openapi: 3.0.0
info:
  title: Substrate API Sidecar [V1 todo]
  description: These are yet to be implemented endpoints for Sidecar v1.
  version: 1.0.0-oas3
tags:
- name: pallets
  description: pallets employed in the runtime
paths:
  /pallets:
    get:
      tags:
      - pallets
      summary: Get a list of pallets used in the runtime.
      description: Returns an array of metadata for pallets that are used in the
        runtime. Can use `only-names` query param to just return an array of
        pallet names.
      parameters:
      - name: only-names
        in: query
        description: Only return the names of pallets.
        required: false
        schema:
          type: boolean
      - name: at
        in: query
        description: Block at which to retrieve a list of the runtime's pallets.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsResponses'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/constants:
    get:
      tags:
      - pallets
      summary: Get a list of constants for a pallet.
      description: Returns a list of metadata for constants of the pallet specified
        by palletId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to query the constant of.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve the list of exposed pallet
          constants.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsConstantsResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find pallet with with palletId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/constants/{constantId}:
    get:
      tags:
      - pallets
      summary: Get the value of a constant.
      description: Returns the value stored under the constantId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to query the constant of.
        required: true
        schema:
          type: string
      - name: constantId
        in: path
        description: Id of the constant to query for.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to query the constant at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsConstantValue'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find resource with with id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/dispatchables:
    get:
      tags:
      - pallets
      summary: Get a list of dispatchables for a pallet.
      description: Returns a list of the dispatchables of the specified palletId
         and the associated metadata of each.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to get the metadata of its dispatchables.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve a list of the pallet's
          dispatchables at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsDispatchablesResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find pallet with with palletId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/dispatchables/{dispatchableId}:
    get:
      tags:
      - pallets
      summary: Get the metadata of a dispatchable.
      description: Returns the metadata of a dispatchable with dispatchableId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to get the dispatchable of.
        required: true
        schema:
          type: string
      - name: dispatchableId
        in: path
        description: Index of the dispatchable in the pallet's dispatchable array.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve the dispatchable at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsDispatchableResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find resource with with id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/errors:
    get:
      tags:
      - pallets
      summary: Get a list of the errors for a pallet.
      description: Returns a list of metadata for errors of the specified palletId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to get the metadata of its errors.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve a list of the pallet's
          errors at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsErrorsResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find pallet with palletId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/errors/{errorId}:
    get:
      tags:
      - pallets
      summary: Get the metadata of an error.
      description: Returns the metadata of an error with errorId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to the error of.
        required: true
        schema:
          type: string
      - name: errorId
        in: path
        description: Index of the error in the pallet's errors array.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve the error at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsErrorResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find resource with id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/events:
    get:
      tags:
      - pallets
      summary: Get a list of events for a pallet.
      description: Returns a list of metadata for events of the specified palletId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to get the metadata of its events.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve a list of the pallet's events at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsEventsResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find pallet with palletId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pallets/{palletId}/events/{eventId}:
    get:
      tags:
      - pallets
      summary: Get the metadata of an event.
      description: Returns the metadata of an event with eventId.
      parameters:
      - name: palletId
        in: path
        description: Name or index of the pallet to the event of.
        required: true
        schema:
          type: string
      - name: eventId
        in: path
        description: Index of the event in the pallet's events array.
        required: true
        schema:
          type: string
      - name: at
        in: query
        description: Block at which to retrieve the event at.
        required: false
        schema:
          type: string
          description: Block identifier, as the block height or block hash.
          format: unsignedInteger or $hex
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PalletsEventResponse'
        "400":
          description: invalid blockId supplied for at query param
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        "404":
          description: could not find resource with id
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    BlockIdentifiers:
      type: object
      properties:
        hash:
          type: string
          description: The block's hash.
          format: hex
        height:
          type: string
          description: The block's height.
          format: unsignedInteger
      description: Block number and hash at which the call was made.
    PalletItemMetadataIndex:
      type: array
      description: Tuple where the first value is the index of the pallet in the filtered
        metadata and the second value is the index of the item in the pallet's array
        of the item type.
      items:
        type: string
        format: unsignedInteger
    PalletEvent:
      type: object
      properties:
        eventIndex:
          $ref: '#/components/schemas/PalletItemMetadataIndex'
        name:
          type: string
        args:
          type: array
          items:
            type: string
        documentation:
          type: array
          items:
            type: string
      description: Metadata of an event from a FRAME pallet.
    PalletError:
      type: object
      properties:
        errorIndex:
          $ref: '#/components/schemas/PalletItemMetadataIndex'
        name:
          type: string
        documentation:
          type: array
          items:
            type: string
      description: Metadata of an error from a FRAME pallet.
    PalletStorageType:
      type: object
    PalletStorageItemMetadata:
      type: object
      properties:
        storageItemIndex:
          $ref: '#/components/schemas/PalletItemMetadataIndex'
        name:
          type: string
        modifier:
          type: string
        type:
          $ref: '#/components/schemas/PalletStorageType'
        fallback:
          type: string
        documentation:
          type: array
          items:
            type: string
      description: Metadata of a storage item from a FRAME pallet.
    PalletConstant:
      type: object
      properties:
        constantIndex:
          $ref: '#/components/schemas/PalletItemMetadataIndex'
        name:
          type: string
        type:
          type: string
        value:
          type: string
        documentation:
          type: array
          items:
            type: string
      description: Metadata of a constant from a FRAME pallet.
    DispatchableArg:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
      description: Metadata of a parameter to a dispatchable call from a FRAME pallet.
    Dispatchable:
      type: object
      properties:
        callIndex:
          $ref: '#/components/schemas/PalletItemMetadataIndex'
        name:
          type: string
        args:
          type: array
          items:
            $ref: '#/components/schemas/DispatchableArg'
        documentation:
          type: array
          items:
            type: string
      description: Metadata of a dispatchable call from a FRAME pallet.
    PalletStorage:
      type: object
      properties:
        prefix:
          type: string
        items:
          type: array
          items:
            $ref: '#/components/schemas/PalletStorageItem'
    Pallet:
      type: object
      properties:
        index:
          type: string
          format: unsignedInteger
        name:
          type: string
        storage:
          $ref: '#/components/schemas/PalletStorage'
        calls:
          type: array
          items:
            $ref: '#/components/schemas/Dispatchable'
        events:
          type: array
          items:
            $ref: '#/components/schemas/PalletEvent'
        constants:
          type: array
          items:
            $ref: '#/components/schemas/PalletConstant'
        errors:
          type: array
          items:
            $ref: '#/components/schemas/PalletError'
      description: Metadata of a FRAME pallet.
    PalletsResponses:
      oneOf:
      - type: object
        properties:
          at:
            $ref: '#/components/schemas/BlockIdentifiers'
          pallets:
            type: array
            items:
              $ref: '#/components/schemas/Pallet'
        description: Array of pallet metadata from the runtime.
      - type: object
        properties:
          at:
            $ref: '#/components/schemas/BlockIdentifiers'
          pallets:
            type: array
            items:
              type: string
        description: Array of pallet names from the runtime.
    PalletsConstantsResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        constants:
          type: array
          items:
            $ref: '#/components/schemas/PalletConstant'
    PalletsConstantValue:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        value:
          type: string
    PalletsDispatchablesResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        dispatchables:
          type: array
          items:
            $ref: '#/components/schemas/Dispatchable'
    PalletsDispatchableResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        dispatchable:
          $ref: '#/components/schemas/Dispatchable'
    PalletsErrorsResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        errors:
          type: array
          items:
            $ref: '#/components/schemas/PalletError'
    PalletsErrorResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        error:
          $ref: '#/components/schemas/PalletError'
    PalletsEventsResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        events:
          type: array
          items:
            $ref: '#/components/schemas/PalletEvent'
    PalletsEventResponse:
      type: object
      properties:
        at:
          $ref: '#/components/schemas/BlockIdentifiers'
        event:
          $ref: '#/components/schemas/PalletEvent'
    Error:
      type: object
      properties:
        code:
          type: number
        message:
          type: string
        stack:
          type: string
