Sudo Soldiers
04.23.2014
name: value
pairs{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 25,
"height_cm": 167.64,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{ "type": "home", "number": "212 555-1234" },
{ "type": "fax", "number": "646 555-4567" }
]
}
REST is all about simplifying API's. It defines 4 methods (verbs):
Create – GET: /user/new?name=John
Read – GET: /user/1
Update – GET: /user/1/update?name=Doe
Delete – GET: /user/1/delete
Simply:
Create – POST: /user (with request body)
Read – GET: /user/1
Update – PUT: /user/1 (with request body)
Delete – DELETE: /user/1
Consider http:/test.com/user/1
. Here, user/1
is a resource.
Set of attributes related to the resource returned by the URI. A `GET http:/test.com/user/1` returns the representation of a user as:
name: John
Age: 21
Representation has a format (XML, JSON, JSONP) and a language (en, de).
GET /events - get all events
GET /events/concerts - get all concerts
GET /events/concerts/123 - get a specific concert
Client to Server
Server to Client
Trying to find a good "acronyms api". Why didn't I think this through before searching?
— Karan Goel (@TheKaranGoel) April 15, 2014
We have the data and starter code. Let's hack something!
Use Postman to test the API.
git push heroku master
# make a Procfile
$ echo "web: node app.js" > Procfile
# test using foreman
$ foreman start
# (git add, git commit your code)
# create an app
$ heroku create [app name]
# to the moon
git push heroku master