What is an API?
In short an API stands for application programming interface. They are mechanisms that allow 2 software components to talk to one another using definitions and protocols. Ex. The National Weather Service has an API.
It allows companies to consume pre-existing programs without building their own in-house. Ex weather applications
https://www.weather.gov/documentation/services-web-api
Collective list of free APIS (many many different types)
https://github.com/public-apis/public-apis
In the above example you are a customer making a request. The API is the waiter or waitress. You have a predefined protocol/language. Have a set menu of items (schema) and protocol (language ie. english, spanish).
The customer in this case is the client, such as web browsers, mobile apps, smart TV etc. The waiter is the API that interfaces with the backend. In this case the chef. The chef takes the inputs from the request. Ie. Cheeseburger, cooked medium with a side of sweet potato fries. No tomatoes.
Then the chef or backend service fulfills the request and hands it to the server. A good response is you get exactly what you have asked for. Also known as a status 200.
If this don't go 100% there are different status codes
200 - OK, successful responses
300 - re-direction
400 - client error (bad input, or resource was not found or not authorized)
500 - server error responses (service unavailable, internal server error etc.)
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
Modern APIs often have common conventions and standards and have evolved over the years.. The most common oneĀ we see now are known as RESTful api. REST stands for representational state transfer. There are a defined set of functions like GET, PUT, DELETE on a defined protocol exchanging data using HTTP https://developer.mozilla.org/en-US/docs/Web/HTTP.
It appears stateless meaning that servers don't save clients data between requests and the response is plain data
The main advantages of A REST api are how easy they can be to integrate with new applications and existing systems. Can make development faster because you are not reinventing the wheel.
It allows innovation and businesses can re-write just the API portion of their application vs their entire codebase.
If you look around the web on different sites, you will find many different API uses.an example would be a wether app. Lets look at top new sties around the web. Here is a small example of a weather API implementation.
Google News
The new york times
MSN
Yahoo
If we do some investigation below we can see that the weather for nytimes comes back from the following endpoint. It probably uses another API to get the relevant location, pass in the longtidue/lattitude coordinates to get a 'location' unique ID.
https://content.api.nytimes.com/svc/weather/v2/current-and-seven-day-forecast.json
We can see it is returned in JSON format a very common data object response.
In conclusion
TLDR