By Tom Johnson / @tomjohnson
idratherbewriting.com
Slides available at
idratherbewriting.com/intro-to-api-documentation/
The following is a video recording of this presentation.
See also yahoo weather
curl --get --include 'https://simple-weather.p.mashape.com/weatherdata?lat=37.3710062&lng=-122.0375935' \
-H 'X-Mashape-Key: EF3g83pKnzmshgoksF83V6JB6QyTp1cGrrdjsnczTkkYgYrp8p' \
-H 'Accept: application/json'
Command | Description |
---|---|
-i or --include |
Include response headers |
-d or --data |
Include data to post |
-H or --header |
Submit header |
-X POST |
The HTTP method to use |
@filename |
Load content from a file |
JSON objects:
{
"key1":"value1",
"key2":"value2"
}
JSON arrays:
["first", "second", "third"]
Wind speed:
data.query.results.channel.wind.speed
Wind direction:
data.query.results.channel.wind.direction
Wind chill:
data.query.results.channel.wind.chill
The information contained in the resource — brief (1-3 sentences) and usually starts with a verb.
The URL path where the resource can be accessed. Doesn't include the base path.
/campaigns/{campaign_id}/actions/send
The operations allowed for the resource URL (GET, POST, PUT, DELETE, etc.)
The same resource often has multiple operations, so organize them as it makes sense for your API.
Options you can use with the endpoint. There are four types of parameters: header, path, query string, and request body.
/surfreport/{beachId}?days=3&units=metric&time=1400
/surfreport/{beachId}?time=1400&units=metric&days=3
{
"days": 2,
"units": "imperial",
"time": 1433524597,
"active": true
}
A sample request to the resource, showing the endpoint and parameters configured.
Requests execute real operations on the client's data. It isn't a sandbox.
Sample response from a request (not comprehensive of all parameter configurations or operations).
Code in the response that indicates a general status of the response. Most status codes (e.g., 200, 302, 500, etc.) are standard.
Status codes are often included with the response examples.
Sample code snippets for submitting a request to the endpoint using a particular programming language. Optional.
Tom Johnson
— idratherbewriting.com
— @tomjohnson
— [email protected]