Professional Documents
Culture Documents
Allaboutapis
Allaboutapis
An easy example is the Star Wars API. If I wanted to make a website about Star Wars, instead of finding
and creating all the data myself, I could build a website that focuses on pulling data from an existing Star
Wars API.
So I could have a search feature with parameters like "planet", "date", "ship", "allegiance", etc.
If someone wanted to find a list of characters from a desert planet named Tatooine, they could choose
that from a dropdown and then run the search.
My website would take that "tatooine" parameter, ask the Star Wars API for info that matches the
"key":"value" pair of "planet":"tatooine", and then deliver those results back to the user's computer
through my website.
Those "key": "value" pairs are the sets of data within an API. The "value" could be a string, number,
array, object, etc. So you could have a very simple API like this:
"friend1": [
"age": 50,
"children": false
],
"friend2": [
"age": 40,
That data would be saved as a JSON file. Let's pretend the file is named "friends.json". Then we can
access that data with something like:
console.log(starWarsAPI.ships["millenium falcon"].pilot.preferredWeapons())
console.log(milleniumFalcon.pilot.preferredWeapons())
I don't actually know the Star Wars API and all of the above was just made up as an example.