On Github ktzhu / power-of-apis
JOUR 390 | Spring 2013
Application Programming Interface.
Pull in outside data
↓Send messages
↓Connect to other services (Facebook, Twitter)
↓Powerful, dynamic apps.
More specifically, today we'll cover:
The Internet – what is it
HTTP
Client + server model
REST easy
RESTful APIs
Requests
How'd it go?
Technical concerns, too hard? Chat also about some ideas for using APIs in their projects.What happens when you type this into your browser?
Name gets translated to IP address (involves your computer, the client, talking to a server).
After IP address gets resolved, your browser goes to eecs.northwestern.edu to request the files for the webpage.
Extremely simplified, but this leads us to ...
HyperText Transfer Protocol
Basically, rules that govern how content gets from one place to another in the depths of the intertubez.
We use HTTP to get pages on the Internet. Where do these pages come from?
YOU GUESSED IT, THE INTERNET.
But actually, other computers on the Internet: servers.
Try it yourself:
var xhr = new XMLHttpRequest(); xhr.open("GET", "http://www.codecademy.com/", false); xhr.send(); console.log(xhr.status); console.log(xhr.statusText);
The Internet is full of clients. They want a lot of things.
(things = web pages, files, scripts, images, audio, video ...)
Servers store this information and will send a response back to you.
HTTP is kind of like the social conventions for talking on the web.
Request: Ask and you shall receive.
Response: A good server will acknowledge your request.
Representational State Transfer.
All you need to know: set of principles around the existence of resources [anything URI addressable] and manipulation of those resources.
HTTP is built on REST principles. Most web APIs are also designed to be RESTful (adhering to REST principles).
When you (client) are on a website, and you click that link to a chill sloth gif, you are, in REST terms, making a state transition.
The server then processes this request, returns the appropriate resources to you.
APIs! That's why you're here, right?
APIs: think of as a ~~~*~code contract~~*~ that says how programs can interact with a given application or service.
Let's say you wanted get all the tweets hashtagged with #boston. You would need to use Twitter's API, which specifies how you authenticate (login), which URLs you go to get the data, and so forth.
We call an API "RESTful" if it does the following:
Google + API documentation.
Any questions?