swagger.json


Overview

The [swagger.json](/projects/291/68851) file is an OpenAPI 3.0 specification document that defines the REST API contract for the [@shapeshiftoss/bitcoincash-api](/projects/291/69281) service. This API provides endpoints for interacting with a Bitcoin Cash coinstack, supporting operations such as retrieving account information, transaction history, unspent transaction outputs (UTXOs), transaction details, broadcasting transactions, and fetching network fee recommendations.

This file serves as the authoritative schema for the API, describing available paths, request parameters, response formats, and data models (schemas). It enables automated client generation, API documentation, server stubs, and validation for the Bitcoin Cash API.


Components (Schemas)

The file defines multiple JSON schemas under [components.schemas](/projects/291/69205) to describe the structure of data objects returned or accepted by the API. These schemas ensure consistent data validation and provide detailed metadata for each entity.

Key Schemas Summary

Schema Name

Description

**BaseInfo**

Basic info about the running coinstack (e.g., network type).

**Address**

Info about an address linked to an extended public key, including balance and public key.

**Account**

Details about an account (address or extended public key), including balances and addresses.

**BadRequestError**

Represents a 400 Bad Request error response.

**ValidationError**

Represents a 422 Validation Error response with message and details.

**InternalServerError**

Represents a 500 Internal Server Error response.

**Vin**

Information about a transaction input (e.g., txid, scriptSig, addresses).

**Vout**

Information about a transaction output (e.g., value, scriptPubKey, addresses).

**Tx**

Comprehensive transaction details including inputs, outputs, fees, confirmations, etc.

**TxHistory**

Paginated transaction history for an account/public key with a cursor for pagination.

**Utxo**

Unspent transaction output details such as txid, vout index, value, confirmations, and address.

**RawTx**

Raw transaction data as returned directly from the Bitcoin Cash node.

**SendTxBody**

Contains the serialized raw transaction hex string for sending/broadcasting a transaction.

**NetworkFee**

Fee recommendation data including sats per kilobyte and blocks until confirmation.

**NetworkFees**

Aggregated network fee info across different confirmation speed tiers (fast, average, slow).


API Paths and Operations

The API exposes the following main resource paths:

1. /api/v1/info

**Example Usage:**

GET /api/v1/info
Accept: application/json

Response 200 OK
{
  "network": "bitcoincash"
}

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

**Example Usage:**

GET /api/v1/account/bitcoincash:qz0...xyz
Accept: application/json

Response 200 OK
{
  "balance": "1000000",
  "unconfirmedBalance": "50000",
  "pubkey": "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiK...",
  "addresses": [
    {
      "balance": "500000",
      "pubkey": "bitcoincash:qz..."
    }
  ],
  "nextReceiveAddressIndex": 5,
  "nextChangeAddressIndex": 2
}

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


4. /api/v1/account/{pubkey}/utxos


5. /api/v1/tx/{txid}


6. /api/v1/tx/{txid}/raw


7. /api/v1/send

**Example Request:**

POST /api/v1/send
Content-Type: application/json

{
  "hex": "0200000001abcdef..."
}

Response 200 OK
"txid1234567890abcdef"

8. /api/v1/fees


Important Implementation Details & Algorithms


Interaction with Other System Components


Visual Diagram

Below is a flowchart representing the API's main endpoints and their relationships with key data schemas:

flowchart TD
    Info["GET /api/v1/info"]
    Account["GET /api/v1/account/{pubkey}"]
    TxHistory["GET /api/v1/account/{pubkey}/txs"]
    Utxos["GET /api/v1/account/{pubkey}/utxos"]
    Tx["GET /api/v1/tx/{txid}"]
    RawTx["GET /api/v1/tx/{txid}/raw"]
    SendTx["POST /api/v1/send"]
    Fees["GET /api/v1/fees"]

    Info -->|returns| BaseInfo[BaseInfo Schema]
    Account -->|returns| AccountSchema[Account Schema]
    TxHistory -->|returns| TxHistorySchema[TxHistory Schema]
    Utxos -->|returns| UtxoList[Array of Utxo Schema]
    Tx -->|returns| TxSchema[Tx Schema]
    RawTx -->|returns| RawTxSchema[RawTx Schema]
    SendTx -->|request with| SendTxBody[SendTxBody Schema]
    SendTx -->|returns| TxId[String]
    Fees -->|returns| NetworkFeesSchema[NetworkFees Schema]

    %% Error responses linked to all endpoints
    subgraph Errors
        BadReq[BadRequestError]
        ValErr[ValidationError]
        IntErr[InternalServerError]
    end

    Info --- Errors
    Account --- Errors
    TxHistory --- Errors
    Utxos --- Errors
    Tx --- Errors
    RawTx --- Errors
    SendTx --- Errors
    Fees --- Errors

Summary

The [swagger.json](/projects/291/68851) file comprehensively defines the REST API for a Bitcoin Cash coinstack service, including endpoints for querying blockchain data, managing accounts, transactions, and fees, as well as broadcasting transactions. It uses OpenAPI 3.0 standards to provide detailed schema definitions and response validation, facilitating integration by client applications and ensuring consistency and reliability of interactions with the Bitcoin Cash network.