NAV
shell python

Introduction

With the growing number of different blockchains and the constant emergence of new decentralised trading protocols, several challenges arise for users and developers in the DeFi space:

These issues make it harder for users to navigate the fragmented DeFi landscape and optimize their trading strategies.

Polia aims to solve these problems by providing a comprehensive, real-time overview of what's happening in the world of DeFi and SOON Centralised Exchanges. By serving as a high-performance, real-time data aggregator, Polia offers users a unified view of the entire DeFi ecosystem, making it easier to track liquidity, compare prices, and identify profitable opportunities across various platforms and networks.

Here are some of the common use cases for clients who use Polia API:

We have language bindings in Shell and Python. You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

General Info

The following base endpoints are available:

Credits

All Plans (with the exception of Enterprise) include a monthly limit to the number of API calls that can be made. The usage is tracked as API "call credits" which are incremented 1:1 against successful API call, or Websocket Server message send.

Stage

Authentication

All HTTP and Websocket requests made against the Polia API must be validated with an API Key. If you don't have an API Key yet visit The Developer Portal to generate one. API Keys Image

You may use any server side programming language that can make HTTP requests and/or open bi-directional websocket connections to target the Polia API. All requests should target domain https://api.polia.io for HTTPS, and wss://stream.polia.io:9443 for Websocket connections.

REST API

To authenticate your requests to the REST API, include the API Key in the Authorization header using the Api-Key prefix.

Example

curl -H "Authorization: Api-Key <API_KEY>" https://api.polia.io/api/v1/networks/ethereum

Websocket API

To authenticate your WebSocket connection, pass the API Key in the Authorization header using the Api-Key prefix, similar to the REST API.

Example

websocat wss://stream.polia.io:9443/ws/v1/defi -H "Authorization: Api-Key <API_KEY>"

Endpoint Overview

REST API

