By Tom Johnson / @tomjohnson
idratherbewriting.com
Slides available at
idratherbewriting.com/slides/documenting_api_endpoints.html
"Resources" refers to the information returned by an API.
The endpoint (aka "path") indicates the URI used to access the resource (e.g., /rewards/items
). The method (aka "operation") indicates the allowed interaction (such as GET, POST, PUT, or DELETE) with the resource.
How would you refer to these two endpoints?
/users/{userId}/rewards/{missionId}
/missions/{missionid}/rewards
Parameters are options you can pass with the endpoint to configure the response. For example, a parameter might specify the number of items returned or the format.
authorization-key: "12345"Path parameter:
/service/myresource/user/{userId}/bicycles/{bicycleId}Query string parameter:
/surfreport/{beachId}?days=3&units=metric&time=1400
{
"days": 2,
"units": "imperial",
"time": 1433524597
}
/surfreport/{beachId}?days=3&units=metric&time=1400 /surfreport/{beachId}?time=1400&units=metric&days=3
/service/myresource/user/{userId}/bicycles/{bicycleId}
... is not the same as:
/service/myresource/user/{userId}/{bicycleId}/bicycles
The request example includes a sample request using the endpoint, showing some parameters configured.
The response example shows a sample response from the request example; the response schema defines all possible elements in the response.