logoDeveloper Hub

Making API Calls

After installing Postman and importing the Avalanche collection, you can choose an API to make the call.

You should also make sure the URL is the correct one for the call. This URL consists of the base URL and the endpoint:

  • The base URL is set by an environment variable called baseURL, and it is by default Avalanche's public API. If you need to make a local API call, simply change the URL to localhost. This can be done by changing the value of the baseURL variable or changing the URL directly on the call tab. Check out the RPC providers to see all public URLs.
  • The API endpoint depends on which API is used. Please check out our APIs to find the proper endpoint.

The last step is to add the needed parameters for the call. For example, if a user wants to fetch data about a certain transaction, the transaction hash is needed. For fetching data about a block, depending on the call used, the block hash or number will be required.

After clicking the Send button, if the call is successfully, the output will be displayed in the Body tab.

Note

Data visualization is available for a number of methods. Learn how to use it with the help of this guide.

Make Call

Examples

C-Chain Public API Call

Fetching data about a C-Chain transaction using eth_getTransactionByHash.

X-Chain Public API Call

Fetching data about an X-Chain block using avm.getBlock.

P-Chain Public API Call

Getting the current P-Chain height using platform.getHeight.

API Call Using Variables

Let's say we want fetch data about this 0x20cb0c03dbbe39e934c7bb04979e3073cc2c93defa30feec41198fde8fabc9b8 C-Chain transaction using both:

  • eth_getTransactionReceipt
  • eth_getTransactionByHash

We can set up an environment variable with the transaction hash as value and use it on both calls.

Note

Find out more about variables here.

Last updated on

On this page

Edit on Github