What is an Application Programming interface? It's exactly what it says - an interface between two application programs, a piece of software that allows different apps to communicate with each other. In the same way that you use the black box pieces of code on a no-code platform to build an app, your app can use an API to create a connection to another application like Stripe or Facebook and exchange information with that service. The API itself is simply a piece of software installed on the server you want to access.
When the two computers connect or "integrate" via the API, they have to agree on the set of rules (or "protocol") they're going to use to communicate with each other (similar to two people deciding what language to use to carry on a conversation). Since Hyper-Text Transfer Protocol (HTTP) is the most common protocol on the Internet, many APIs use it as their communication protocol.
Once a connection is established, the client (your app) sends a request to the other computer (the server) and receives one of three responses (an acknowledgment that the request was handled successfully, an error message explaining that the request failed, or the data requested by your app). The request sent by your app is made up of four parts:
- A URL that provides the location you want to connect to on the server. The URL itself consists of three parts:
- The address of the server (www.youtube.com).
- The specific location you want to reach on the server (/results).
- The query string parameters (?search_query=bubble.io).
- The HTTP method:
- GET request - Asks the server to retrieve a resource (a webpage, product, image, etc.).
- PUT request - Asks the server to update a resource (change the address in a customer record for example).
- POST request - Asks the server to create a new resource (e.g. create a new customer record with the data in the body of the request).
- DELETE request - Asks the server to remove a resource (e.g. delete an inactive customer record).
- Header records: Additional information to pass on to the server, such as the time of the request, the request authorization, type of content, and response cookies.
- As part of a query string in the URL (?something+API-key).
- In an HTTP header record.
- A user name and password (which act as the API-key) can be sent as part of each request.
- 200 - Request succeeded.
- 404 - The requested resource doesn't exist.
- 503 - Website is currently unavailable.
- 1xx - Request received, continuing to process.
- 2xx - Success (requested data delivered or requested action completed).
- 3xx - Redirection (additional processing needed to complete the request).
- 4xx - Client errors; the request isn't correctly structured or can't be fulfilled.
- 5xx - Server errors; the server failed to handle the request correctly.