# Tron API Quickstart

> Get started building on Tron and using the HTTP JSON API

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

The Tron API enables you to interact with the Tron blockchain via a collection of HTTP JSON endpoints. You can query block and transaction data, interact with smart contracts, manage assets, participate in governance, and more.

Tron leverages a high-throughput, low-latency architecture optimized for dApp performance and decentralized finance. This quickstart walks you through setting up your environment and making your first API call to the Tron network.

***

## What is the Tron API?

The Tron API lets you perform queries and send transactions to the Tron blockchain through an HTTP JSON interface. The API supports comprehensive interactions with Tron's account model, token standards (TRC-10, TRC-20), smart contracts, and node-level information.

Alchemy's Tron API offers consistent and performant access to:
* Fetching account and token balances
* Querying blocks, transactions, contracts, and resources
* Sending and simulating transactions
* Managing tokens and interacting with smart contracts

***

## Getting started

### 1. Choose a package manager (npm or yarn)

Select a package manager to manage your project's dependencies. The choice between `npm` and `yarn` depends on your preference or project requirements.

| npm                                                                                                                       | yarn                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| Begin with `npm` by following the [npm documentation](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm). | For `yarn`, refer to [yarn's installation guide](https://classic.yarnpkg.com/lang/en/docs/install). |

### 2. Set up your project

Open your terminal and run the following commands:

<CodeGroup>
  ```text npm
  mkdir tron-api-quickstart
  cd tron-api-quickstart
  npm init --yes
  ```

  ```text yarn
  mkdir tron-api-quickstart
  cd tron-api-quickstart
  yarn init --yes
  ```
</CodeGroup>

This creates a new directory named `tron-api-quickstart` and initializes a Node.js project within it.

### 3. Make your first request

Install Axios, a popular HTTP client, to make API requests:

<CodeGroup>
  ```bash bash
  npm install axios
  # Or with yarn
  # yarn add axios
  ```
</CodeGroup>

Create an `index.js` file in your project directory and paste the following code:

<CodeGroup>
  ```javascript javascript
  const axios = require('axios');

  const url = `https://tron-mainnet.g.alchemy.com/v2/${yourAPIKey}/wallet/getnowblock`;

  axios.get(url)
  .then(response => {
  const blockNumber = response.data.block_header.raw_data.number;
  console.log('Latest block number:', blockNumber);
  })
  .catch(error => {
  console.error('Error fetching latest block:', error);
  });

  ```
</CodeGroup>

Replace `yourAPIKey` with your actual Alchemy API key from the [Alchemy Dashboard](https://dashboard.alchemy.com/signup).

### 4. Run your script

Run the following command:

<CodeGroup>
  ```bash bash
  node index.js
  ```
</CodeGroup>

You should see the latest block number from the Tron blockchain printed in your console:

```shell
Latest block number: 53762589
```

## Next steps

You've made your first request to the Tron API. You can now explore the [HTTP JSON endpoints available on the Tron API](/docs/reference/tron-api-endpoints) and start building your dApps.