# Blockchain API

**What is Blockchain API?**

The Blockops Blockchain API provides developers with instant, high-performance Remote Procedure Call (RPC) endpoints via HTTP and WebSockets (WSS). It acts as the critical communication bridge between your decentralized application (dApp) and the blockchain, handling node operations and syncing behind the scenes.

**The Problem It Solves**

Running your own blockchain nodes requires massive storage, constant updates, and 24/7 monitoring. The Blockchain API eliminates this infrastructure burden. You simply use our API endpoint to get reliable read/write access to the network, allowing you to focus entirely on building your application.

**Dashboard**

The dashboard gives access to all the available features on Blockops and provides a side navigation for easy navigation.

To get started, visit [blockops.network](https://www.blockops.network) and navigate to the Blockchain API page on the dashboard. This allows you to connect to a network which generates your API keys.

<div align="left"><figure><img src="/files/KWVHZG8J83VUaiMi0O5y" alt="" width="344"><figcaption></figcaption></figure> <figure><img src="/files/mm77TEjVXPw4mqpQVq9r" alt=""><figcaption></figcaption></figure></div>

### Supported Networks

Blockops' API Service supports:

* [Ethereum](/networks/supported-networks/ethereum.md)
* [Polkadot](/networks/supported-networks/polkadot.md)
* Gnosis
* Cronos
* Polygon
* Lisk
* Assethub
* Arbitrum
* Zora
* Celo
* BSC
* Optimism
* Soneium
* Starknet
* Unichain
* Solana
* Fantom
* Sonic
* Zksync
* Blast
* Linea
* Berachain
* Mantle
* Scroll
* Hyperbridge
* Avalanche
* Monad and
* [Base](/networks/supported-networks/base.md), all easily accessible from the dashboard.

**Accessing Endpoints**

1. **Select Project:** Choose your project from the top dropdown (e.g., "Default Project").
2. **Select Network:** Use the network selector to switch between chains (e.g., **Lisk** vs **Ethereum**) and environments (**Mainnet** vs **Testnet**).

<figure><img src="/files/LrKNvhAqGQvb10DjmPbb" alt="Network Selector" width="600"><figcaption></figcaption></figure>

**RPC Endpoints**

Once a network is selected, your unique **HTTP** and **WSS** (WebSocket) endpoints are automatically generated.

* **HTTP Endpoint:** Use this for standard JSON-RPC requests (e.g., fetching block data).
* **WSS Endpoint:** Use this for real-time subscriptions and events.

You can view your full **API Key** on the right side of the dashboard.

<figure><img src="/files/ifLEVJVE7oHNDia9R8jk" alt="RPC Endpoints" width="600"><figcaption></figcaption></figure>

**Integration Helper**

The dashboard includes a built-in integration helper. Select a method (e.g., `eth_getBlockByNumber`) and a language (e.g., `bash`, `js`, `python`) to generate a ready-to-use code snippet tailored to your API key.

<figure><img src="/files/CdoXBRyt6nYFRHXFL7QN" alt="Integration Helper" width="600"><figcaption></figcaption></figure>

### Common EVM RPC Methods

Once your endpoints are generated, you can interact with the network using standard JSON-RPC methods. Here is a quick reference for the most common methods you will use when building your project:

| Category                 | Method                      | Description                                                                                |
| ------------------------ | --------------------------- | ------------------------------------------------------------------------------------------ |
| **Account Info**         | `eth_getBalance`            | Returns the native token balance of an address (e.g., LSK or ETH).                         |
|                          | `eth_getTransactionCount`   | Returns the nonce of an account (essential for sending transactions).                      |
| **Chain State**          | `eth_chainId`               | Returns the specific Chain ID (e.g., Lisk Mainnet is 1135).                                |
|                          | `eth_gasPrice`              | Returns the current price of gas on the network in wei.                                    |
| **Transaction Info**     | `eth_getTransactionByHash`  | Gets the full details of a transaction using its unique hash.                              |
|                          | `eth_getTransactionReceipt` | Gets the receipt (status, logs, gas used) of a transaction.                                |
| **Contract Interaction** | `eth_call`                  | Executes a "read-only" call to a smart contract (costs zero gas).                          |
|                          | `eth_estimateGas`           | Estimates how much gas a transaction will cost before you send it.                         |
| **Events & Logs**        | `eth_getLogs`               | Returns an array of all logs matching a specific filter (highly useful for indexing data). |

### Practical Examples

**Connect via a command line**

You can connect to the network using websocket or HTTP with your API key in two ways:

* Adding the API key as a query string `?api_key=${APIKEY}`
* Or the request header `-H 'authorization: APIKEY ${APIKEY}'`

**cURL**

For example, the following cURL command can be used to get the header and body of a block.

`curl -H "Content-Type: application/json" -H "authorization: APIKEY xxxx" -d '{"id":1, "jsonrpc":"2.0", "method": "eth_getBlockByNumber", "params": ["latest", true]}' https://lisk.rpc.blockops.network/rpc`

**What Success Looks Like:** Here is the successful JSON response you will receive back, proving your app is communicating with the chain:

`{"jsonrpc":"2.0","result":{"hash":"0x381dd358f0b1e328e861822b2a51a72e8dc064803a5c7ccc96277da3b16d7667","number":"0xe07a1d", "timestamp": "0x65123abc"},"id":1}`

**wscat**

If you want to send data requests with WebSockets, you can use several libraries or wscat. You can install and use wscat as follows:

* Download wscat from <https://www.npmjs.com/package/wscat>
* Install wscat by running the following command: `npm install -g wscat`

You can connect to the network with wscat using two options by adding the API key as a query string:

`wscat -c 'wss://lisk.rpc.blockops.network/ws' --header 'authorization: APIKEY xxxx'`

Or the request header:

`wscat -c 'wss://lisk.rpc.blockops.network/ws?api_key=**********************'`

After executing the command, the terminal will display a message indicating that the connection has been enabled successfully:

`Connected (press CTRL+C to quit)`

Then, you can send the following request into the open terminal:

`> {"id":1, "jsonrpc":"2.0", "method": "eth_blockNumber"}`

<figure><img src="/files/nYhVbar8fJKXklHlkb5A" alt=""><figcaption><p>Response from network node</p></figcaption></figure>

### Connect via Polkadot JS UI

Connect via Polkadot JS API

If you are building on Polkadot or any Substrate-based chain, you can connect your application using the official `@polkadot/api` library.

First, install the library in your project repository:

```bash
npm install @polkadot/api
```

Then, instantiate the `WsProvider` using your Blockops WSS endpoint. The most reliable way to authenticate is by appending your API key as a query parameter in the URL.

```javascript
import { ApiPromise, WsProvider } from "@polkadot/api";

async function connectToBlockops() {
  const WSS_URL = "wss://polkadot.rpc.blockops.network/ws?api_key=YOUR_API_KEY";

  const wsProvider = new WsProvider(WSS_URL);

  try {
    const api = await ApiPromise.create({ provider: wsProvider });

    const chain = await api.rpc.system.chain();
    const lastHeader = await api.rpc.chain.getHeader();

    console.log(`Successfully connected to ${chain}!`);
    console.log(`Latest Block Number: ${lastHeader.number.toHuman()}`);
  } catch (error) {
    console.error("Connection failed:", error);
  }
}

connectToBlockops();
```

### Rotate API Key

Rotating API keys is important when an unauthorized third party has access to your API key. You have the option to reset it by using the Rotate Key button located in the project dashboard.

<figure><img src="/files/W6yTXXXHqIRWZzKDnFkf" alt=""><figcaption></figcaption></figure>

### Blockchain API Rate Limiting

**What is Rate Limiting?** Rate limiting is a mechanism that controls the number of API requests your application can make to the Blockops RPC nodes within a specific time frame (usually measured in Requests Per Second, or RPS).

### API Service Rate Limiting

For detailed information on how request limits are handled, how to manage your RPS (Requests Per Second), and how to upgrade your limits, please refer to our full guide on [Blockops API Rate Limiting](/developer/products/mission-control/appchain-deployment.md#theenhancedapiservice-regenerateapikey).

*(Note: You can monitor your real-time request volume and remaining limits directly from your Project Dashboard.).*

**API Error Codes**

The following error codes are frequently returned by our Blockchain API. However, it's important to note that this list doesn't include errors related to network-specific business logic.

| Code | Message               | Explanation                                                              |
| ---- | --------------------- | ------------------------------------------------------------------------ |
| 401  | Unauthorized Access   | Invalid API key or no API key found in request                           |
| 404  | No route matched      | This indicates the specific page you are trying to visit is non-existent |
| 429  | Too Many Requests     | You have exceeded your request limit.                                    |
| 500  | Internal Server Error | Something went wrong inside our servers. Contact support.                |

**Conclusion**

Blockops Blockchain API is a gateway to accessing your endpoint with ease and securely.

{% hint style="info" %}
[**Follow us on Twitter**](https://twitter.com/blockopsnetwork) **for more information on upcoming protocols and developments.**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blockops.network/developer/products/blockchain-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
