Getting Started with API tools:
When working with CEX and DEX data we will most likely interact with REST APIs. To GET simple REST API response data in JSON format we will use a simple tool called “Insomnia”. This is a free tool that is used to Debug REST (Representational State Transfer) APIs.
Because it is free and really easy to use tool. We can get all the details on every response. Advanced features allow us to view status code, body, headers, cookies, etc. Custom headers and queries, API authentication is an easy approach. The intuitive UI lets us GET JSON data by simply entering URLs, which then returns data in JSON format.
API Endpoint: https://jsonplaceholder.typicode.com/todos/1
"title": "delectus aut autem",
The API endpoint is the URL for GET data. I am writing GET in the capital because there is GET, POST, PUT, PATCH, OPTIONS, DELETE, HEAD are methods associated when working with REST APIs. An endpoint can be edited to get more specific data. These alterations are called parameters at the end of the URL after a question mark.
API Endpoint with Parameter: https://api.crex24.com/CryptoExchangeService/BotPublic/ReturnTicker?request=[NamePairs=BTC_LTC]
This API endpoint specifically returns BTC/LTC pair data as URL parameters have restricted it to do so. Data can be displayed in browser but Insomnia is faster and more formal. It provides us a wide range of options to make it easier to work with APIs. To know more about REST APIs and JSON please read the following article.
Advanced Usage (Headers, Queries)
When we work with public API endpoints it is just a matter of send and go, but if we work with secure APIs that use authentication via API keys there are a few steps associated with Insomnia. Using authenticated APIs is really easy with insomnia. Most APIs provide API keys within the URL. In some cases, we have to manually enter the URL in headers or a query string parameter name. Doing this in insomnia is really easy we will go through coinmarketcap API as an example for this.
Authenticating API with Headers
Authenticating API with Body
Authenticating APIs with headers is the most preferred method. While authentication using query is also convenient.