Guide to use Merlin API

In this page you will find some examples to help you understand how to get started with Merlin's API and how to access the different endpoints. You will see how to obtain your API Key and how to use it through a GUI or a Terminal.

Sign up to get API Key

Step 1: Sign up with an email address on api.mymerlin.io to obtain your exclusive API key.

Step 2: You will receive an email that your account has been topped up with 4000 free units.

Identify Endpoints

Explore this API documentation and identify the endpoints(s) to use. Merlin's API data is structured:

  • DeFi Positions: get a user's (wallet) exposure to DeFi, both active and past Positions, with or without performance P&L analytics

  • Transactions: get a user's (wallet) full on-chain Transactions activity, filter by Chains or by Time Period

    • Pre-Classified Transactions - NEW: get full on-chain Transactions activity including accounting & tax ready classification information

  • User Balances: get a user's (wallet) holdings, both wallet holdings and DeFi invested assets

  • Protocols: get Merlin supported protocols and chains

  • API Units Usage: get the unit balance of your API Key usage (holdings and daily consumption)

First Tests

Let's assume we want to access the endpoint related to token balances of a specific user (see all details in the "API Reference" section). We can simulate the following scenario:

  • Endpoint: https://merlin-api-v1.cf/api/merlin/public/balances/token/{user}

  • User: 0x171c53d55b1bcb725f660677d9e8bad7fd084282

  • API Key: 123456

In order to fetch the data we want, we will fulfill the following information:

  • Endpoint: https://merlin-api-v1.cf/api/merlin/public/balances/token/0x171c53d55b1bcb725f660677d9e8bad7fd084282

  • Method: GET

  • Headers:

    • KEY: Authorization

    • VALUE: 123456

As you can observe, we introduced the user address in the endpoint, and we created a Header where we introduced our API Key.

Now, let's see how this looks like when using a GUI and when using a Terminal.

Using a GUI

Let's apply what we learned by using Postman as a GUI to access our API:

As you can see, we are using GET method, we introduced our user at the end of our endpoint, and we created a Header with "Authorization" as KEY, and our API Key as VALUE. We received the response in the Body section.

Using a Terminal

Although this is not a common practice, we can also apply what we learned to access the API via Terminal by using Curl. This would be the command line to be executed:

curl -X GET --header 'Accept: application/json' --header 'Authorization: 123456' 'https://merlin-api-v1.cf/api/merlin/public/balances/token/0x171c53d55b1bcb725f660677d9e8bad7fd084282'

The response of the API would be logged in the terminal itself.

Last updated