Skip to content

Latest commit

 

History

History
131 lines (104 loc) · 4.66 KB

README.md

File metadata and controls

131 lines (104 loc) · 4.66 KB

Substreams Atomic API

.github/workflows/bun-test.yml License

REST API

Pathname
Description
GET /health Health check
GET /chains Get available chains
GET /sales Get sales by chain, collection_name, sale_id, timestamp, block_number, template_id, listing_price_amount, listing_price_symcode, trx_id or contains_asset_id
GET /sales/aggregate Get aggregate of sales for given time range filtered by chain,collection_name or listing_price_symcode
GET /metrics Prometheus metrics
GET /openapi OpenAPI v3 JSON

Supported aggregate functions : count, sum, min, max, avg, median

Supported aggregate columns: sale_id, total_asset_ids, listing_price_amount

Requirements

Additionnaly to pull data directly from a substream:

Quickstart

$ bun install
$ bun dev

Linux Only

$ wget https://github.com/pinax-network/substreams-atomic-api/releases/download/v0.2.0/substreams-atomic-api
$ chmod +x ./substreams-atomic-api

.env Environment variables

# API Server
PORT=8080
HOSTNAME=localhost

# Clickhouse Database
HOST=http://127.0.0.1:8123
DATABASE=default
USERNAME=default
PASSWORD=
MAX_LIMIT=500

# Logging
VERBOSE=true

Required database structure

substreams-sink-clickhouse auto generates some tables (see Database structure section). For this API to work, you will also need to provide following schemas to substreams-sink-clickhouse (see Schema initialization section):

  • substreams-atomicmarket-sales schema
  • substreams-atomicassets schema

The minimum required added tables to the database structure are:

erDiagram
    Sales }|--|{ Assets : " "

    Sales {
        sale_id     UInt64
        trx_id      String
        seller      String
        asset_ids   Array(UInt64)
        offer_id    Int64
        listing_price_amount  Int64
        listing_price_precision  UInt8
        listing_price_symcode    String
        settlement_symbol_precision   UInt8
        settlement_symbol_code String
        maker_marketplace String
        collection_name String
        collection_fee  Float64

    }

    Assets {
        asset_id     UInt64
        scope        String
        collection_name String
        template_id  Int32

    }
Loading

Help

$ ./substreams-atomic-api -h
Usage: substreams-atomic-api [options]

Atomic API

Options:
  -V, --version            output the version number
  -p, --port <number>      HTTP port on which to attach the API (default: "8080", env: PORT)
  -v, --verbose <boolean>  Enable verbose logging (choices: "true", "false", default: false, env: VERBOSE)
  --hostname <string>      Server listen on HTTP hostname (default: "localhost", env: HOSTNAME)
  --host <string>          Database HTTP hostname (default: "http://localhost:8123", env: HOST)
  --username <string>      Database user (default: "default", env: USERNAME)
  --password <string>      Password associated with the specified username (default: "", env: PASSWORD)
  --database <string>      The database to use inside ClickHouse (default: "default", env: DATABASE)
  --max-limit <number>     Maximum LIMIT queries (default: 10000, env: MAX_LIMIT)
  -h, --help               display help for command

Docker environment

Pull from GitHub Container registry

docker pull ghcr.io/pinax-network/substreams-atomic-api:latest

Build from source

docker build -t substreams-atomic-api .

Run with .env file

docker run -it --rm --env-file .env ghcr.io/pinax-network/substreams-atomic-api