Connecting with other applications
"FB, Talk to me!"
API's are interfaces for code/computers to talk to one another.
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
Get Some Data Back!
Search for Beyonce Albums
Search for Beatles Songs
Search for Podcasts About "code"
Search for Harry Potter Movies
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 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 looks exactly like JavaScript objects, but everything is a string
{
"person": {
"age": "21",
"name": "Travis",
"city": "Los Angeles"
}
}
{
"person": {
"age": "21",
"name": "Travis",
"city": "Los Angeles"
}
}
<person>
<age>21</age>
<name>Travis</name>
<city>Los Angeles</city>
</person>
{
"person": {
"age": "21",
"name": "Travis",
"city": "Los Angeles"
}
}
<person>
<age>21</age>
<name>Travis</name>
<city>Los Angeles</city>
</person>