Endpoint Description
/api/v1/networks/* Access network-related data and operations.
/api/v1/exchanges/* Access exchange-related data and operations.
/api/v1/tokens/* Access token-related data and operations.
/api/v1/pools/* Access pool-related data and operations.
/api/v1/notifications/* SOON Manage notifications and access notification-related data.

WebSocket API

Endpoint Description
/ws/v1/core Provides real-time information around blocks/txs/logs.
/ws/v1/defi Provides real-time DeFi-related data and updates for all supported chains.
/ws/v1/cefi SOON Provides real-time CeFi-related data and updates for all supported exchanges.
/ws/v1/nft SOON WebSocket endpoint for real-time NFT-related data and updates.

Objects

Network

Represents a blockchain network.

Field Type Description
id string The unique identifier of the network.
name string The name of the network.
is_active boolean Indicates if the network is actively used by Polia.

Example

{
  "id": "zksync",
  "name": "ZkSync",
  "is_active": true
}

Exchange

Represents an exchange.

Field Type Description
id string The unique identifier of the exchange.
network string The ID of the network the exchange operates on.
name string The name of the exchange.
type enum The type of exchange. Possible values are:
- dex: Decentralized exchange
- cex: Centralized exchange

Example

{
  "id": "syncswap-v2-zksync",
  "network": "zksync",
  "name": "SyncSwap V2",
  "type": "dex"
}

Token

Represents a token on a blockchain network.

Field Type Description
id string The unique identifier of the token.
symbol string The symbol of the token.
name string The name of the token.
platforms object The platforms (networks) where the token is available, with the corresponding token addresses and decimal places.
platforms.<network> object An object containing the token information on the specified network. The field name is the ID of the network.
platforms.<network>.address string The token address on the specified network.
platforms.<network>.decimal integer The number of decimal places used by the token on the specified network.

Example

{
  "id": "0x",
  "symbol": "zrx",
  "name": "0x Protocol",
  "platforms": {
    "ethereum": {
      "address": "0xe41d2489571d322189246dafa5ebde1f4699f498",
      "decimal": 18
    },
    "avalanche": {
      "address": "0x596fa47043f99a4e0f122243b841e55375cde0d2",
      "decimal": 18
    },
    "harmony-shard-0": {
      "address": "0x8143e2a1085939caa9cef6665c2ff32f7bc08435",
      "decimal": 18
    },
    "energi": {
      "address": "0x591c19dc0821704bedaa5bbc6a66fee277d9437e",
      "decimal": 18
    }
  }
}

Pool

Represents a liquidity pool on a DEX.

Field Type Description
id integer The unique identifier of the pool.
network string The ID of the network the pool operates on.
dex string The ID of the DEX the pool belongs to.
token0 string The ID of the first token in the pool.
token1 string The ID of the second token in the pool.
address string The address of the pool contract.
name string The name of the pool.
created_at string The timestamp of when the pool was created (ISO 8601 format).

Example

{
  "id": 6,
  "network": "ethereum",
  "dex": "uniswap_v2",
  "token0": "wrapped-ethw",
  "token1": "tether",
  "address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852",
  "name": "WETH / USDT",
  "created_at": "2021-10-11T01:35:32Z"
}

PoolDetails

Represents the detailed information and metrics of a liquidity pool.

Field Type Description
name string The name of the pool.
address string The address of the pool contract.
created_at string The timestamp of when the pool was created.
dex object An object containing the ID and name of the DEX the pool belongs to.
network object An object containing the ID and name of the network the pool operates on.
token0 object An object containing details of the first token in the pool.
token1 object An object containing details of the second token in the pool.
metrics object An object containing various metrics of the pool.
metrics.block_number string The block number of the latest metrics.
metrics.block_hash string The block hash of the latest metrics.
metrics.tx_index string The transaction index in the block.
metrics.token0_reserve_amount string The reserve amount of the first token in the pool.
metrics.token1_reserve_amount string The reserve amount of the second token in the pool.
metrics.token0_to_token1_exchange_rate string The exchange rate from token0 to token1.
metrics.token1_to_token0_exchange_rate string The exchange rate from token1 to token0.
metrics.token0_to_token1_exchange_rate_raw string The raw exchange rate from token0 to token1.
metrics.token1_to_token0_exchange_rate_raw string The raw exchange rate from token1 to token0.

Example

{
  "name": "KOI / WETH",
  "address": "0x842e64a006da45b154e92310363b4d26ba2db274",
  "created_at": "2024-03-08 15:25:09 UTC",
  "dex": {
    "id": "zkswap-finance",
    "name": "zkSwap"
  },
  "network": {
    "id": "zksync",
    "name": "ZkSync"
  },
  "token0": {
    "id": "weth",
    "address": "0x78b050d981d7f6e019bf6e361d0d1167de6b19da",
    "symbol": "weth",
    "decimal": 18
  },
  "token1": {
    "id": "koi-3",
    "address": "0xa995ad25ce5eb76972ab356168f5e1d9257e4d05",
    "symbol": "koi",
    "decimal": 18
  },
  "metrics": {
    "block_number": "38744847",
    "block_hash": "0x1b8094bd53b891acc80d079b118903bd68ca67559ad56e19392c713ab776dd3c",
    "tx_index": "5",
    "token0_reserve_amount": "8660764132491671162",
    "token1_reserve_amount": "926877859402793771931001",
    "token0_to_token1_exchange_rate": "0.000009344018788054748",
    "token1_to_token0_exchange_rate": "107020.33275857545",
    "token0_to_token1_exchange_rate_raw": "0.000009344018788054748",
    "token1_to_token0_exchange_rate_raw": "107020.33275857545"
  }
}

Block

Represents a block on any of the supported networks.

Field Type Description
network_id string The ID of the network the block belongs to.
number string The block number in hexadecimal format.
hash string The unique identifier (hash) of the block.
parentHash string The hash of the parent block.
mixHash string The mix hash (used in proof-of-work consensus).
sha3Uncles string The SHA3 hash of the uncles data in the block.
receiptsRoot string The root of the receipts trie of the block.
stateRoot string The root of the final state trie of the block.
transactionsRoot string The root of the transactions trie of the block.
miner string The address of the miner who mined the block.
nonce string The nonce used to mine the block.
gasUsed string The total gas used by all transactions in the block.
gasLimit string The maximum gas allowed in the block.
difficulty string The difficulty level of the block.
extraData string Any extra data included in the block.
logsBloom string Bloom filter for the logs of the block.
timestamp string The timestamp of the block in hexadecimal format.

Example

{
  "network_id": "zksync",
  "number": "0x24f22fe",
  "hash": "0xe6c71ccf5592aff8a04cdcc565ce6cdf53b9082f1696f3a567c48548c5720c39",
  "parentHash": "0x74e4942b3cbc2af578f9d70b53fccc2f85757a4f85edf67c04f6924408a164a9",
  "mixHash": null,
  "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "miner": "0x0000000000000000000000000000000000000000",
  "nonce": null,
  "gasUsed": "0x5bca6",
  "gasLimit": "0x4000000000000",
  "difficulty": "0x0",
  "extraData": "0x",
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x668e942a"
}

Networks Endpoints

List Networks

Retrieve a paginated list of networks with filtering and searching capabilities.

GET https://api.polia.io/api/v1/networks

Example Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/networks
import requests

url = "https://api.polia.io/api/v1/networks"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Query Parameters

Parameter Type Description
page integer The page number for pagination.
page_size integer The number of items per page (default: 10, max: 50).
id string Filter by the network ID.
name string Filter by the network name.
is_active boolean Filter by the network's active status.
search string Search by the network name.

Example Response

{
  "count": 164,
  "next": "https://api.polia.io/api/v1/networks?page=2",
  "previous": null,
  "results": [
    {
      "id": "ethereum",
      "name": "Ethereum",
      "is_active": true
    },
    ...
  ]
}

Retrieve a Network

Retrieve a single network by its ID.

GET https://api.polia.io/api/v1/networks/{id}

Example Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/networks/{id}
import requests

url = "https://api.polia.io/api/v1/networks/{id}"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Path Parameters

Parameter Type Description
id string The ID of the network to retrieve.

Example Response

{
  "id": "ethereum",
  "name": "Ethereum",
  "is_active": true
}

Exchanges Endpoints

List Exchanges

Retrieve a paginated list of Exchanges with filtering and searching capabilities.

GET https://api.polia.io/api/v1/exchanges

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/exchanges
import requests

url = "https://api.polia.io/api/v1/exchanges"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Query Parameters

Parameter Type Description
page integer The page number for pagination.
page_size integer The number of items per page (default: 25, max: 50).
id string Filter by the DEX ID.
network string Filter by the network ID.
name boolean Filter by the DEX name.
type enum Filter by the type: 'cex'
search string Search by the DEX name.

Example Response

{
  "count": 100,
  "next": "https://api.polia.io/api/v1/exchanges?page=2",
  "previous": null,
  "results": [
    {
      "id": "uniswap",
      "network": "ethereum",
      "name": "Uniswap",
      "type": "dex"
    },
    ...
  ]
}

Retrieve an Exchange

Retrieve a single Exchange by its ID.

GET https://api.polia.io/api/v1/exchanges/{id}

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/exchanges/{id}
import requests

url = "https://api.polia.io/api/v1/exchanges/{id}"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Path Parameters

Parameter Type Description
id string The ID of the exchange to retrieve.

Example Response

{
  "id": "uniswap",
  "network": "ethereum",
  "name": "Uniswap",
  "type": "dex"
}

Tokens Endpoints

List Tokens

Retrieve a paginated list of tokens with filtering capabilities.

GET https://api.polia.io/api/v1/tokens

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/tokens
import requests

url = "https://api.polia.io/api/v1/tokens"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Query Parameters

Parameter Type Description
page integer The page number for pagination.
page_size integer The number of items per page (default: 25, max: 50).
symbol string Filter by the token symbol (case-insensitive).
name string Filter by the token name (case-insensitive).

Example Response

{
  "count": 14663,
  "next": "https://api.polia.io/api/v1/tokens?page=2",
  "previous": null,
  "results": [
    {
      "id": "0-knowledge-network",
      "symbol": "0kn",
      "name": "0 Knowledge Network",
      "platforms": {
        "ethereum": {
          "address": "0x4594cffbfc09bc5e7ecf1c2e1c1e24f0f7d29036",
          "decimal": 18
        }
      }
    },
    {
      "id": "0-mee",
      "symbol": "ome",
      "name": "O-MEE",
      "platforms": {
        "ethereum": {
          "address": "0xbd89b8d708809e7022135313683663911826977e",
          "decimal": 18
        }
      }
    },
    ...
  ]
}

Retrieve a Token

Retrieve a single token by its ID.

GET https://api.polia.io/api/v1/tokens/{id}

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/tokens/{id}
import requests

url = "https://api.polia.io/api/v1/tokens/{id}"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Path Parameters

Parameter Type Description
id string The ID of the token to retrieve.

Example Response

{
  "id": "0chain",
  "symbol": "zcn",
  "name": "Zus",
  "platforms": {
    "ethereum": {
      "address": "0xb9ef770b6a5e12e45983c5d80545258aa38f3b78",
      "decimal": 10
    },
    "polygon-pos": {
      "address": "0x8bb30e0e67b11b978a5040144c410e1ccddcba30",
      "decimal": 10
    }
  }
}

Pools Endpoints

List Pools

Retrieve a paginated list of pools with filtering and searching capabilities.

GET https://api.polia.io/api/v1/pools

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/pools
import requests

url = "https://api.polia.io/api/v1/pools"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Query Parameters

Parameter Type Description
page integer The page number for pagination.
page_size integer The number of items per page (default: 25, max: 50).
network string Filter by the network ID.
exchange string Filter by the Exchange ID.
token0 boolean Filter by the token0 ID.
token1 string Filter by the token1 ID.
address integer Filter by the pool address.
search integer Search by the pool name or address.

Example Response

{
  "count": 51789,
  "next": "https://api.polia.io/api/v1/pools?page=2",
  "previous": null,
  "results": [
    ...
    {
      "id": 2,
      "network": "ethereum",
      "dex": "uniswap_v2",
      "token0": "trog",
      "token1": "wrapped-ethw",
      "address": "0xe3cc21af229934034b320502fa55cfa1ab7b1493",
      "name": "TROG / WETH",
      "created_at": "2024-06-01T03:52:23Z"
    },
    ...
  ]
}

Retrieve a Pool

Retrieve a single pool by its ID.

GET https://api.polia.io/api/v1/pools/{id}

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/pools/{id}
import requests

url = "https://api.polia.io/api/v1/pools/{id}"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Path Parameters

Parameter Type Description
id string The ID of the pool to retrieve.

Example Response

{
  "id": 2,
  "network": "ethereum",
  "dex": "uniswap_v2",
  "token0": "trog",
  "token1": "wrapped-ethw",
  "address": "0xe3cc21af229934034b320502fa55cfa1ab7b1493",
  "name": "TROG / WETH",
  "created_at": "2024-06-01T03:52:23Z"
}

List Pools Metrics

Retrieve a paginated list of pools metrics with filtering and searching capabilities.

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/pools/metrics
import requests

url = "https://api.polia.io/api/v1/pools/metrics"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Query Parameters

Parameter Type Description
page integer The page number for pagination.
page_size integer The number of items per page (default: 25, max: 50).
network string Filter by the network ID.
exchange string Filter by the Exchange ID.
token0 boolean Filter by the token0 ID.
token1 string Filter by the token1 ID.
address integer Filter by the pool address.
search integer Search by the pool name or address.

Example Response

{
  "count": 51610,
  "next": "https://api.polia.io/api/v1/pools/metrics?page=2",
  "previous": null,
  "results": [
    {
      "id": 126621,
      "network": "zksync",
      "dex": "zkswap-finance",
      "token0": "weth",
      "token1": "mav",
      "address": "0xbe5f5c11c832451e428d3bb603cc52650c008421",
      "name": "MAV / WETH",
      "created_at": "2023-11-09T04:02:28Z",
      "metrics": {
        "token0_reserve_amount": "7709289482938884275",
        "token1_reserve_amount": "122644947434555951118037",
        "token0_to_token1_exchange_rate": "0.00006285859828879298",
        "token1_to_token0_exchange_rate": "15908.722549072325",
        "token0_to_token1_exchange_rate_raw": "0.00006285859828879298",
        "token1_to_token0_exchange_rate_raw": "15908.722549072325",
        "updated_at": "2024-07-23T00:50:54.669900Z"
      }
    }
    ...
  ]
}

Retrieve Pool Metrics

Retrieve a single pool metrics by its pool ID.

GET https://api.polia.io/api/v1/pools/metrics/{pool_id}

Request

curl -H "Authorization: Api-Key <API_KEY>" \
 https://api.polia.io/api/v1/pools/metrics/126617
import requests

url = "https://api.polia.io/api/v1/pools/metrics/126617"
headers = {"Authorization": "Api-Key <API_KEY>"}

response = requests.get(url, headers=headers)
print(response.json())

Path Parameters

Parameter Type Description
pool_id string The ID of the pool to retrieve metrics for.

Example Response

{
  "id": 126617,
  "network": "zksync",
  "dex": "zkswap-finance",
  "token0": "usdc",
  "token1": "weth",
  "address": "0x7642e38867860d4512fcce1116e2fb539c5cdd21",
  "name": "USDC / WETH",
  "created_at": "2023-07-04T03:53:57Z",
  "metrics": {
    "token0_reserve_amount": "1729961686593",
    "token1_reserve_amount": "499820177300636117961",
    "token0_to_token1_exchange_rate": "0.0000000000000000000034611681663912655",
    "token1_to_token0_exchange_rate": "288919795839517070000",
    "token0_to_token1_exchange_rate_raw": "0.0000000034611681663912656",
    "token1_to_token0_exchange_rate_raw": "288919795.83951706",
    "updated_at": "2024-07-23T00:47:22.284776Z"
  }
}

WebSocket API

The WebSocket endpoints follow a specific format based on the desired data:

Type Endpoint URL Description
DEFI wss://stream.polia.io:9443/ws/v1/defi Provides real-time data for tokens across different decentralised exchanges and networks
Core wss://stream.polia.io:9443/ws/v1/block Provides real-time data for core blockchain functionality - block production, SOON txs, SOON mempool txs, SOON raw logs.
CEFI (soon) wss://stream.polia.io:9443/ws/v1/cefi Provides real-time data for token pairs across different centralised exchanges
NFT (soon) wss://stream.polia.io:9443/ws/v1/nft SOON NFTs

DEFI

Provides real-time metrics from DEX pools. Supported active networks can be found at networks.

wss://stream.polia.io:9443/ws/v1/defi

Parameters

After opening a bi-directional communication with the websocket server, you can specify the desired networks and DEXes using the method, networks and dex parameters:

Parameter Type Description
method enum Specifies the action to take. Possible values are: subscribe or unsubscribe.
networks string A comma-separated list of network IDs you want to receive data for. If omitted, data for all supported networks will be pushed. See networks.
dex string A comma-separated list of DEX IDs you want to receive data for. If omitted, data for all supported DEXes will be pushed. See exchanges.

By default, after opening a websocket connection - networks and dexes will be treated with their default values, meaning a stream of Defi market data for all supported networks/dexes will start.

Request

websocat wss://stream.polia.io:9443/ws/v1/defi -H "Authorization: Api-Key <API_KEY>" \
<<< '{"method":"subscribe","networks":"ethereum,zksync","dex":"uniswap_v2,uniswap_v3,spacefi_zksync"}'
import asyncio
import websockets
import json

async def subscribe():
    url = "wss://stream.polia.io:9443/ws/v1/defi"
    api_key = "<API_KEY>"

    headers = {
        "Authorization": f"Api-Key {api_key}"
    }

    subscription_message = {
        "method": "subscribe",
        "networks": "ethereum,zksync",
        "dex": "uniswap_v2,uniswap_v3,spacefi_zksync"
    }

    async with websockets.connect(url, extra_headers=headers) as websocket:
        await websocket.send(json.dumps(subscription_message))
        print(f"> Sent: {subscription_message}")

        while True:
            response = await websocket.recv()
            print(f"< Received: {response}")

asyncio.run(subscribe())

Response

{
  "name": "FTX Token / WETH",
  "address": "0x7825de5586e4d2fd04459091bbe783fa243e1bf3",
  "created_at": "2021-10-11 01:23:56 UTC",
  "dex": {
    "id": "sushiswap",
    "name": "SushiSwap"
  },
  "network": {
    "id": "ethereum",
    "name": "Ethereum"
  },
  "token0": {
    "id": "ftx-token",
    "address": "0xda79dcf81c948dfb85cbda738bc898195a2ba861",
    "symbol": "ftt",
    "decimal": 18
  },
  "token1": {
    "id": "wrapped-ethw",
    "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "symbol": "wethw",
    "decimal": 18
  },
  "metrics": {
    "block_number": "20276749",
    "block_hash": "0xf69e9da27fc1f11aaf533ef9db223b068752618c089f910502c3b9438c667861",
    "tx_index": "33",
    "token0_reserve_amount": "151995905638178712886880",
    "token1_reserve_amount": "59730007126735246536",
    "token0_to_token1_exchange_rate": "2544.716013773002",
    "token1_to_token0_exchange_rate": "0.00039297115850554933",
    "token0_to_token1_exchange_rate_raw": "2544.716013773002",
    "token1_to_token0_exchange_rate_raw": "0.00039297115850554933"
  }
}

Core

The endpoint provides real-time data around core blockchain functionality - block production, SOON txs, SOON mempool txs, SOON raw logs

wss://stream.polia.io:9443/ws/v1/core

Parameters

After opening a bi-directional communication with the websocket server, you can specify the desired networks and functionality kind using the method, networks and kind parameters:

Parameter Type Description
method enum Specifies the action to take. Possible values are: subscribe or unsubscribe.
networks string A comma-separated list of network IDs you want to receive data for. If omitted, data for all supported networks will be pushed. See networks.
kind enum The type of core functionality. Possible values are: blocks, txs, mempool_txs, logs. Currently only supporting blocks. Defaults to blocks.

By default, after opening a websocket connection - networks and kind will be treated with their default values, meaning a stream of Core blockchain data for all supported networks will start.

Request

websocat wss://stream.polia.io:9443/ws/v1/defi -H "Authorization: Api-Key <API_KEY>" \
  <<< '{"method":"subscribe","networks":"ethereum,zksync","kind":"blocks"}'
import asyncio
import websockets
import json

async def subscribe():
    url = "wss://stream.polia.io:9443/ws/v1/defi"
    api_key = "<API_KEY>"

    headers = {
        "Authorization": f"Api-Key {api_key}"
    }

    subscription_message = {
        "method": "subscribe",
        "networks": "ethereum,zksync",
        "kind": "blocks"
    }

    async with websockets.connect(url, extra_headers=headers) as websocket:
        await websocket.send(json.dumps(subscription_message))
        print(f"> Sent: {subscription_message}")

        while True:
            response = await websocket.recv()
            print(f"< Received: {response}")

asyncio.run(subscribe())

Response

{
  "network": "zksync",
  "number": "0x24f2f2f",
  "hash": "0xb9f695c1de0317b14c9970ec4579f9d0d33506741db10d2647700ebf30e20bde",
  "parentHash": "0xf4ed0aad41f30f864a674d33e746dfb61453e4dd8e43163f87654fcb931a7799",
  "mixHash": null,
  "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
  "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "miner": "0x0000000000000000000000000000000000000000",
  "nonce": null,
  "gasUsed": "0x10f60a",
  "gasLimit": "0x4000000000000",
  "difficulty": "0x0",
  "extraData": "0x",
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x668ea09e"
}

CEFI (SOON)

NFT (SOON)

Notifications

Create a Notification

Retrieve a Notification

List Notifications

Update a Notification

Delete a Notification

Errors

The Polia API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- Forbiden.
404 Not Found -- The specified resource could not be found.
406 Not Acceptable -- You requested a format that isn't json.
429 Too Many Requests -- Too many requests! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.