# Starknet API Quickstart

> How to get started building on Starknet and using the JSON-RPC API

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

*To use the Starknet API you'll need to [create a free Alchemy account](https://dashboard.alchemy.com/signup) first!*

## What is the Starknet API?

Starknet is a decentralized Validity-Rollup (also known as ZK-Rollup) that operates as a Layer 2 network over Ethereum, enabling apps to achieve massive scale without compromising Ethereum's composability and security.

The Starknet API is a collection of JSON-RPC methods that let you interact with the Starknet network. You can access up-to-date network data and submit transactions through the provided endpoints.

## Getting started

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

Choose a package manager to manage your project's dependencies. The two most popular options for Node.js are `npm` and `yarn`.

#### npm

Install Node.js and `npm` for your operating system by following the [npm documentation](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).

#### yarn

Install `yarn` by following the [yarn installation guide](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable).

### 2. Set up your project (npm or yarn)

Set up a Node.js project. Open your terminal and run the following commands:

<CodeGroup>
  ```text npm
  mkdir alchemy-starknet-api
  cd alchemy-starknet-api
  npm init --yes
  ```

  ```text yarn
  mkdir alchemy-starknet-api
  cd alchemy-starknet-api
  yarn init --yes
  ```
</CodeGroup>

This will create a new directory called `alchemy-starknet-api` and initialize a new Node.js project in it.

### 3. Make your first request

You need an HTTP client to make requests to the Starknet API. Install Axios with the command below:

<CodeGroup>
  ```Text npm
  npm install axios
  ```

  ```Text yarn
  yarn add axios
  ```
</CodeGroup>

Create a file called `index.js` in your project directory and add the following code to request the `starknet_blockNumber` JSON-RPC method:

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

  const apiKey = 'YOUR_API_KEY'; // Replace with your Alchemy API key
  const url = `https://starknet-mainnet.g.alchemy.com/v2/${apiKey}`;

  const payload = {
    jsonrpc: '2.0',
    id: 1,
    method: 'starknet_blockNumber',
    params: []
  };

  axios.post(url, payload)
    .then(response => {
      console.log('Block Number:', response.data.result);
    })
    .catch(error => {
      console.error(error);
    });
  ```
</CodeGroup>

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

### 4. Run the script

Run the following command in your terminal:

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

You should see the current block number on Starknet printed to the console:

<CodeGroup>
  ```shell shell
  Block Number: 42390
  ```
</CodeGroup>

## Next steps

You've made your first request to the Starknet API using Alchemy. From here, you can explore the [JSON-RPC methods available on Starknet](/docs/reference/starknet-getclasshashat) and start building your decentralized applications.