> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get IDL

> Get the IDL that was in effect for a Solana program at any slot, from the catalog Parsed Events uses to decode instructions.

The path parameters, response schema, and examples on this page are generated from the OpenAPI definition.

Get IDL returns a program's IDL as of a slot: the latest version that became active at or before `slot`. `slot` doesn't need to match a version exactly, so you can pass any point in history. To fetch one specific version, pass its `slot` from [List IDL Versions](https://www.helius.dev/docs/api-reference/parsed-events/idl-versions.md).

The IDL comes from the same catalog that Parsed Events and [Parsed Streams](https://www.helius.dev/docs/parsed-streams.md) use to decode instructions. The [Orb explorer](https://www.helius.dev/docs/orb/explore-programs.md) uses these endpoints to show program IDLs.

## Use Cases

* **Decode history with the right interface.** Pass a transaction's slot to get the IDL that was live when it executed. Programs change their instructions and accounts over time, so the current IDL can misread older transactions.
* **Find exact names for filters.** [Scan Transaction History](https://www.helius.dev/docs/api-reference/parsed-events/scan.md) `match.programs[].instructions` accepts instruction names as the IDL spells them.
* **Review interface changes.** Fetch two versions and compare their `instructions` to see what an upgrade added or removed. See the example on [List IDL Versions](https://www.helius.dev/docs/api-reference/parsed-events/idl-versions.md#example-detect-a-new-idl-version).

## IDL Formats

The response is the IDL document as stored. Programs in the catalog use one of two Anchor formats, and one program's versions can use both. Check which format you received before reading it:

| | Legacy Anchor (before 0.30) | Anchor 0.30+ |
| - | - | - |
| Program name and version | Top-level `name` and `version` | `metadata.name` and `metadata.version` |
| Program address | No top-level `address` | Top-level `address` |
| Instruction discriminator | Not included | `instructions[].discriminator` |
| Instruction account flags | `isMut`, `isSigner` | `writable`, `signer` |

Both formats have `instructions`. Most IDLs also have `accounts`, `types`, and `errors`, and many have `events`.

## Credits

Each request costs **10 credits** and is available on all plans. See [Credits](https://www.helius.dev/docs/billing/credits.md#parsed-events).

## Errors

| Status | When |
| - | - |
| `400` | `programId` isn't a valid base58 address, or `slot` isn't an unsigned 64-bit integer. |
| `401` | The API key is missing or invalid. The body is plain text: `Unauthorized`. |
| `404` | The catalog has no IDL for the program, or no version was active at or before `slot`. |

Other errors return a JSON body with an `error` message, such as `{"error": "no IDL found for program KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD at or before slot 1"}`.

## Request Parameters

**programId** `string` *required*

Program address, base58-encoded.

**slot** `number` *required*

Slot to look up. It doesn't need to match a version's activation slot. Pass a `slot` from List IDL Versions to get that exact version, or a transaction's slot to get the IDL in effect when it executed.


## OpenAPI

````yaml openapi/parsed-events.yaml GET /v1/parsed-events/idl/{programId}/{slot}
openapi: 3.0.3
info:
  title: Parsed Events
  version: 0.1.0
  description: Parse Solana transactions and parsed transaction history with Parsed Events.
servers:
  - url: https://mainnet.helius-rpc.com
security:
  - ApiKeyQuery: []
paths:
  /v1/parsed-events/idl/{programId}/{slot}:
    get:
      tags:
        - Parsed Events
      summary: Get IDL
      description: >-
        Get the IDL that was in effect for a program at a slot, which is the
        latest version activated at or before `slot`.
      operationId: getIdlParsedEvents
      parameters:
        - $ref: '#/components/parameters/ProgramId'
        - name: slot
          in: path
          required: true
          description: >-
            Slot to look up. It doesn't need to match a version's activation
            slot. Pass a `slot` from List IDL Versions to get that exact
            version, or a transaction's slot to get the IDL in effect when it
            executed.
          schema:
            type: integer
            format: uint64
            minimum: 0
            example: 205509752
      responses:
        '200':
          description: >-
            The IDL document as stored. Both the legacy Anchor format and the
            Anchor 0.30+ format occur, so check which one you received before
            reading it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Idl'
              examples:
                Legacy Anchor IDL:
                  summary: >-
                    Kamino Lend at slot 182747476 (trimmed to one instruction
                    and one error)
                  value:
                    name: kamino_lending
                    version: 0.1.0
                    instructions:
                      - name: refreshObligation
                        accounts:
                          - name: lendingMarket
                            isMut: false
                            isSigner: false
                          - name: obligation
                            isMut: true
                            isSigner: false
                        args: []
                    errors:
                      - code: 6000
                        name: InvalidMarketAuthority
                        msg: Market authority is invalid
                Anchor 0.30+ IDL:
                  summary: >-
                    Pump AMM at slot 454326107 (trimmed to one instruction and
                    one error)
                  value:
                    address: pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA
                    metadata:
                      name: pump_amm
                      version: 0.1.0
                      spec: 0.1.0
                      description: Created with Anchor
                    instructions:
                      - name: toggle_boost
                        discriminator:
                          - 117
                          - 161
                          - 160
                          - 74
                          - 223
                          - 137
                          - 118
                          - 99
                        accounts:
                          - name: admin
                            signer: true
                            relations:
                              - global_config
                          - name: global_config
                            writable: true
                        args:
                          - name: enabled
                            type: bool
                    errors:
                      - code: 6000
                        name: FeeBasisPointsExceedsMaximum
        '400':
          $ref: '#/components/responses/IdlBadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: >-
            The catalog has no IDL for the program, or no version was active at
            or before `slot`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                default:
                  value:
                    error: >-
                      no IDL found for program
                      KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD at or before
                      slot 1
components:
  parameters:
    ProgramId:
      name: programId
      in: path
      required: true
      description: Program address, base58-encoded.
      schema:
        type: string
        example: KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD
  schemas:
    Idl:
      type: object
      additionalProperties: true
      description: >-
        An IDL document, returned as stored. Two formats occur:


        - **Legacy Anchor** (before 0.30): top-level `name` and `version`.
        Instruction accounts use `isMut` and `isSigner`.

        - **Anchor 0.30+**: top-level `address` and `metadata` (`name`,
        `version`, `spec`, `description`). Instructions carry a `discriminator`,
        and instruction accounts use `writable` and `signer`.


        Both formats have `instructions`. Most IDLs also have `accounts`,
        `types`, and `errors`, and many have `events`. One program's versions
        can use different formats.
    ErrorResponse:
      type: object
      description: Request-level error response.
      properties:
        error:
          type: string
          description: Error message.
  responses:
    IdlBadRequest:
      description: >-
        `programId` isn't a valid address, or `slot` isn't an unsigned 64-bit
        integer.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            Invalid program ID:
              value:
                error: 'invalid program id: notanaddress: String is the wrong size'
            Invalid slot:
              value:
                error: 'invalid activation slot: abc: invalid digit found in string'
    Unauthorized:
      description: The API key is missing or invalid. The body is plain text.
      content:
        text/plain:
          schema:
            type: string
          examples:
            default:
              value: Unauthorized
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.