Anatomy of APIs
Tags: webdev, computerscience, writing, api
Published: 2022-03-30 15:11:13

## What Even Is An API
APIs are in a way the foundation of functionality within a web application. API or Application Programming Interface is a type of software that sends and receives data or services from another software. An API is almost never directly interacted with the user, only implemented by the developer of the application. There are many types of APIs and different ways to use them within your software. 

APIs have different actions that can do with a specified request from the application. There are four main actions that APIs preform which are GET, POST, PATCH, and DELETE. These four actions directly interact with the API through specified request from the developer. 

- GET: This request sends back specified data or sends back a specific service (API can send back product information)

- POST: This adds/creates data to the API (Adding a new product)

- PATCH: This updates existing data within the API (Changing  the price of a product)

- DELETE: This removes data from the API (Takes away a product once it sells out)

There are more types of API actions but these are the most commonly used ones and most important. 

## Within The API

APIs can be built using multiple different languages such as Ruby, Python, and Java to name a few. When building an API there is a lot that has to be taken into account. For instance who do you want using it? What can they do with your API? What kind data is being sent back? All of these have to be taken into consideration when creating an API. A lot of this can be controlled by creating these routes within the API. 

The creator of an API will write out specific routes that will then hit controller methods that will render json data back to the application. The application then uses the send back JSON data to parse it into the used programming language. Routes have to specified on which kinda of request they are (i.e GET, POST, PATCH, DELETE, etc...).  Controller methods then have to have corresponding name definitions so that the route knows which method to use when the route is hit. The API knows which action to do as it has to be specified within the method request. 

APIs also have specific endpoints that the software has to call to in order to receive the desired data/service. These endpoints can look a bit different based on the API. An API endpoint will usually start the same with the name of API then followed by "/" can route to specific parts of the API. For example if an API was running on a localhost then a request to "Http://localhost:4000/users" with a method of "GET" will send me back user data. Due to the "users" after the "/" the API software knows that I am calling for user data and not data about products. 


APIs are often made to accomplish a specific goal. There are different types of APIs that can be made. The kind of API talked about here is identified  as a REST API. These kind of APIs are very scaleable and their capabilities are entirely decided by what the developer can do. APIs run our everyday world in the background being the foundation of endless technologies that everyone uses on a day to day basis. 

##Sources 
https://www.bigcommerce.com/blog/what-is-an-api/#the-apis-fueling-your-bigcommerce-site
https://blog.hubspot.com/website/types-of-apis
https://en.wikipedia.org/wiki/API