API documentation templates to get you started

API Title

Enter a brief description of the API such as why developers will find it important.
Then, list of all the API endpoints, including their URLs, methods, request and response formats, and error handling.

Endpoint 1

A description of the first endpoint, including its purpose, benefit, and usage scenario.

Request

Details about the request for this endpoint, including the endpoint URL, method, headers, and request body.

Endpoint URL

The full URL of the endpoint, including the base URL and any path parameters:

https://api.example.com/v1/endpoint1

Method

The HTTP method used for this endpoint, such as GET, POST, PUT, or DELETE.

Headers

Displays a list of the headers required for this endpoint, including Content-Type or Authorization.

- Content-Type: application/json
- Authorization: YOUR_API_KEY

Request Body

A sample request body for this endpoint, including any required parameters and their data types.

{
  "property1": "item1",
  "property2": 12345
}

Response

Details about the response for this endpoint, including success and error responses.

Success

Displays a description of a successful response, including the HTTP status code and a sample response body.

HTTP Status: 200 OK

{
  "status": "success",
  "message": "Successful response"
}

Error

Displays a description of an error response, including the HTTP status code and a sample response body.

HTTP Status: 400 Bad Request

{
  "status": "error",
  "message": "Bad request"
}

That’s probably as basic as it gets for simple API template. If you want something a bit more visually appealing, you can use JSON or YAML and create some API documentation in Swagger!

Generic API sample in Swagger

Basic template for representing API documentation using Swagger 3.0.

Travel booking sample API

Here is a sample API for booking flights, hotels, and rental cars for travel.

Endpoints

A list of all the API endpoints, including their URLs, methods, request and response formats, and error handling.

Flight Booking

A endpoint for booking flights.

Request

Details about the request for this endpoint, including the endpoint URL, method, headers, and request body.

Endpoint URL

The full URL of the endpoint, including the base URL and any path parameters.

https://api.travelbookingapp.com/v1/flights

Method

The HTTP method used for this endpoint, such as GET, POST, PUT, or DELETE.

Headers

A list of the headers required for this endpoint:

- Content-Type: application/json
- Authorization: YOUR_API_KEY

Request Body

A sample request body for this endpoint.

{
  "departure_city": "Dallas",
  "arrival_city": "London",
  "departure_date": "2023-06-01",
  "return_date": "2023-06-10",
  "passenger_count": 2
}

Response

Details about the response for this endpoint, including success and error responses.

Success

A description of a successful response, including the HTTP status code and a sample response body.

HTTP Status: 200 OK

{
  "status": "success",
  "message": "Flight booked successfully",
  "flight_id": "abc123"
}

Error

A description of an error response, including the HTTP status code and a sample response body.

HTTP Status: 400 Bad Request

{
  "status": "error",
  "message": "Invalid departure or arrival city"
}

Hotel Booking

A endpoint for booking hotels.

Request

Details about the request for this endpoint, including the endpoint URL, method, headers, and request body.

Endpoint URL

The full URL of the endpoint, including the base URL and any path parameters.

https://api.travelbookingapp.com/v1/hotels

Method

The HTTP method used for this endpoint, such as GET, POST, PUT, or DELETE.

Headers

A list of the headers required for this endpoint:

- Content-Type: application/json
- Authorization: Bearer YOUR_API_KEY

Request Body

A sample request body for this endpoint, including any required parameters and their data types.

{    "city": "London",   
 "check_in_date": "2023-06-01",   
 "check_out_date": "2023-06-10",   
 "room_count": 2 
}

Response

Details about the response for this endpoint, including success and error responses.

Success

A description of a successful response, including the HTTP status code and a sample response body.

HTTP Status: 200 OK

{
"status": "success",
"message": "Hotel booked successfully",
"hotel_id": "xyz789"
}

Error

A description of an error response:

HTTP Status: 400 Bad Request

{
"status": "error",
"message": "Invalid city"
}

Rental Car Booking

A endpoint for booking rental cars.

Request

Details about the request for this endpoint, including the endpoint URL, method, headers, and request body.

Endpoint URL

The full URL of the endpoint:

https://api.travelbookingapp.com/v1/cars

Method

The HTTP method used for this endpoint, such as GET, POST, PUT, or DELETE.

Headers

A list of the headers required for this endpoint:

Content-Type: application/json
Authorization: YOUR_API_KEY

Request Body

A sample request body for this endpoint:

{ 
  "pickup_city": "Austin", 
  "dropoff_city": "San Francisco", 
  "pickup_date": "2023-07-01", 
  "dropoff_date": "2023-07-10" 
}

Response

Details about the response for this endpoint

Success

A description of a successful response:

HTTP Status: 200 OK

{
"status": "success",
"message": "Rental car booked successfully",
"car_id": "abc890"
}

Error

A description of an error response:

HTTP Status: 400 Bad Request

{
"status": "error",
"message": "Invalid pickup or dropoff city"
}

Common error codes in API documentation

400 Bad Request: The request was malformed or missing required parameters.
401 Unauthorized: The API key provided in the request is invalid or has been revoked.
404 Not Found: The requested resource could not be found.
500 Internal Server Error: An error occurred on the server while processing the request.

Travel booking sample in Swagger

Swagger 3.0 example:

en_USEnglish