swagger.json


Overview

This file defines the OpenAPI 3.0 specification for the [@shapeshiftoss/bitcoin-api](/projects/291/69281) version `10.0.0`. It provides a comprehensive description of a RESTful HTTP API designed to interact with a Bitcoin coinstack. The API enables clients to retrieve information about the blockchain network, accounts (addresses or extended public keys), transactions, unspent transaction outputs (UTXOs), network fees, and to broadcast raw transactions.

The specification includes detailed schemas for request and response payloads, HTTP endpoints with methods, parameters, and expected responses, as well as metadata about the API.


Purpose and Functionality

The primary purpose of this file is to serve as a contract for the Bitcoin API, enabling developers and tools to understand and interact with the API effectively. It standardizes:

This API is vital for wallet services, blockchain explorers, and other Bitcoin-related applications requiring programmatic access to blockchain data and transaction management.


Detailed Components

Schemas

The [components.schemas](/projects/291/69205) section defines the data models used throughout the API responses and requests. These schemas ensure consistent data structures and validation rules.

Below are key schemas with explanations:


BaseInfo


Address


Account


Vin (Transaction Input)


Vout (Transaction Output)


Tx (Transaction)


TxHistory (Transaction History)


Utxo (Unspent Transaction Output)


RawTx (Raw Transaction)


SendTxBody


NetworkFee and NetworkFees


Error Schemas


API Endpoints Summary

Path

Method

OperationId

Description

Response Schema

/api/v1/info

GET

GetInfo

Get info about the running coinstack

`BaseInfo`

/api/v1/account/{pubkey}

GET

GetAccount

Get account details by address or extended public key

`Account`

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

GET

GetTxHistory

Get transaction history for an account

`TxHistory`

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

GET

GetUtxos

Get UTXOs for an account

array of `Utxo`

/api/v1/tx/{txid}

GET

GetTransaction

Get transaction details by txid

`Tx`

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

GET

GetRawTransaction

Get raw transaction details from the node

`RawTx`

`/api/v1/send`

POST

SendTx

Broadcast a raw transaction

string (txid)

/api/v1/fees

GET

GetNetworkFees

Get current recommended network fees

`NetworkFees`


Important Implementation Details


Interaction with Other System Components


Usage Examples

Example: Get Account Details

GET /api/v1/account/03a34b... HTTP/1.1
Host: api.example.com
Accept: application/json

Response:

{
  "balance": "150000",
  "unconfirmedBalance": "5000",
  "pubkey": "03a34b...",
  "addresses": [
    {
      "balance": "100000",
      "pubkey": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
    }
  ],
  "nextReceiveAddressIndex": 5,
  "nextChangeAddressIndex": 2
}

Example: Send Raw Transaction

POST /api/v1/send HTTP/1.1
Host: api.example.com
Content-Type: application/json

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

Response:

"b6f6991d3a0e7eeb0f8b..."

Visual Diagram

Below is a Mermaid class diagram illustrating the key data schemas and their relationships in this API specification.

classDiagram
    class BaseInfo {
        +string network
    }
    class Address {
        +string balance
        +string pubkey
    }
    class Account {
        +string balance
        +string unconfirmedBalance
        +string pubkey
        +Address[] addresses
        +number nextReceiveAddressIndex
        +number nextChangeAddressIndex
    }
    class Vin {
        +string txid
        +string vout
        +number sequence
        +string coinbase
        +object scriptSig
        +string[] addresses
        +string value
    }
    class Vout {
        +string value
        +number n
        +string opReturn
        +object scriptPubKey
        +string[] addresses
    }
    class Tx {
        +string txid
        +string blockHash
        +number blockHeight
        +number timestamp
        +Vin[] vin
        +Vout[] vout
        +number confirmations
        +string value
        +string fee
        +string hex
    }
    class TxHistory {
        +string cursor
        +string pubkey
        +Tx[] txs
    }
    class Utxo {
        +string txid
        +number vout
        +string value
        +number height
        +number confirmations
        +string address
        +string path
        +number locktime
        +boolean coinbase
    }
    class RawTx {
        +string txid
        +string hash
        +number version
        +number size
        +number vsize
        +number weight
        +number locktime
        +object[] vin
        +object[] vout
        +string hex
        +string blockhash
        +number confirmations
        +number time
        +number blocktime
    }
    class SendTxBody {
        +string hex
    }
    class NetworkFee {
        +number satsPerKiloByte
        +number blocksUntilConfirmation
    }
    class NetworkFees {
        +NetworkFee fast
        +NetworkFee average
        +NetworkFee slow
    }
    class BadRequestError {
        +string error
    }
    class ValidationError {
        +string message
        +object details
    }
    class InternalServerError {
        +string message
    }

    Account "1" -- "*" Address : contains
    Tx "1" -- "*" Vin : contains
    Tx "1" -- "*" Vout : contains
    TxHistory "1" -- "*" Tx : contains
    NetworkFees "1" -- "1" NetworkFee : fast
    NetworkFees "1" -- "1" NetworkFee : average
    NetworkFees "1" -- "1" NetworkFee : slow

Summary

This [swagger.json](/projects/291/68851) file is a detailed OpenAPI specification that acts as the blueprint for the Bitcoin API developed by ShapeShift. It defines how clients can query blockchain data, manage accounts and transactions, and broadcast new transactions efficiently and reliably. The schemas provide strong typing and validation, while the paths describe RESTful operations with clear request and response structures. This file facilitates integration, documentation, and automation for applications interacting with the Bitcoin blockchain via this API.


End of Documentation for swagger.json