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

# Environments

> API environments, URLs, and configuration for the Tradovate Partner API

The Tradovate Partner API is split into two main environments: **Development** and **Production**. Each environment has two domains: **LIVE** and **DEMO**. Understanding these environments is crucial for building a reliable integration.

## Quick Start

Use this for testing and development:

* **API Base**: `https://demo-api.staging.ninjatrader.dev/v1` (DEMO) or `https://live-api.staging.ninjatrader.dev/v1` (LIVE)
* **WebSocket**: `wss://demo-api.staging.ninjatrader.dev/v1/websocket` or `wss://live-api.staging.ninjatrader.dev/v1/websocket`
* **Client Access**: `https://trader.staging.ninjatrader.dev/` or `https://web.staging.ninjatrader.dev/`

Use this for live operations:

* **API Base**: `https://demo.tradovateapi.com/v1` (DEMO) or `https://live.tradovateapi.com/v1` (LIVE)
* **WebSocket**: `wss://demo.tradovateapi.com/v1/websocket` or `wss://live.tradovateapi.com/v1/websocket`
* **Client Access**: `trader.tradovate.com` or `web.ninjatrader.com`

## Environment Details

### Development Environment

This is your testing environment for API integration and development work. You should use this environment for:

* Testing your integration before going live
* Experimenting with new features
* Debugging issues without affecting real users

### Production Environment

This is your live environment for real client operations and real trading. Only use this environment when:

* You're ready to serve actual customers
* Your integration has been thoroughly tested
* You're confident in your implementation

### Domain Types

Understanding the difference between LIVE and DEMO domains is crucial:

* **LIVE**: This environemnt represents real trading with actual money and positions. Any live accounts you own will show up in this environment.
  This environment must be used to manage certain entities like tradovate subscriptions, market data subscriptions, and user plugins.
* **DEMO**: This represents simulated trading for simulation and evaluation purposes. All of your sim accounts will show up in this environment.

## Client Access Points

Your users will access their accounts through these client applications:

### Development Clients

* **Tradovate**: `https://trader.staging.ninjatrader.dev/`
* **NinjaTrader**: `https://web.staging.ninjatrader.dev/`

These are your development point-of-access for clients. When you create a user, you can test their experience using one of these clients.

### Production Clients

* **Tradovate**: `trader.tradovate.com`
* **NinjaTrader**: `web.ninjatrader.com`

These are your production point-of-access for real clients. When a user signs up, they can access their evaluation accounts via one of these clients, or the Tradovate or NinjaTrader standalone applications. They can also access via the TDV or NT mobile apps.

### Admin Dashboards

* **Development**: `dashboards.staging.ninjatrader.dev`
* **Production**: `dashboards.tradovate.com`

These are the development and production admin dashboards apps, respectively. You'll use these to manage your users and monitor your integration.

## API Base URLs

### Development Environment

* **Development Simulation URL**: `https://demo-api.staging.ninjatrader.dev/v1`
* **Development LIVE URL**: `https://live-api.staging.ninjatrader.dev/v1`

### Production Environment

* **Production Simulation URL**: `https://demo.tradovateapi.com/v1`
* **Production LIVE URL**: `https://live.tradovateapi.com/v1`

## WebSocket URLs

### Real-Time User Data WebSockets

#### Development

* `wss://demo-api.staging.ninjatrader.dev/v1/websocket` OR
* `wss://live-api.staging.ninjatrader.dev/v1/websocket`

Use of live or demo URLs will give real-time updates for their respective environments.

#### Production

* `wss://demo.tradovateapi.com/v1/websocket` OR
* `wss://live.tradovateapi.com/v1/websocket`

### Market Data WebSockets

#### Development

* `wss://md-api.staging.ninjatrader.dev/v1/websocket`

#### Production

* `wss://md.tradovateapi.com/v1/websocket`

### Market Replay WebSockets

#### Development

* `wss://replay.staging.ninjatrader.dev/v1/websocket`

When using a Market Replay Socket, forward all messages (both market data and real-time user data) through the replay socket. Expect all messages from the replay session to come through the replay socket.

#### Production

* `wss://replay.tradovateapi.com/v1/websocket`

## Environment Differences

### LIVE Environment Capabilities

* Change Tradovate Subscription details
* Cancel or renew subscriptions manually
* Immediately expire a subscription
* Change user plugins (such as TradingView)

### SIM Environment Capabilities

* Change sim accounts' permissions
* Adjust sim accounts' max-net liquidities
* Change the Risk Category of a sim account, useful for:
  * Applying a halted-trading category for an individual account
  * Upgrading an account to a new type
  * Changing an account's baseline risk rules
* Halt trading for an entire category (useful to stop all, or specific categories of users from trading in an emergency)
* Return an account to its SOD state at a given date (by session date, not calendar date)

## Best Practices

### Environment Selection

* **Start with Development**: Use the Development environment for all testing and integration work
* **Test thoroughly**: Only move to Production when you're confident in your implementation
* **Use DEMO first**: Test with DEMO domains before using LIVE domains, even in Production

### URL Configuration

* **Store URLs as variables**: Store environment URLs as configuration variables in your application
* **Use environment-specific credentials**: Use different authentication credentials for each environment
* **Handle errors gracefully**: Implement proper error handling for environment-specific responses

### WebSocket Connections

* **Choose the right URL**: Use the appropriate WebSocket URL for your environment and data type
* **Implement reconnection logic**: WebSocket connections can drop, so implement proper reconnection logic
* **Handle environment differences**: Different environments may have different connection requirements

***