> ## Documentation Index
> Fetch the complete documentation index at: https://ormilabs.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Perform Query

> How to perform a query on a REST endpoint to retrieve onchain data

In this guide, we will walk you through the steps to perform a query on a REST endpoint to retrieve onchain data.

## Prerequisites

Before you begin, ensure you have the following:

* An API key
* A REST client (e.g., Postman, curl)

## Steps to Perform a Query

1. **Identify the endpoint URL**: The base URL for the API is `https://data-api.cloud.ormi.dev/somnia`.
2. **Add the endpoint path**: Append the specific endpoint path to the base URL, e.g., `v1/address/{walletAddress}/balance`.
3. **Include query parameters**: Add any necessary query parameters to the URL, e.g., `?param1=value1&param2=value2`.
4. **Set up headers**: Include the required headers, such as `Authorization` with your API key.
5. **Make the request**: Use your REST client to send a GET request to the constructed URL.

You may find all our API definitions in the [API Reference](/dedicated-env/somnia/data-apis/api-reference/balances/get-erc-20-balance) or access them below:

<Card title="Access Now" img="https://mintcdn.com/ormilabs/nEcq6BS5X_MOATC1/images/chain-logos/somnia-icon-padding.svg?fit=max&auto=format&n=nEcq6BS5X_MOATC1&q=85&s=f339b431381fad794ac2327ab26020ce" href="/docs/dedicated-env/somnia/data-apis/api-reference/balances/get-erc-20-balance" width="328" height="119" data-path="images/chain-logos/somnia-icon-padding.svg">
  Access Data APIs Now for Free
</Card>

***

## Example - Performing a Query to Fetch ERC20 Transfers

Here is an example of a query to retrieve the token balance of a wallet address on the Ethereum mainnet:

1. Identify the endpoint URL by navigating to the [API Reference](/dedicated-env/somnia/data-apis/api-reference/balances/get-erc-20-balance).

   <Frame>
     <img src="https://mintcdn.com/ormilabs/QF_fmnEzWAEcNv02/images/0xAPI/erc20-transfers.png?fit=max&auto=format&n=QF_fmnEzWAEcNv02&q=85&s=9db5da0773febafdb17bbf8ba6c67e68" alt="Retrieve ERC20 transfers" width="2665" height="2255" data-path="images/0xAPI/erc20-transfers.png" />

     <figcaption>Retrieve ERC20 transfers</figcaption>
   </Frame>

2. Copy and paste the required endpoint path and query parameters into the editor, then click "Send" to make the request.

   <Frame>
     <img src="https://mintcdn.com/ormilabs/QF_fmnEzWAEcNv02/images/0xAPI/perform-query.png?fit=max&auto=format&n=QF_fmnEzWAEcNv02&q=85&s=2d4a69182934e441a80bc9dda15aa18f" alt="Perform Query" width="2012" height="2118" data-path="images/0xAPI/perform-query.png" />

     <figcaption>Perform query</figcaption>
   </Frame>

3. You may use any third-party tool such as curl or Postman to directly query the endpoint.

   <Frame>
     <img src="https://mintcdn.com/ormilabs/QF_fmnEzWAEcNv02/images/0xAPI/curl.png?fit=max&auto=format&n=QF_fmnEzWAEcNv02&q=85&s=95c934286705686378f668f76729fb57" alt="Using Curl" width="1402" height="292" data-path="images/0xAPI/curl.png" />

     <figcaption>Using curl for query</figcaption>
   </Frame>

4. The API Reference page also provides handy code snippets for various programming languages to help you get started.

   <Frame>
     <img src="https://mintcdn.com/ormilabs/QF_fmnEzWAEcNv02/images/0xAPI/languages.png?fit=max&auto=format&n=QF_fmnEzWAEcNv02&q=85&s=bd78192435a35ae9f2f98c4a7f591d58" alt="Using Other Programming Languages" width="1408" height="1106" data-path="images/0xAPI/languages.png" />

     <figcaption>Using other programming languages</figcaption>
   </Frame>
