Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lholmquist committed Dec 23, 2014
1 parent 1dbc7ea commit 16086c7
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,86 @@ Here is an example
console.log(err);
});


#### Sub Resources

There are some values that return a link. To make it easier to deal with these, there are corresponding getters for those properties.

For example, a call to `getPerson(1)` might return this json:

{
"name": "Luke Skywalker",
"height": "172",
"mass": "77",
"hair_color": "blond",
"skin_color": "fair",
"eye_color": "blue",
"birth_year": "19BBY",
"gender": "male",
"homeworld": "http://swapi.co/api/planets/1/",
"films": [
"http://swapi.co/api/films/1/",
"http://swapi.co/api/films/2/",
"http://swapi.co/api/films/3/",
"http://swapi.co/api/films/6/"
],
"species": [],
"vehicles": [
"http://swapi.co/api/vehicles/14/",
"http://swapi.co/api/vehicles/30/"
],
"starships": [
"http://swapi.co/api/starships/12/",
"http://swapi.co/api/starships/22/"
],
"created": "2014-12-09T13:50:51.644000Z",
"edited": "2014-12-20T21:17:56.891000Z",
"url": "http://swapi.co/api/people/1/"
}

taking "homeworld" as an example, you can now call `getHomeworld()`, which will return a Promise

getHomeworld().then(function (result) {
console.log(result);
});

This might produce some json like this:


{
"name": "Tatooine",
"rotation_period": "23",
"orbital_period": "304",
"diameter": "10465",
"climate": "arid",
"gravity": "1 standard",
"terrain": "desert",
"surface_water": "1",
"population": "200000",
"residents": [
"http://swapi.co/api/people/1/",
"http://swapi.co/api/people/2/",
"http://swapi.co/api/people/4/",
"http://swapi.co/api/people/6/",
"http://swapi.co/api/people/7/",
"http://swapi.co/api/people/8/",
"http://swapi.co/api/people/9/",
"http://swapi.co/api/people/11/",
"http://swapi.co/api/people/43/",
"http://swapi.co/api/people/62/"
],
"films": [
"http://swapi.co/api/films/1/",
"http://swapi.co/api/films/3/",
"http://swapi.co/api/films/4/",
"http://swapi.co/api/films/5/",
"http://swapi.co/api/films/6/"
],
"created": "2014-12-09T13:50:49.641000Z",
"edited": "2014-12-21T20:48:04.175778Z",
"url": "http://swapi.co/api/planets/1/"
}

### Note

This API tries to follow the API for the Python helper lib here: https://github.com/phalt/swapi-python
Expand Down

0 comments on commit 16086c7

Please sign in to comment.