Skip to main content
GET
/
api
/
:projectId
/
types
Project Types
curl --request GET \
  --url https://api.example.com/api/:projectId/types
{
  "projectId": "<string>",
  "programName": "<string>",
  "types": [
    {
      "name": "<string>",
      "kind": "<string>",
      "fields": [
        {
          "name": "<string>",
          "type": "<string>"
        }
      ]
    }
  ],
  "Type Resolution Examples": {}
}

Overview

Custom types (also called “defined types”) are reusable data structures defined in Anchor programs. They can be used as instruction arguments, account fields, or nested within other types. This endpoint returns all type definitions from the program’s IDL.

Get Program Types

GET /api/:projectId/types
Retrieve all custom type definitions from the program’s IDL with full field resolution.

Path Parameters

projectId
string
required
The unique identifier of the project

Response

projectId
string
The project identifier
programName
string
Name of the Anchor program from the IDL
types
array
List of type definitions

Example Request

curl -X GET "https://api.orquestra.so/api/proj_abc123/types"

Example Response

{
  "projectId": "proj_abc123",
  "programName": "token_swap",
  "types": [
    {
      "name": "PoolConfig",
      "kind": "struct",
      "fields": [
        {
          "name": "minLiquidity",
          "type": "u64"
        },
        {
          "name": "maxSlippage",
          "type": "u16"
        },
        {
          "name": "enableOracle",
          "type": "bool"
        },
        {
          "name": "oracleAddress",
          "type": "option<publicKey>"
        }
      ]
    },
    {
      "name": "SwapDirection",
      "kind": "enum",
      "fields": [
        {
          "name": "AToB",
          "type": "unit"
        },
        {
          "name": "BToA",
          "type": "unit"
        }
      ]
    },
    {
      "name": "PriceOracle",
      "kind": "struct",
      "fields": [
        {
          "name": "address",
          "type": "publicKey"
        },
        {
          "name": "lastPrice",
          "type": "u64"
        },
        {
          "name": "lastUpdated",
          "type": "i64"
        },
        {
          "name": "confidence",
          "type": "u64"
        }
      ]
    },
    {
      "name": "LiquidityOperation",
      "kind": "enum",
      "fields": [
        {
          "name": "Deposit",
          "type": "{ amountA: u64, amountB: u64 }"
        },
        {
          "name": "Withdraw",
          "type": "{ liquidity: u64 }"
        }
      ]
    },
    {
      "name": "FeeStructure",
      "kind": "struct",
      "fields": [
        {
          "name": "tradeFee",
          "type": "u16"
        },
        {
          "name": "protocolFee",
          "type": "u16"
        },
        {
          "name": "lpFee",
          "type": "u16"
        }
      ]
    },
    {
      "name": "TradeHistory",
      "kind": "struct",
      "fields": [
        {
          "name": "user",
          "type": "publicKey"
        },
        {
          "name": "timestamp",
          "type": "i64"
        },
        {
          "name": "direction",
          "type": "SwapDirection"
        },
        {
          "name": "amountIn",
          "type": "u64"
        },
        {
          "name": "amountOut",
          "type": "u64"
        }
      ]
    }
  ]
}

Understanding Type Definitions

Struct Types

Structs are composite types with named fields. They’re similar to objects in JavaScript or structs in Rust.
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct PoolConfig {
    pub min_liquidity: u64,
    pub max_slippage: u16,
    pub enable_oracle: bool,
    pub oracle_address: Option<Pubkey>,
}

Enum Types

Enums represent a choice between multiple variants. Variants can be unit types (no data) or contain associated data.
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub enum SwapDirection {
    AToB,
    BToA,
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub enum LiquidityOperation {
    Deposit { amount_a: u64, amount_b: u64 },
    Withdraw { liquidity: u64 },
}

Type Resolution

Orquestra automatically resolves complex and nested types into readable string representations:
Type Resolution Examples
table
IDL TypeResolved String
{ "defined": "PoolConfig" }PoolConfig
{ "option": "publicKey" }option<publicKey>
{ "vec": "u8" }vec<u8>
{ "array": ["u8", 32] }[u8; 32]
"publicKey"publicKey
"u64"u64
"string"string

Using Types in Instructions

Custom types can be used as instruction arguments:
const config = {
  minLiquidity: 1000000n,
  maxSlippage: 100,
  enableOracle: false,
  oracleAddress: null
};

const feeStructure = {
  tradeFee: 30,      // 0.3%
  protocolFee: 5,    // 0.05%
  lpFee: 25          // 0.25%
};

await program.methods
  .initializePool(config, feeStructure)
  .accounts({
    pool: poolPda,
    authority: wallet.publicKey,
    // ...
  })
  .rpc();

Nested and Recursive Types

Types can reference other custom types, creating nested structures:
Nested Type Example
{
  "name": "PoolState",
  "kind": "struct",
  "fields": [
    {
      "name": "config",
      "type": "PoolConfig"
    },
    {
      "name": "fees",
      "type": "FeeStructure"
    },
    {
      "name": "oracle",
      "type": "option<PriceOracle>"
    },
    {
      "name": "recentTrades",
      "type": "vec<TradeHistory>"
    }
  ]
}

Error Responses

{
  "error": "Project not found or not public"
}
The specified project ID does not exist, is private, or has no IDL uploaded.
{
  "error": "Failed to get types"
}
The server encountered an error processing the request.

Notes

No authentication required - This endpoint is public for all public projects.
Use this endpoint to generate TypeScript type definitions for your frontend client. The type information can be used to create strongly-typed interfaces.
Types are resolved recursively. If a type references another custom type (e.g., PoolConfig contains a FeeStructure), you’ll see the type name, and you can look up the referenced type in the same response.
Some programs may have no custom types defined (empty array). These programs use only primitive types (u64, bool, publicKey, etc.) in their instructions and accounts.

Build docs developers (and LLMs) love