swagger.json


Overview

This file is an **OpenAPI 3.0** specification document for the [@shapeshiftoss/optimism-api](/projects/291/68947) version `10.0.0`. It defines a RESTful API that provides access to various functionalities related to the **Optimism** Ethereum Layer 2 scaling solution. The API exposes endpoints to:

This specification serves as a contract between the API provider and consumers, enabling automatic generation of client SDKs, server stubs, and comprehensive documentation.


Detailed Components Documentation

Components Schemas

The file includes detailed JSON Schemas describing data structures used in requests and responses.

1. BaseInfo

2. TokenBalance

3. Account

4. Tx (Transaction)

5. TokenTransfer

6. InternalTx

7. TxHistory / BaseTxHistory_Tx_

8. SendTxBody

9. RPCRequest / RPCResponse

10. TokenMetadata

11. EstimateGasBody & OptimismGasEstimate

12. Fees & OptimismGasFees

13. Error Responses


API Endpoints

All endpoints are prefixed with `/api/v1`.

1. GET /info

2. GET /account/{pubkey}

3. GET /account/{pubkey}/txs

4. GET /tx/{txid}

5. POST /send

6. POST /jsonrpc

7. GET /metadata/token

8. POST /gas/estimate

9. GET /gas/fees


Important Implementation Details and Algorithms


Integration and Interactions


Usage Examples

Example: Get Account Details

**Request:**

GET /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: Send Raw Transaction

**Request:**

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

{
  "hex": "0xf86b808504a817c80082520894ad6d458402f60fd3bd25163575031acdce07538d880de0b6b3a76400008025a0e9d..."
}

**Response:**

"0x123abc..."

Visual Diagram of File Structure

This file is primarily a **specification document** describing schemas and API paths. It does not define classes or functions but organizes components (schemas) and endpoints.

The diagram below illustrates the structural relationship between **schemas** and **API paths**, highlighting request/response flow.

flowchart TD
    subgraph Schemas
        BaseInfo["BaseInfo"]
        Account["Account"]
        TokenBalance["TokenBalance"]
        Tx["Tx"]
        TokenTransfer["TokenTransfer"]
        InternalTx["InternalTx"]
        TxHistory["TxHistory"]
        SendTxBody["SendTxBody"]
        RPCRequest["RPCRequest"]
        RPCResponse["RPCResponse"]
        TokenMetadata["TokenMetadata"]
        EstimateGasBody["EstimateGasBody"]
        OptimismGasEstimate["OptimismGasEstimate"]
        Fees["Fees"]
        OptimismGasFees["OptimismGasFees"]
        Errors["Error Schemas"]
    end

    subgraph API_Paths
        Info["GET /info"]
        GetAccount["GET /account/{pubkey}"]
        GetTxHistory["GET /account/{pubkey}/txs"]
        GetTx["GET /tx/{txid}"]
        SendTx["POST /send"]
        JsonRpc["POST /jsonrpc"]
        TokenMeta["GET /metadata/token"]
        GasEstimate["POST /gas/estimate"]
        GasFees["GET /gas/fees"]
    end

    %% Relationships
    Info -->|response| BaseInfo
    GetAccount -->|response| Account
    Account --> TokenBalance
    GetTxHistory -->|response| TxHistory
    TxHistory --> Tx
    Tx --> TokenTransfer
    Tx --> InternalTx
    GetTx -->|response| Tx
    SendTx -->|request| SendTxBody
    SendTx -->|response| "string (txid)"
    JsonRpc -->|request| RPCRequest
    JsonRpc -->|response| RPCResponse
    TokenMeta -->|response| TokenMetadata
    GasEstimate -->|request| EstimateGasBody
    GasEstimate -->|response| OptimismGasEstimate
    GasFees -->|response| OptimismGasFees

    %%