swagger.json

Overview

This file is an OpenAPI 3.0 specification document describing the REST API for the [@shapeshiftoss/avalanche-api](/projects/291/68873) version 10.0.0. It defines a comprehensive interface for interacting with an Avalanche-based blockchain coinstack, exposing endpoints to retrieve network and account information, transaction details and history, send transactions, query gas fees and estimates, obtain token metadata, and perform JSON-RPC calls to the underlying node.

The API supports typical blockchain explorer and wallet functionalities targeted at Ethereum Virtual Machine (EVM) compatible chains on Avalanche. It provides strongly typed JSON schemas for request and response payloads, error handling, and supports both single and batch JSON-RPC requests.


Detailed Documentation

Components

The specification defines multiple JSON schemas under [components.schemas](/projects/291/69205) which are reused throughout the API. These schemas represent data models for accounts, transactions, token balances, errors, gas fees, and RPC communication.

Key Schemas


Paths (Endpoints)

1. GET /api/v1/info

2. GET /api/v1/account/{pubkey}

3. GET /api/v1/account/{pubkey}/txs

4. GET /api/v1/tx/{txid}

5. POST /api/v1/send

6. POST /api/v1/jsonrpc

7. GET /api/v1/metadata/token

8. POST /api/v1/gas/estimate

9. GET /api/v1/gas/fees


Implementation Details & Algorithms


Interaction with Other System Parts


Visual Diagram: Component Diagram of Main API Endpoints and Schemas

flowchart TD
    Info["GET /api/v1/info<br/>Returns BaseInfo"]
    Account["GET /api/v1/account/{pubkey}<br/>Returns Account"]
    TxHistory["GET /api/v1/account/{pubkey}/txs<br/>Returns TxHistory"]
    TxDetail["GET /api/v1/tx/{txid}<br/>Returns Tx"]
    SendTx["POST /api/v1/send<br/>SendTxBody -> string(txid)"]
    JsonRpc["POST /api/v1/jsonrpc<br/>RPCRequest -> RPCResponse"]
    TokenMeta["GET /api/v1/metadata/token<br/>Returns TokenMetadata"]
    GasEstimate["POST /api/v1/gas/estimate<br/>EstimateGasBody -> GasEstimate"]
    GasFees["GET /api/v1/gas/fees<br/>Returns GasFees"]

    Info --> BaseInfo[BaseInfo Schema]
    Account --> AccountSchema[Account Schema]
    AccountSchema --> TokenBalanceSchema[TokenBalance Schema]
    TxHistory --> TxHistorySchema[TxHistory Schema]
    TxHistorySchema --> TxSchema[Tx Schema]
    TxSchema --> TokenTransferSchema[TokenTransfer Schema]
    TxSchema --> InternalTxSchema[InternalTx Schema]
    TxDetail --> TxSchema
    SendTx --> SendTxBody[SendTxBody Schema]
    JsonRpc --> RPCRequest[RPCRequest Schema]
    JsonRpc --> RPCResponse[RPCResponse Schema]
    TokenMeta --> TokenMetadataSchema[TokenMetadata Schema]
    GasEstimate --> EstimateGasBody[EstimateGasBody Schema]
    GasEstimate --> GasEstimateSchema[GasEstimate Schema]
    GasFees --> GasFeesSchema[GasFees Schema]

    classDef endpoint fill:#f9f,stroke:#333,stroke-width:1px;
    class Info,Account,TxHistory,TxDetail,SendTx,JsonRpc,TokenMeta,GasEstimate,GasFees endpoint;

Usage Examples

Example: Fetching Account Details

curl -X GET "https://api.example.com/api/v1/account/0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF"

Response:

{
  "balance": "0",
  "unconfirmedBalance": "0",
  "nonce": 0,
  "pubkey": "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF",
  "tokens": [
    {
      "balance": "1337",
      "contract": "0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d",
      "decimals": 18,
      "name": "FOX",
      "symbol": "FOX",
      "type": "ERC20"
    }
  ]
}

Example: Sending a Raw Transaction

curl -X POST "https://api.example.com/api/v1/send" \
  -H "Content-Type: application/json" \
  -d '{
    "hex": "0xf86b808504a817c80082520894..."
  }'

Response:

"0x123456789abcdef..."

Example: JSON-RPC Call

curl -X POST "https://api.example.com/api/v1/jsonrpc" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_blockNumber",
    "params": []
  }'

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1a4"
}

Summary

This OpenAPI specification defines a rich, well-typed, and robust RESTful API for interacting with the Avalanche EVM coinstack. It covers all essential blockchain operations such as querying accounts, transactions, sending transactions, gas fee estimation, and token metadata retrieval. The inclusion of a JSON-RPC proxy endpoint enables full node interaction, while detailed schema definitions enhance client integration and validation.

This file is a core part of the backend API layer in the overall architecture, serving as the contract between frontend clients and blockchain node interactions.


End of Documentation for swagger.json