swagger.json

Overview

`swagger.json` is an OpenAPI 2.0 (Swagger) specification file describing the REST API for the **Thorchain Unchained API**. This API provides access to Thorchain blockchain data, enabling clients to retrieve account info, transaction history, transaction details, affiliate revenue, gas estimates, and broadcast raw transactions. It also supports a WebSocket endpoint for subscribing to pending and confirmed transactions.

The file defines the API endpoints (`paths`), data models (`definitions`), request/response formats, and metadata such as content types, license, and API information. This specification drives API documentation, client SDK generation, and server stubs.


API Endpoints

The API exposes a set of RESTful endpoints under `/api/v1/` and a WebSocket subscription endpoint `/`. Below is a detailed description of each endpoint:

1. WebSocket Subscription

GET /

**Usage Example:**

Client establishes a WebSocket connection to receive real-time transaction updates.


2. Get Account Details

GET /api/v1/account/{pubkey}

**Usage Example:**

GET /api/v1/account/abc123pubkey
Accept: application/json

3. Get Paginated Transaction History

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


4. Get Affiliate Revenue

GET /api/v1/affiliate/revenue


5. Estimate Gas Cost

POST /api/v1/gas/estimate

**Usage Example:**

POST /api/v1/gas/estimate
Content-Type: application/json

{
  "rawTx": "ABC123RAWTRANSACTIONDATA"
}

6. Get Coinstack Info

GET /api/v1/info


7. Send Raw Transaction

POST /api/v1/send

**Usage Example:**

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

{
  "rawTx": "ABC123RAWTRANSACTIONDATA"
}

8. Get Transaction Details

GET /api/v1/tx/{txid}


Data Model Definitions

The `definitions` section describes all data models used in requests and responses. These models are crucial for understanding the structure and content of payloads.

Key Data Models

Model Composition


Implementation Details and Algorithms


Interaction with Other System Components


Visual Diagram

Below is a **flowchart** representing the main API endpoints and their relationships to core data models.

flowchart TD
    WS[WebSocket Subscription<br/>"/"]
    Account["Get Account Details<br/>/api/v1/account/{pubkey}"]
    TxHistory["Get Transaction History<br/>/api/v1/account/{pubkey}/txs"]
    AffiliateRev["Get Affiliate Revenue<br/>/api/v1/affiliate/revenue"]
    GasEstimate["Estimate Gas<br/>/api/v1/gas/estimate"]
    Info["Get Coinstack Info<br/>/api/v1/info"]
    SendTx["Send Raw Transaction<br/>/api/v1/send"]
    GetTx["Get Transaction Details<br/>/api/v1/tx/{txid}"]

    WS -->|Subscribes to| Tx

    Account -->|Returns| AccountModel[Account]
    TxHistory -->|Returns| TxHistoryModel[TxHistory]
    AffiliateRev -->|Returns| AffiliateRevenueModel[AffiliateRevenue]
    GasEstimate -->|Returns| GasAmountModel[GasAmount]
    Info -->|Returns| InfoModel[Info]
    SendTx -->|Returns| TxHash[TransactionHash]
    GetTx -->|Returns| TxModel[Tx]

    %% Data models cluster
    subgraph Data_Models
      AccountModel
      TxHistoryModel
      AffiliateRevenueModel
      GasAmountModel
      InfoModel
      TxHash
      TxModel
    end

Summary

This file is central to exposing Thorchain blockchain data and transaction capabilities in a standardized, machine-readable format.