Skip to content

Releases: pinax-network/substreams-atomic-api

v0.2.2

23 Nov 15:57
Compare
Choose a tag to compare

v0.2.1

23 Nov 15:53
Compare
Choose a tag to compare

Full Changelog: v0.2.0...v0.2.1

  • Removed listing_price_value

  • Added chains for grouping and filtering

  • Added time range querying logic instead of timestamp comparisons

v0.2.0

06 Nov 14:28
Compare
Choose a tag to compare

Full Changelog: v0.1.0...v0.2.0

Substreams Atomic API

.github/workflows/bun-test.yml

REST API

Pathname
Description
GET /health Health check
GET /sales Get sales by collection_name, sale_id, timestamp, block_number, template_id, listing_price_amount, listing_price_symcode, listing_price_value, trx_id or contains_asset_id
GET /sales/aggregate Get aggregate of sales filtered by collection_name, timestamp or block_number
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, listing_price_value

Requirements

Additionnaly to pull data directly from a substream:

Quickstart

$ bun install
$ bun dev

Bun Binary Releases

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

Expected 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 expected added tables to the database structure will then be:

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

    Sales {
        sale_id     UInt64
        trx_id      String
        asset_ids   Array(UInt64)
        listing_price_amount  Int64
        listing_price_precision  UInt8
        listing_price_symcode    String
        listing_price_value      Float64
        collection_name String

    }

    Assets {
        asset_id     UInt64
        scope        String
        collection_name String
        template_id  Int32

    }

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

v0.1.0

18 Oct 09:32
Compare
Choose a tag to compare

First version working with dummy data