Intro to API's
Connecting with other applications
API
Application Programming Interface
"FB, Talk to me!"
API's are interfaces for code/computers to talk to one another.
Web API's
Generally communicate via HTTP
- Twitter API, give me all tweets that mention "ice cream"
- Facebook API, send me the current user's profile picture
- Weather API, what is the weather in Missoula Montana?
- Reddit API, what is the current top post?
- GooglePlaces API, what gas stations are near the user?
- Yelp API, give me 10 restaurants in the zipcode 94110
A Human Interface
The itunes API
Make an HTTP request to:
https://itunes.apple.com/search?term=beyonce&entity=musicVideo
https://itunes.apple.com/search?term=beyonce&entity=album
https://itunes.apple.com/search?term=beatles&entity=song
https://itunes.apple.com/search?term=code&entity=podcast
https://itunes.apple.com/search?term=harry-potter&entity=movie
Make an HTTP request to an API
Get Some Data Back!
Search for Beyonce Albums
Search for Beatles Songs
Search for Podcasts About "code"
Search for Harry Potter Movies
Data Formats
When we use the internet, we make HTTP request and get HTML back.
API's don't respond with HTML. HTML contains information about the structure of a page. API's respond with data, not structure.
They use simpler data formats like XML and JSON
XML
Extended Markup Language
XML is syntacticly similar to HTML, but it does not describe presentation like HTML does
<person>
<age>21</age>
<name>Travis</name>
<city>Los Angeles</city>
</person>
JSON
Javascript Object Notation
JSON looks exactly like JavaScript objects, but everything is a string
{
"person": {
"age": "21",
"name": "Travis",
"city": "Los Angeles"
}
}
XML vs. JSON
{
"person": {
"age": "21",
"name": "Travis",
"city": "Los Angeles"
}
}
<person>
<age>21</age>
<name>Travis</name>
<city>Los Angeles</city>
</person>
XML vs. JSON
{
"person": {
"age": "21",
"name": "Travis",
"city": "Los Angeles"
}
}
<person>
<age>21</age>
<name>Travis</name>
<city>Los Angeles</city>
</person>
Intro to API's
By Colt Steele
Intro to API's
- 2,378