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

# API

> REST and GraphQL API reference — endpoints, authentication, and data access

Railnet provides a GraphQL API for querying portfolio data, positions, transaction history, and protocol state. Use this API to build dashboards, generate reports, and monitor your Multi-Vehicle operations.

## GraphQL endpoint

```
https://query.railnet-testnet.defi.testnet.kiln.fi/v1/graphql
```

<Note>
  This is the **testnet** endpoint. The mainnet endpoint will be provided when available.
</Note>

## Available data

The GraphQL API exposes data indexed from on-chain events, including:

* **Multi-Vehicle positions** — current allocations across sub-vehicles
* **Query lifecycle** — track deposit and redeem queries through STEAM states
* **Fee accrual** — accumulated fees and distribution history
* **Sector accounting** — asset balances across sectors
* **Keeper jobs** — automation status and execution history

## Example queries

### Query Multi-Vehicle positions

```graphql theme={null}
query GetMultiVehiclePositions($address: String!) {
  multiVehicle(where: { address: { _eq: $address } }) {
    address
    totalAssets
    totalSupply
    vehicles {
      vehicleAddress
      totalAssets
      sector
    }
  }
}
```

### Query STEAM query state

```graphql theme={null}
query GetQueryState($queryId: String!) {
  steamQuery(where: { id: { _eq: $queryId } }) {
    id
    state
    mode
    owner
    receiver
    inputAssets {
      asset
      value
    }
    outputAssets {
      asset
      value
    }
    createdAt
    updatedAt
  }
}
```

### Query keeper job status

```graphql theme={null}
query GetKeeperJobs($multiVehicle: String!) {
  keeperJobs(where: { target: { _eq: $multiVehicle } }) {
    jobId
    status
    lastExecutedAt
    executionCount
  }
}
```

<Note>
  Full schema documentation is coming soon. Use GraphQL introspection to explore available types and fields:

  ```graphql theme={null}
  {
    __schema {
      types {
        name
        fields {
          name
          type { name }
        }
      }
    }
  }
  ```
</Note>

## Integration patterns

### Polling

Query the API at regular intervals to update your platform's view of positions and state.

```typescript theme={null}
const ENDPOINT = "https://query.railnet-testnet.defi.testnet.kiln.fi/v1/graphql";

async function getPositions(multiVehicleAddress: string) {
  const response = await fetch(ENDPOINT, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      query: `
        query ($address: String!) {
          multiVehicle(where: { address: { _eq: $address } }) {
            totalAssets
            totalSupply
            vehicles { vehicleAddress totalAssets }
          }
        }
      `,
      variables: { address: multiVehicleAddress }
    })
  });
  return response.json();
}
```

### Subscriptions

The GraphQL API supports subscriptions for real-time updates on query state changes and other events.

```graphql theme={null}
subscription OnQueryUpdate($owner: String!) {
  steamQuery(where: { owner: { _eq: $owner } }) {
    id
    state
    updatedAt
  }
}
```

## Next steps

<CardGroup cols={2}>
  <Card title="Handle deposits and withdrawals" icon="arrow-right-arrow-left" href="/conduits/deposits-and-withdrawals">
    Process operations through the STEAM lifecycle.
  </Card>

  <Card title="Set up access control" icon="lock" href="/conduits/compliance">
    Configure roles and permissions.
  </Card>
</CardGroup>
