TECHNOLOGY

What does API Mean?

What does API Mean?

An API short for Application Programming Interface means a set of functions codes allowing applications to access specified data and interact with external software applications components, operating systems or microservices.

To simplify, an API delivers a user response to a system and sends the system’s response back to a user. You click “add to cart;” an API tells the site you added a product to your cart; the website puts the product in your cart, and your cart is updated.

You may hear the term “microservices” come up in relation to API. These however, are not the same. Microservices are a style or architecture which divides functionality within a web application. While API is the framework which developers interact with a web application. Microservices can actually use API to communicate between each other.

API lets a developer make a specific “call” or “request” in order to send or receive information. This communication is done using a programming language called “JSON.”  It can also be used to make a defined action such as updating or deleting data. There are four basic request methods that can be made with API:

GET – Gathers information (Pulling all Coupon Codes)

PUT –  Updates pieces of data (Updating Product pricing)

POST – Creates (Creating a new Product Category)

DELETE – (Deleting a blog post)

What is JSON and Why is It Used?

JSON (JavaScript Object Notation) is used to represent data on a server. It’s fairly easy to read by humans, and easy for machines/applications to understand. Let’s look at an example of JSON from a product on BigCommerce:

This is easy to understand as it’s outputted in key/value pairs, with the key on the left, and a value on the right. Keys are a fixed object defined by the application and will remain the same as with “category.” Whereas the values will be unique, such as “Shirts.”

What is an API Request?

There are several components of an API Request in order for it to function. Let’s go over these individually and how they can be used to build a request.

What is Endpoint?

There are two key parts to an endpoint that are used when making an API request. One of which is the URL. BigCommerce uses https://api.bigcommerce.com/stores/ as the URL for all API Requests. This may look like a regular URL but if you plug this into a web browser, you will receive a 404 error message.

The second part is the path. The path will vary depending on what you are trying to accomplish. You can find a list of available paths for BigCommerce by visiting our developer documentation: https://developer.bigcommerce.com/api-reference. For this example we are going to use the product path which is /v3/catalog/products.

When we put these two parts together, we get a complete endpoint https://api.bigcommerce.com/stores/{store_hash}/v3/catalog/products. Now you may be saying to yourself “What is the {store_hash}?“ “Where did that come from?” This is what is known as a variable. Variables are unique components to an endpoint and will vary depending on your store’s information. You can spot a variable by the open and closed brackets “{ }”.

What is Header?

Headers provide information to the client and server. Common examples of a header would be authentication credentials such as a “Auth Token” or “Client ID”. These credentials are provided to you automatically when you create an API Account. Another common header is referred to as the “Content Type,” which informs the server about what type of content will be sent. For example, a commonly used content type is  “application/json” which let’s the server know, we are sending JSON data across.

What is Method?

Methods are the actions taken when sending a request. Think back to the beginning when we discussed GET, PUT, POST, and DELETE. These are all API Methods.

What is Data?

The request data, also commonly referred to as the “body,” is information that will be either sent to or returned by a server. In the previous discussion of JSON, you can see an example of API data. The body of a request will sometimes require specific information before it can be delivered. An example of this is if you are editing a single product, the Product ID will be required before any change can be made.

Read more here.

[optin-monster slug=”em8z7q6hga9elmy1dbgb”]

YOU MIGHT ALSO LIKE...