# Stellar API Quickstart

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

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

*To use the Stellar API, you need an Alchemy account. [Create a free account](https://dashboard.alchemy.com/signup) to get started.*

## What is Stellar?

Stellar is an open-source, decentralized blockchain network designed for fast, low-cost financial transactions and asset tokenization. It features Soroban, a smart contract platform built on Rust and WebAssembly (WASM), offering 5-second finality and a developer-friendly environment for building decentralized applications.

## What is the Stellar API?

The Stellar API gives you access to Stellar RPC over JSON-RPC 2.0 through Alchemy. The transport is familiar if you have used JSON-RPC before, but the methods and response shapes are Stellar-specific rather than Ethereum-specific.

## Get started

### 1. Create a project directory

Create a new directory for your example script:

<CodeGroup>
  ```shell shell
  mkdir stellar-api-quickstart
  cd stellar-api-quickstart
  ```
</CodeGroup>

### 2. Make your first request

Create an `index.js` file in your project directory and paste the following code. This example uses Node.js's built-in `fetch` API.

<CodeGroup>
  ```javascript index.js
  const apiKey = "your-api-key";
  const url = `https://stellar-mainnet.g.alchemy.com/v2/${apiKey}`;

  const payload = {
    jsonrpc: "2.0",
    id: 1,
    method: "getNetwork",
  };

  fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  })
    .then((response) => response.json())
    .then((data) => {
      console.log(JSON.stringify(data, null, 2));
    })
    .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).

This request calls `getNetwork`, a Stellar RPC method that returns information such as the network passphrase and protocol version.

### 3. Run your script

Run your script to make a request to the Stellar network:

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

You should see a JSON-RPC response with a `result` object containing network details such as `passphrase` and `protocolVersion`.

## Next steps

You've made your first request to the Stellar network. Next, you can:

* Call `getLatestLedger` to inspect the latest ledger metadata.
* Call `getLedgerEntries` to read live ledger state such as contract data and other ledger entries.
* Use the official `stellar-sdk` package when you're ready to build a larger JavaScript application against Stellar RPC and Horizon.

When you move beyond zero-parameter methods like `getNetwork`, keep in mind that Stellar RPC methods use named parameters for requests instead of Ethereum-style positional arrays.