swagger.json


Overview

[swagger.json](/projects/291/68851) is an OpenAPI 2.0 (Swagger) specification file that describes the REST API for the **Thorchain-V1 Unchained API**. This API provides programmatic access to Thorchain V1 blockchain data, allowing clients to retrieve information about accounts, transactions, and the running blockchain node.

The specification defines:

This file acts as a contract that both API providers and consumers can rely on for consistent interaction, documentation generation, client SDK generation, and automated testing.


API Endpoints

The API exposes the following main endpoints:

1. Get Paginated Transaction History

**Usage example:**

GET /api/v1/account/cosmos1abcxyz/txs?pageSize=10&cursor=eyJjdXJzb3IiOiIxMjMifQ==

2. Get Info About the Running Coinstack

**Usage example:**

GET /api/v1/info

3. Get Transaction Details

**Usage example:**

GET /api/v1/tx/ABC123DEF456...

Data Models and Definitions

The `definitions` section contains detailed JSON schema definitions for the data objects used in requests and responses.

Key data models include:

1. Base Models

2. Cosmos SDK Related Models

3. Transaction Models

4. Pagination and Error Models

5. Value Models

**Example: Tx Object Schema**

{
  "txid": "string",
  "blockHeight": 1000000,
  "timestamp": 1643052655037,
  "confirmations": 12,
  "fee": {
    "amount": "1000",
    "denom": "rune"
  },
  "gasUsed": "888",
  "gasWanted": "999",
  "index": 1,
  "memo": "test memo",
  "messages": [
    {
      "index": "0",
      "origin": "cosmos",
      "from": "cosmos1...",
      "to": "cosmos1...",
      "type": "/cosmos.bank.v1beta1.MsgSend",
      "value": {
        "amount": "123456789",
        "denom": "rune"
      }
    }
  ],
  "events": {
    "0": {
      "message": {
        "action": "transfer"
      }
    }
  },
  "value": "123456789"
}

Implementation Details and Algorithms


Interaction with Other System Components


Visual Diagram: API Structure Flowchart

flowchart TD
    A[API Root] --> B[GET /api/v1/account/{pubkey}/txs]
    A --> C[GET /api/v1/info]
    A --> D[GET /api/v1/tx/{txid}]

    B --> B1[Parameters: pubkey (path), cursor (query), pageSize (query)]
    B --> B2[Response: TxHistory | BadRequestError | InternalServerError]

    C --> C1[No parameters]
    C --> C2[Response: Info]

    D --> D1[Parameter: txid (path)]
    D --> D2[Response: Tx | BadRequestError | InternalServerError]

    subgraph Data Models
        TxHistory
        Info
        Tx
        BadRequestError
        InternalServerError
    end

Summary

The [swagger.json](/projects/291/68851) file is a comprehensive OpenAPI specification for the Thorchain-V1 Unchained API, detailing endpoints, parameters, responses, and data schemas. It enables clients to interact with Thorchain blockchain data efficiently and reliably, supports pagination for large data sets, and provides clear error messaging. The specification also serves as a foundation for generating client SDKs, API documentation, and automated tests, promoting maintainability and consistency throughout the project lifecycle.