By Tom Johnson / @tomjohnson
idratherbewriting.com
See also yahoo weather
Find Weather by fyhao on Mashape
Get the Mashape API keys so you can make requests.
Make a request to each weather endpoint using Postman.
curl http://example.com
curl http://example.com -i
curl http://example.com -I
curl -X GET http://example.com -I
/* GET, POST, PUT, DELETE */
curl --get --include 'https://simple-weather.p.mashape.com/aqi?lat=37.3
54108&lng=-121.955236' \
-H 'X-Mashape-Key: {api key}' \
-H 'Accept: text/plain'
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 |
curl -i -H "Accept: application/json" -X POST -d "{status:MIA}"
http://personsreport.com/status/person123
Test your memory:
-i
means...-H
means...-X POST
means...-d
means...
{
"key1":"value1",
"key2":"value2"
}
["first", "second", "third"]
[
{
"name":"Tom",
"age":39
},
{
"name":"Shannon",
"age":37
}
]
{
"children": ["Avery","Callie","lucy","Molly"],
"hobbies": ["swimming","biking","drawing","horseplaying"]
}
Identify the objects and arrays in the weatherdata endpoint response.
Create a sample web page and print the weather description to the page following the instructions in 2.1.
data.query.results.channel.item.description
console.log (data.query.results.channel.item.description);
Print the weather description to the page.
"data": {
"name": "Tom"
}
Access "Tom" using data.name
.
"data" : {
"items": ["ball", "bat", "glove"]
}
To access glove, you would use data.items[2]
.
Practice accessing different values through dot notation following the exercise on 2.3.
Create the basic structure for the endpoint documentation
api_site.com/{apikey}/users
// gets all users
api_site.com/{apikey}/users/{userId}
// gets a specific user
api_site.com/{apikey}/rewards
// gets all rewards
api_site.com/{apikey}/rewards/{rewardId}
// gets a specific reward
api_site.com/{apikey}/users/{userId}/rewards
// gets all rewards for a specific user
api_site.com/{apikey}/users/{userId}/rewards/{rewardId}
// gets a specific reward for a specific user
api_site.com/{apikey}/users/{userId}/rewards/{missionId}
// gets the rewards for a specfic mission related to a specific user
api_site.com/{apikey}/missions/{missionid}/rewards
// gets the rewards available for a specific mission
Critique the Mashape Weather API descriptions.
Compare with Xweather API descriptions.
Write the resource description for surfreport.
/campaigns/{campaign_id}/actions/send
Write the endpoint definition and method for surfreport.
/surfreport/{beachId}?days=3&units=metric&time=1400
/surfreport/{beachId}?time=1400&units=metric&days=3
{
"days": 2,
"units": "imperial",
"time": 1433524597
}
Construct a table to list the surfreport parameters
Document the sample request with the surfreport/{beachId} endpoint
Create a sample response in your surfreport/{beachId} endpoint.
See also Twilio
Generate a JavaScript code sample from Postman following the steps in 3.0.
Create a code sample for the surfreport endpoint.
Authorization: Basic bG9sOnNlY3VyZQ==
See also the Shopify cheat sheet.
Swap in {api key}
for the real value. You can use my keys.
Note: JS display activities are optional.
Use the EventBrite API to get the event title and description of this event.
Use the Flickr API to get photo images from this Flickr gallery.
Use the Klout API to get your Klout score and a list of your influencers and influencees.
Use the Xweather API to get the wind speed (MPH) for a specific place (your choice).
Hooray! You finished the documenting APIs part of the course! Now, on to publishing API docs.
Look at about 5 different APIs from the list on "4.6 List of 100 APIs." Identify one thing that the APIs have in common.
Following the instructions in 4.9, do the following:
## Heading 2
This is a bulleted list:
* first item
* second item
* third item
This is a numbered list:
1. Click this **button**.
2. Go to [this site](http://www.example.com).
3. See this image:

For a detailed example, see the code sample on 5.0.
On your Github wiki page, edit the page and create the following:
Follow the instructions in 5.4 to create a Swagger output using the information from the Mashape Weather API.
reindeer:
- Donner
- Blitzen
- Comet
- Cupid
hobbies:
active:
- flying
- prancing
inactive:
- pawing
- driving
items:
- title: Course overview
url: /docapis_course_overview/
weight: 1.0
audience: writers
address: 1234 main street
route: Google maps
{
"reindeer": [
"Donner",
"Blitzen",
"Comet",
"Cupid"
],
"hobbies": {
"active": [
"flying",
"prancing"
],
"inactive": [
"pawing",
"driving"
]
},
"items": [
{
"title": "Course overview",
"url": "/docapis_course_overview/",
"weight": 1,
"audience": "writers"
}
],
"address": "1234 main street",
"route": "Google maps"
}
Follow the instructions in 5.6 to create a RAML output using the information from the Mashape Weather API.
Follow the instructions in 5.7 to create an API Blueprint output using the information from the Mashape Weather API.
Fork the Documentation theme for Jekyll and publish it via CloudCannon following the instructions in 5.8.
Explore creating pages and publishing API documentation (the Weather Mashape API info) on readme.com.
Programming skills needed to document native library APIs?
Download the acme sample project on Github following the instructions in 7.2.
public class Bicycle {
// code...
}
add(a, b) {
sum = a + b;
}
class Bicycle {
void turn() {
// code ...
}
void pedal(int rotations) {
System.out.println("Your speed is " + rotations + " per minute".);
}
int brake(int force, int weight) {
torque == force * weight;
return torque;
}
}
public static void main(String[] args) {
//Java runs the code it finds within this method...
}
class Bicycle {
String brand;
int size;
}
public enum Spoke { SINGLE-BUTTED, DOUBLE-BUTTED, TRIPLE-BUTTED };
myBicycle Bicycle = new Bicycle();
myBicycle.brand = "Trek";
myBicycle.pedal();
public class Bicycle{
public Bicycle(String brand, int size) {
this.brand = model;
this.size = size;
}
}
Bicycle myBicycle = new Bicycle ("Trek", 22);
package vehicles
public class Bicycle {
}
public class Bicycle throws IOException {
}
public class Bicycle extends Vehicle {
}
public interface Wheel {
public void rotate();
}
public class MountainBikeWheel implements Wheel {
public void rotate() {
System.out.println("whoosh ... whoosh .... whoosh");
}
}
// sample comment...
/*
sample comment
*/
/**
*
*
*
*
*/
/**
* [short description]
*
* [long description]
*
* [author, version, params, returns, throws, see, other tags]
* [see also]
*/
/**
* Short one line description.
*
* Longer description. If there were any, it would be
* here.
*
* And even more explanations to follow in consecutive
* paragraphs separated by HTML paragraph breaks.
*
* @param variable Description text text text.
* @return Description text text text.
*/
public int methodName (...) {
// method body with a return statement
}
@author (classes and interfaces)
@version (classes and interfaces)
@param (methods and constructors)
@return (methods)
@throws (@exception is an older synonym)
@see
@since
@serial
@deprecated
@param url the web address of the site
@throws IOException if your input format is invalid
@see #field
@see #Constructor(Type, Type...)
@see #Constructor(Type id, Type id...)
@see #method(Type, Type,...)
@see #method(Type id, Type, id...)
@see Class
@see Class#field
@see Class#Constructor(Type, Type...)
@see Class#Constructor(Type id, Type id)
@see Class#method(Type, Type,...)
@see Class#method(Type id, Type id,...)
@see package.Class
@see package.Class#field
@see package.Class#Constructor(Type, Type...)
@see package.Class#Constructor(Type id, Type id)
@see package.Class#method(Type, Type,...)
@see package.Class#method(Type id, Type, id)
/**
* First paragraph.
*
* Link to a class named 'Foo': {@link Foo}.
* Link to a method 'bar' on a class named 'Foo': {@link Foo#bar}.
* Link to a method 'baz' on this class: {@link #baz}.
* Link specifying text of the hyperlink after a space: {@link Foo the Foo class}.
* Link to a method handling method overload {@link Foo#bar(String,int)}.
*/
public ...
… auto-generated documentation is worse than useless: it lets maintainers fool themselves into thinking they have documentation, thus putting off actually writing good reference by hand. If you don’t have documentation just admit to it. Maybe a volunteer will offer to write some! But don’t lie and give me that auto-documentation crap. — Jacob Kaplan Moss
Tom Johnson
— idratherbewriting.com
— @tomjohnson
— [email protected]