- **Epistemic status:** #evergreen ![[Pasted image 20220428094110.png]] The Application Programming Interface (API) is in charge of taking in requests for data and sending a response of the data requested. To give it more context, imagine you are in a restaurant and the waiter (API) comes to your table asking what are you going to order. You will then tell the waiter, and they will go back to the kitchen (Server) telling the chefs the order. After some time, the waiter will pick up the food you ordered and serve it to you. Let's extend the definition since we are missing some key features by taking a look at one type of API called the Data API. This type of API is in charge of not only getting data but updating, deleting, and creating that data ([[CRUD]]). API's may need a server that handles each request to verify, run the operation, then return the result. Servers are just another computer that is designed for a specific use case. On its core, API's help communication between services controlling access and how that data is distributed. ## Types of API's Let's take a look at the general types of API: - **Open API's:** They are publicly available, allowing access to developers to use them. These APIs might require having an account to them, but are still open for personal or commercial use. - **Partner API's:** They are open only to business partners, having restrictions on who can access them and what the developer can do. - **Internal API's:** API's that are only used by the person or entity that made them. They are not distributed to anybody outside that group. - **Composite API's:** Combines multiple data services or API's allowing the developer to use more than one endpoint. An example of this type of API is microservices architecture. API's can also be categorized into two major categories: - **Data API's:** Provide a way of manipulating data on a software application by using [[CRUD]] operations. - **Hardware API's:** Let's say you want to develop an app for Android and you need access to the camera to allow users to take a profile picture. Android has large numbers of APIs that allow these operations on the hardware of the device. Depending on the device and OS, they can differ. API's can have a combination of hardware and software to complete an operation. Using our picture example, when we take a picture using the camera API on the hardware, we might need to send that data to update the user profile picture on the database doing an Update operation. The hardware APIs can be considered open APIs because they can be accessed by any developer, meanwhile the API that is updating the profile picture can be internal because no other developer can access it. Just the application. ## API Protocols When utilizing API's we require certain protocols to allow developers to be on the same page when utilizing an API. These protocols give rules to the API that it must adhere to. We are going to take a look at the major ones: - [[Representational State Transfer (REST)]] - [[Simple Object Access Protocol (SOAP)]] - [[GraphQL]] - JSON-RPC - gRPC - Thrift If you want to build your own API, you can follow the project [[Basic REST API using Node and Express]] --- ## References - “API.” In _Wikipedia_, April 26, 2022. <https://en.wikipedia.org/w/index.php?title=API&oldid=1084801516>. - Castellani, Stephane. “Types of APIs | The Different Types of APIs in 2020.” _Axway Blog_ (blog), April 29, 2020. <https://blog.axway.com/amplify-products/api-management/different-types-apis>. - “Know Your API Protocols: SOAP vs. REST vs. JSON-RPC vs. GRPC vs. GraphQL vs. Thrift.” Accessed April 28, 2022. <https://www.mertech.com/blog/know-your-api-protocols>. - MuleSoft Videos. _What Is an API?_, 2015. <https://www.youtube.com/watch?v=s7wmiS2mSXY>. - How-To Geek. “What Is an API, and How Do Developers Use Them?” Accessed April 28, 2022. <https://www.howtogeek.com/343877/what-is-an-api/>. - freeCodeCamp.org. “What Is an API? In English, Please.,” December 19, 2019. <https://www.freecodecamp.org/news/what-is-an-api-in-english-please-b880a3214a82/>.