openapi: 3.0.0
info:
  title: Trace API
  version: 1.0.0
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  contact:
    url: https://wire.network

servers:
  - url: "{protocol}://{host}:{port}/v1/"
    variables:
      protocol:
        enum:
          - http
          - https
        default: http
      host:
        default: localhost
      port:
        default: "8080"

components:
  schemas: {}

paths:
  "/trace_api/get_block":
    post:
      description: Returns a block trace object containing retired actions and related metadata.
      operationId: get_block
      requestBody:
        content:
          application/json:
            # the required field is block_num, so let's provide an example
            example:
              block_num: 1000
            schema:
              type: object
              required:
                - block_num
              properties:
                block_num:
                  type: integer
                  description: Provide a `block number`
      responses:
        '200':
          description: OK - valid response payload
          content:
            application/json:
              schema:
                oneOf:
                  # -------------- BlockTraceV0 --------------
                  - type: object
                    additionalProperties: false
                    minProperties: 7
                    required:
                      - id
                      - number
                      - previous_id
                      - status
                      - timestamp
                      - producer
                      - transactions
                    properties:
                      id:
                        type: string
                        pattern: "^[0-9A-Fa-f]{64}$"
                        title: Sha256
                      number:
                        description: height of this block in the chain
                        type: integer
                      previous_id:
                        "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                      status:
                        description: pending or irreversible
                        type: string
                      timestamp:
                        type: string
                        description: Date/time string in the format YYYY-MM-DDTHH:MM:SS.sss
                        pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}$"
                        title: DateTimeSeconds
                      producer:
                        oneOf:
                          - type: string
                            maxLength: 0
                            title: EmptyString
                          - anyOf:
                              - type: string
                                description: String representation of privileged SYSIO name type
                                pattern: "^(sysio[\\.][a-z1-5]{1,6})([a-j]{1})?$"
                                title: NamePrivileged
                              - type: string
                                description: String representation of basic SYSIO name type, must be 12 chars with [a-z0-5]
                                pattern: "^([a-z]{1}[a-z1-5]{11})([a-j]{1})?$"
                                title: NameBasic
                              - type: string
                                description: A SYSIO bid name type (1-12 chars, only a-z and 0-5)
                                pattern: "^([a-z1-5]{1,12})([a-j]{1})?$"
                                title: NameBid
                              - type: string
                                description: String representation of SYSIO name type
                                pattern: "^([a-z1-5]{1}[a-z1-5\\.]{0,10}[a-z1-5]{1})([a-j]{1})?$"
                                title: NameCatchAll
                            title: Name
                      transactions:
                        description: list of transaction traces generated from block
                        type: array
                        items:
                          type: object
                          additionalProperties: false
                          minProperties: 2
                          required:
                            - id
                            - actions
                          properties:
                            id:
                              "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                            actions:
                              type: array
                              items:
                                type: object
                                additionalProperties: false
                                minProperties: 6
                                required:
                                  - global_sequence
                                  - receiver
                                  - account
                                  - action
                                  - authorization
                                  - data
                                properties:
                                  global_sequence:
                                    type: integer
                                  receiver:
                                    "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/1"
                                  account:
                                    "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/1"
                                  action:
                                    "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/1"
                                  authorization:
                                    type: array
                                    items:
                                      type: object
                                      additionalProperties: false
                                      minProperties: 2
                                      required:
                                        - account
                                        - permission
                                      properties:
                                        account:
                                          "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/1"
                                        permission:
                                          "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/1"
                                    title: AuthorizationTraceV0
                                  data:
                                    type: object
                                    additionalProperties: true
                                title: ActionTraceV0
                          title: TransactionTraceV0
                    title: BlockTraceV0

                  # -------------- BlockTraceV1 --------------
                  - type: object
                    additionalProperties: false
                    minProperties: 10
                    required:
                      - id
                      - number
                      - previous_id
                      - status
                      - timestamp
                      - producer
                      - transaction_mroot
                      - action_mroot
                      - schedule_version
                      - transactions
                    properties:
                      id:
                        "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                      number:
                        description: height of this block in the chain
                        type: integer
                      previous_id:
                        "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                      status:
                        description: pending or irreversible
                        type: string
                      timestamp:
                        "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/timestamp"
                      producer:
                        oneOf:
                          - "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/0"
                          - "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/producer/oneOf/1"
                      transaction_mroot:
                        "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                      action_mroot:
                        "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                      schedule_version:
                        description: number of times producer schedule has changed since genesis
                        type: integer
                      transactions:
                        description: list of transaction traces generated from block
                        type: array
                        items:
                          type: object
                          additionalProperties: false
                          minProperties: 7
                          required:
                            - id
                            - actions
                            - status
                            - cpu_usage_us
                            - net_usage_words
                            - signatures
                            - transaction_header
                          properties:
                            id:
                              "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/id"
                            actions:
                              type: array
                              items:
                                "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/0/properties/transactions/items/properties/actions/items"
                            status:
                              type: string
                              enum:
                                - executed
                                - soft_fail
                                - hard_fail
                                - delayed
                                - expired
                              description: |
                                status:
                                  * `executed` - Succeed, no error handler executed
                                  * `soft_fail` - Objectively failed (not executed), error handler executed
                                  * `hard_fail` - Objectively failed and error handler objectively failed thus no state change
                                  * `delayed` - Used by delayed-user transactions for timer-based executions
                                  * `expired` - Transaction expired and storage space refunded to user
                            cpu_usage_us:
                              type: integer
                            net_usage_words:
                              type: integer
                            signatures:
                              type: array
                              items:
                                type: string
                                description: Base58 encoded SYSIO cryptographic signature
                                pattern: "^SIG_([RK]1|WA)_[1-9A-HJ-NP-Za-km-z]+$"
                                title: Signature
                            transaction_header:
                              type: object
                              additionalProperties: false
                              minProperties: 6
                              required:
                                - expiration
                                - ref_block_num
                                - ref_block_prefix
                                - max_net_usage_words
                                - max_cpu_usage_ms
                                - delay_sec
                              properties:
                                expiration:
                                  description: Time that transaction must be confirmed by.
                                  type: string
                                  pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$"
                                  title: DateTime
                                ref_block_num:
                                  type: integer
                                ref_block_prefix:
                                  description: 32-bit portion of block ID
                                  type: integer
                                max_net_usage_words:
                                  "$ref": "#/paths/~1trace_api~1get_block/post/responses/200/content/application~1json/schema/oneOf/1/properties/transactions/items/properties/transaction_header/properties/max_cpu_usage_ms"
                                max_cpu_usage_ms:
                                  description: A whole number
                                  anyOf:
                                    - type: string
                                      pattern: "^\\d+$"
                                    - type: integer
                                  title: WholeNumber
                                delay_sec:
                                  type: integer
                              title: TransactionHeader
                          title: TransactionTraceV1
                    title: BlockTraceV1
        '400':
          description: Error - requested block number is invalid (not a number, larger than max int)
        '404':
          description: Error - requested data not present on node
        '500':
          description: Error - exceptional condition while processing get_block; e.g. corrupt files
      x-codeSamples:
        - lang: Shell
          label: Shell
          source: |
            curl -X POST "http://localhost:8080/v1/trace_api/get_block" \
              -H "Content-Type: application/json" \
              -d '{"block_num": 1000}'
        - lang: Node.js
          label: Node.js
          source: |
            const fetch = require('node-fetch');

            const payload = {
              block_num: 1000
            };

            fetch("http://localhost:8080/v1/trace_api/get_block", {
              method: "POST",
              headers: { "Content-Type": "application/json" },
              body: JSON.stringify(payload)
            })
              .then(res => res.json())
              .then(console.log)
              .catch(console.error);
        - lang: Python
          label: Python
          source: |
            import requests

            url = "http://localhost:8080/v1/trace_api/get_block"
            payload = {
              "block_num": 1000
            }
            headers = {"Content-Type": "application/json"}

            response = requests.post(url, json=payload, headers=headers)
            print(response.text)

  /trace_api/get_transaction_trace:
    post:
      summary: get_transaction_trace
      description: Returns the trace information for a specific transaction by its ID. This endpoint searches for the block containing the transaction and returns the full transaction trace.
      operationId: get_transaction_trace
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - id
              properties:
                id:
                  type: string
                  description: The transaction ID (hash) to retrieve the trace for. Must be between 8 and 64 characters.
                  minLength: 8
                  maxLength: 64
            example:
              id: "02ca32345cc025052c8fe119516aa6086e14a333eddc4433283ecf50374e2b06"
      responses:
        "200":
          description: OK - Transaction trace found
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Transaction ID
                  block_num:
                    type: integer
                    description: Block number containing this transaction
                  block_time:
                    type: string
                    description: Block timestamp
                  producer_block_id:
                    type: string
                    description: Block ID as produced
                  status:
                    type: string
                    description: Transaction status (executed, soft_fail, hard_fail, delayed, expired)
                  cpu_usage_us:
                    type: integer
                    description: CPU usage in microseconds
                  net_usage_words:
                    type: integer
                    description: Net usage in words
                  actions:
                    type: array
                    description: List of action traces
                    items:
                      type: object
                      properties:
                        receiver:
                          type: string
                        account:
                          type: string
                        action:
                          type: string
                        authorization:
                          type: array
                          items:
                            type: object
                            properties:
                              actor:
                                type: string
                              permission:
                                type: string
                        data:
                          type: object
              examples:
                ExampleResponse:
                  summary: Sample Transaction Trace
                  value:
                    id: "02ca32345cc025052c8fe119516aa6086e14a333eddc4433283ecf50374e2b06"
                    block_num: 12345
                    block_time: "2025-02-07T18:50:13.000"
                    producer_block_id: "0000303939c5b8b5c6d7e8f9..."
                    status: "executed"
                    cpu_usage_us: 250
                    net_usage_words: 12
                    actions:
                      - receiver: "sysio.token"
                        account: "sysio.token"
                        action: "transfer"
                        authorization:
                          - actor: "alice"
                            permission: "active"
                        data:
                          from: "alice"
                          to: "bob"
                          quantity: "1.0000 SYS"
                          memo: "test transfer"
        "400":
          description: Error - Bad or missing transaction ID
        "404":
          description: Error - Transaction ID not found in trace log files or transaction trace missing
        "500":
          description: Error - Exceptional condition while processing request
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl -X POST "http://localhost:8080/v1/trace_api/get_transaction_trace" \
              -H "Content-Type: application/json" \
              -d '{"id": "02ca32345cc025052c8fe119516aa6086e14a333eddc4433283ecf50374e2b06"}'
        - lang: Node.js
          label: Node.js
          source: |
            const fetch = require('node-fetch');

            const payload = {
              id: "02ca32345cc025052c8fe119516aa6086e14a333eddc4433283ecf50374e2b06"
            };

            fetch("http://localhost:8080/v1/trace_api/get_transaction_trace", {
              method: "POST",
              headers: { "Content-Type": "application/json" },
              body: JSON.stringify(payload)
            })
              .then(res => res.json())
              .then(console.log)
              .catch(console.error);
        - lang: Python
          label: Python
          source: |
            import requests

            url = "http://localhost:8080/v1/trace_api/get_transaction_trace"
            payload = {
              "id": "02ca32345cc025052c8fe119516aa6086e14a333eddc4433283ecf50374e2b06"
            }
            headers = {"Content-Type": "application/json"}

            response = requests.post(url, json=payload, headers=headers)
            print(response.json())
