> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# Getting Started

This guide walks you through authenticating with the Trade API and making your first request. By the end, you'll have a working access token and a confirmed connection to the API.

## What You Need

* **A NinjaTrader account** with a username and password.
* **API credentials**: a client ID (`cid`) and secret (`sec`) issued by NinjaTrader. Keep your `sec` out of public repositories and client-side code.
* **A device identifier**: a string of up to 64 characters that permanently identifies the device making requests. You can generate one with a package like [DeviceId](https://github.com/MatthewKing/DeviceId) for C# or [device-uuid](https://www.npmjs.com/package/device-uuid) for JavaScript.

All examples on this page use the Demo environment (`demo.tradovateapi.com`). Swap in `live.tradovateapi.com` when you're ready for Live trading.

#### Get an access token

Exchange your credentials for an access token by calling `accessTokenRequest`:

```bash title="cURL"
curl -X POST https://demo.tradovateapi.com/v1/auth/accesstokenrequest \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
        "name": "<your username>",
        "password": "<your password>",
        "appId": "Sample App",
        "appVersion": "1.0",
        "cid": 8,
        "sec": "f03741b6-f634-48d6-9308-c8fb871150c2",
        "deviceId": "123e4567-e89b-12d3-a456-426614174000"
      }'
```

A successful response includes your access token and its expiration time:

```json
{
    "accessToken": "<your access token>",
    "mdAccessToken": "<your market data access token>",
    "expirationTime": "2021-06-15T15:40:30.056Z",
    "userStatus": "Active",
    "userId": 15460,
    "name": "example-user",
    "hasLive": true,
    "outdatedTaC": false,
    "hasFunded": true,
    "hasMarketData": true,
    "outdatedLiquidationPolicy": false
}
```

Save your `accessToken` for REST requests and WebSocket connections to the trading API. If you plan to use the [Market Data API](/market-data), save the `mdAccessToken` as well.

Tokens last about 90 minutes. To keep a long-running application connected, call `renewAccessToken` before the token expires rather than requesting a new one. See [Authentication & Access](/api/authentication) for the full token lifecycle, session limits, and two-factor authentication details.

#### Make your first call

Confirm your token works by listing your accounts. Send it as a `Bearer` value in the `Authorization` header:

```bash title="cURL"
curl -X GET 'https://demo.tradovateapi.com/v1/account/list' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <your access token>'
```

A successful response returns an array of your accounts with their IDs, names, and account details. If you get an `HTTP 401` response, your token may be expired or incorrectly formatted.

#### Explore the API

With a working token, you're ready to build. A few common starting points:

* **Place an order.** Call `order/placeorder` to submit a trade.
* **Check your positions.** Call `position/list` to see your open positions.
* **Stream real-time updates.** Open a [WebSocket connection](/api/websockets) to receive order and position events in real time without polling.

Browse the [REST API Endpoints](/api/rest-api-endpoints) for the full list of available operations, or read [API Conventions](/api/conventions) for query and submission patterns.

## Next Steps

* Review [Authentication & Access](/api/authentication) for session limits, token renewal, and two-factor authentication.
* If your application authenticates other users, see [OAuth Integration](/api/oauth) to delegate authentication to NinjaTrader.
* Read [API Conventions](/api/conventions) to understand how the API structures queries and submissions.
* Connect to the [WebSocket](/api/websockets) for real-time order and position updates.
* Use the [Market Data API](/market-data) for real-time quotes, depth of market, and charts.