Check out the highlights from Developer Week

What are API Endpoints?

What is an API?

API (Application Programming Interface) is code which bridges data exchange between two applications.

What are API Endpoints?

An API endpoint lies at one end which receives, processes requests from an application and then sends the information requested. It can be defined as the URL (Uniform Resource Locator) for a server or a service.

How are API endpoints used?

Let's suppose you want to build a FinTech website that has the functionality to display information on digital or tangible assets such as cryptocurrency, fiat currency, stocks, gold, or silver. The application might need a third party or a separate entity dedicated to providing updates on cryptocurrency, another one for fiat currency, stocks, and so on. The APIs provided by these companies can be used in a single application to display information for all these different assets.

Similarly, trading bots use APIs from finance websites and applications to access information on assets to execute trading operations.

Your applications will be receiving information by sending requests via APIs, the address where the respective requests are directed is known as an endpoint.

How do API Endpoints work?

API endpoints can be accessed using methods under the HTTP communication protocol.

The following methods can be used to perform CRUD ( create, read, update, delete) operations in RESTful services :

GET: You can retrieve data from an endpoint. For example, retrieve your profile picture to be displayed when you log into Twitter.

POST: Insert data in the servers located at the endpoint e.g. uploading a new tweet on your feed.

PUT & PATCH: Update or modify existing data e.g updating your account’s email address.

DELETE: remove specific data at the endpoint location e.g. deleting a tweet.

Examples of API Endpoints

Details on how to access the API endpoints are provided in the documentation of the service you intend on using.

For instance, if you want to build an online e-commerce website and use Google Firestore as the backend storage option, the documentation provides code snippets on how to perform CRUD operations whenever the database needs to be accessed, consider the following code:

---------------------------------------------------------------------------------------------------------------------------

curl -X PUT -d '{ "first": "Jack", "last": "Sparrow" }' \

  'https://[PROJECT_ID].firebaseio.com/users/jack/name.json'

--------------------------------------------------------------------------------------------------------------------------

This command contains the HTTP method PUT, followed by NoSQL data, and finally a URL or an endpoint where the data object is to be stored, if the operation is successful it returns a 200 OK status code.

Similarly, the following code is used for a delete request:

---------------------------------------------------------------------------------------------------------------------------

curl -X DELETE \

  'https://[PROJECT_ID].firebaseio.com/users/jack/name/last.json'

Platform

Global Data Network
Join the Newsletter