topstepx-api

Use when building TopStepX integrations, connecting to the TopStepX or ProjectX Gateway API, creating trading bots for TopStepX, placing orders, streaming real-time market data via SignalR, or any mention of TopStepX/ProjectX in a trading API context. Provides complete REST and WebSocket API reference for generating correct integration code in any programming language.

12 stars

Best use case

topstepx-api is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use when building TopStepX integrations, connecting to the TopStepX or ProjectX Gateway API, creating trading bots for TopStepX, placing orders, streaming real-time market data via SignalR, or any mention of TopStepX/ProjectX in a trading API context. Provides complete REST and WebSocket API reference for generating correct integration code in any programming language.

Teams using topstepx-api should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/topstepx-api/SKILL.md --create-dirs "https://raw.githubusercontent.com/mizu-trading/topstepx-dev/main/skills/topstepx-api/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/topstepx-api/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How topstepx-api Compares

Feature / Agenttopstepx-apiStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use when building TopStepX integrations, connecting to the TopStepX or ProjectX Gateway API, creating trading bots for TopStepX, placing orders, streaming real-time market data via SignalR, or any mention of TopStepX/ProjectX in a trading API context. Provides complete REST and WebSocket API reference for generating correct integration code in any programming language.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# TopStepX (ProjectX Gateway) API

ProjectX Trading, LLC offers a complete trading platform API for prop firms and evaluation providers. The API uses REST for operations and SignalR WebSockets for real-time streaming.

## Connection URLs

| Service        | URL                                        |
|----------------|--------------------------------------------|
| REST API       | `https://api.topstepx.com`                 |
| User Hub (WS)  | `https://rtc.topstepx.com/hubs/user`       |
| Market Hub (WS) | `https://rtc.topstepx.com/hubs/market`     |

## Rate Limits

| Endpoint                          | Limit                    |
|-----------------------------------|--------------------------|
| `POST /api/History/retrieveBars`  | 50 requests / 30 seconds |
| All other endpoints               | 200 requests / 60 seconds |

Exceeding limits returns HTTP 429. Implement backoff and retry logic.

## Authentication

All requests require a JWT Bearer token. Tokens are valid for 24 hours.

### API Key Login (recommended for bots)

```
POST /api/Auth/loginKey
Body: { "userName": "string", "apiKey": "string" }
Response: { "token": "jwt_here", "success": true, "errorCode": 0, "errorMessage": null }
```

### Application Login

```
POST /api/Auth/loginApp
Body: { "userName": "...", "password": "...", "deviceId": "...", "appId": "...", "verifyKey": "..." }
Response: { "token": "jwt_here", "success": true, "errorCode": 0, "errorMessage": null }
```

### Session Validation / Token Refresh

```
POST /api/Auth/validate
Header: Authorization: Bearer <token>
Response: { "success": true, "newToken": "refreshed_jwt", "errorCode": 0 }
```

### Using the Token

Include the token as a Bearer token in the Authorization header for all REST requests:
```
Authorization: Bearer <token>
```

For WebSocket hubs, pass the token as a query parameter:
```
https://rtc.topstepx.com/hubs/user?access_token=<token>
```

## Standard Response Format

Every REST endpoint returns this structure:

```json
{
  "success": true,
  "errorCode": 0,
  "errorMessage": null,
  "<dataField>": ...
}
```

Always check `success` before processing data. On failure, `errorCode` and `errorMessage` describe the issue.

## REST API Endpoints

All endpoints use POST method with JSON request bodies.

### Account

| Endpoint                | Purpose                    | Key Params                  |
|-------------------------|----------------------------|-----------------------------|
| `/api/Account/search`   | List accounts              | `onlyActiveAccounts`: bool  |

### Contract / Market Data

| Endpoint                     | Purpose                    | Key Params                          |
|------------------------------|----------------------------|-------------------------------------|
| `/api/Contract/available`    | List available contracts   | `live`: bool                        |
| `/api/Contract/search`       | Search contracts by name   | `searchText`: string, `live`: bool  |
| `/api/Contract/searchById`   | Get contract by ID         | `contractId`: string                |
| `/api/History/retrieveBars`  | Historical OHLCV bars      | `contractId`, `live`, `startTime`, `endTime`, `unit`, `unitNumber`, `limit`, `includePartialBar` |

**Bar unit values:** 1=Second, 2=Minute, 3=Hour, 4=Day, 5=Week, 6=Month

### Orders

| Endpoint                  | Purpose              | Key Params                                      |
|---------------------------|----------------------|-------------------------------------------------|
| `/api/Order/place`        | Place new order      | `accountId`, `contractId`, `type`, `side`, `size`, optional: `limitPrice`, `stopPrice`, `trailPrice`, `customTag`, `stopLossBracket`, `takeProfitBracket` |
| `/api/Order/search`       | Search order history | `accountId`, `startTimestamp`, optional: `endTimestamp` |
| `/api/Order/searchOpen`   | Get open orders      | `accountId`                                     |
| `/api/Order/cancel`       | Cancel order         | `accountId`, `orderId`                          |
| `/api/Order/modify`       | Modify order         | `accountId`, `orderId`, optional: `size`, `limitPrice`, `stopPrice`, `trailPrice` |

**Bracket objects** (`stopLossBracket` / `takeProfitBracket`): `{ "ticks": int, "type": OrderType }`

### Positions

| Endpoint                              | Purpose               | Key Params                          |
|---------------------------------------|------------------------|-------------------------------------|
| `/api/Position/searchOpen`            | Get open positions     | `accountId`                         |
| `/api/Position/closeContract`         | Close entire position  | `accountId`, `contractId`           |
| `/api/Position/partialCloseContract`  | Partial close          | `accountId`, `contractId`, `size`   |

### Trades

| Endpoint              | Purpose             | Key Params                                      |
|-----------------------|---------------------|-------------------------------------------------|
| `/api/Trade/search`   | Search trade history | `accountId`, `startTimestamp`, optional: `endTimestamp` |

A `null` value for `profitAndLoss` on a trade indicates a half-turn trade.

## Enums Quick Reference

| Enum          | Values                                                              |
|---------------|---------------------------------------------------------------------|
| OrderSide     | 0=Bid (buy), 1=Ask (sell)                                          |
| OrderType     | 0=Unknown, 1=Limit, 2=Market, 3=StopLimit, 4=Stop, 5=TrailingStop, 6=JoinBid, 7=JoinAsk |
| OrderStatus   | 0=None, 1=Open, 2=Filled, 3=Cancelled, 4=Expired, 5=Rejected, 6=Pending |
| PositionType  | 0=Undefined, 1=Long, 2=Short                                      |
| DomType       | 0=Unknown, 1=Ask, 2=Bid, 3=BestAsk, 4=BestBid, 5=Trade, 6=Reset, 7=Low, 8=High, 9=NewBestBid, 10=NewBestAsk, 11=Fill |
| TradeLogType  | 0=Buy, 1=Sell                                                      |

## Real-Time Data (SignalR WebSockets)

The API uses SignalR over WebSocket for streaming. Two hubs are available:

### User Hub (`/hubs/user`)

Subscribe/unsubscribe methods:
- `SubscribeAccounts()` / `UnsubscribeAccounts()` - account balance updates
- `SubscribeOrders(accountId)` / `UnsubscribeOrders(accountId)` - order status changes
- `SubscribePositions(accountId)` / `UnsubscribePositions(accountId)` - position updates
- `SubscribeTrades(accountId)` / `UnsubscribeTrades(accountId)` - trade executions

Events: `GatewayUserAccount`, `GatewayUserOrder`, `GatewayUserPosition`, `GatewayUserTrade`

### Market Hub (`/hubs/market`)

Subscribe/unsubscribe methods:
- `SubscribeContractQuotes(contractId)` / `UnsubscribeContractQuotes(contractId)` - quote updates
- `SubscribeContractTrades(contractId)` / `UnsubscribeContractTrades(contractId)` - market trades
- `SubscribeContractMarketDepth(contractId)` / `UnsubscribeContractMarketDepth(contractId)` - DOM/L2 data

Events: `GatewayQuote(contractId, data)`, `GatewayTrade(contractId, data)`, `GatewayDepth(contractId, data)`

### SignalR Connection Pattern

Connect with WebSocket transport, skip negotiation, enable auto-reconnect. Re-subscribe to all channels on reconnection. Pass JWT via `access_token` query parameter AND `accessTokenFactory`.

## Language-Agnostic Implementation Guidance

When generating code for any language:

1. **Authentication**: Implement token storage, 24h expiry tracking, and automatic refresh via `/api/Auth/validate`.
2. **HTTP client**: All REST calls are POST with JSON bodies. Set `Content-Type: application/json` and `Authorization: Bearer <token>`.
3. **Error handling**: Always check `success` field. Handle HTTP 429 with exponential backoff.
4. **SignalR**: Use the official SignalR client for the target language. Configure WebSocket-only transport with `skipNegotiation: true`. Always re-subscribe on reconnect.
5. **Contract IDs**: Format is `CON.F.US.<symbol>.<expiry>` (e.g., `CON.F.US.ENQ.U25`).
6. **Timestamps**: Use ISO 8601 format with timezone (`2024-12-01T00:00:00Z`).

## Additional Resources

### Reference Files

For detailed endpoint specifications with full request/response examples, consult:
- **`references/rest-api.md`** - Complete REST endpoint documentation with request bodies and response schemas
- **`references/realtime.md`** - SignalR connection examples, event payload schemas, and language-specific patterns
- **`references/enums.md`** - Full enum definitions with descriptions and usage context

Related Skills

swe-cli-skills

12
from SylphAI-Inc/skills

Senior engineer CLI expertise for AI agents — workflows, safety guardrails, gotchas, and anti-patterns across cloud, IaC, containers, databases, dev tools, and platforms

DevOps & Infrastructure

PicoClaw Fleet

11
from EricGrill/agents-skills-plugins

Orchestrate a fleet of remote PicoClaw workers over SSH for fast, ephemeral one-shot tasks.

DevOps & Infrastructure

VibeCollab — Setup Instructions for AI Assistants

9
from flashpoint493/VibeCollab

You are helping a user set up VibeCollab in their project.

Workflow & Productivity

raycast-extension-docs

9
from lemikeone/Codex-skill-raycast-extension

Guidance for building, debugging, and publishing Raycast extensions using the Raycast documentation set. Use when Codex needs to create or modify Raycast extensions (React/TypeScript/Node), consult Raycast API reference or UI components, build AI extensions, handle manifest/lifecycle/preferences, troubleshoot issues, or prepare/publish extensions to the Raycast Store or Teams.

Coding & Development

evomap

9
from hyz0906/paper

Connect to the EvoMap collaborative evolution marketplace. Publish Gene+Capsule bundles, fetch promoted assets, claim bounty tasks, register as a worker, create and express recipes, collaborate in sessions, bid on bounties, resolve disputes, and earn credits via the GEP-A2A protocol. Use when the user mentions EvoMap, evolution assets, A2A protocol, capsule publishing, agent marketplace, worker pool, recipe, organism, session collaboration, or service marketplace.

AI Agent Marketplace

maestro

8
from Viniciuscarvalho/maestro

Intelligent skill knowledge gateway. Routes tasks to the right knowledge without loading all skills into context. MUST be consulted before any coding task — call the search_skills MCP tool to retrieve relevant expertise from 100+ indexed skills covering Swift, SwiftUI, concurrency, testing, architecture, performance, and security.

Coding & Development

opentui

7
from LeonardoTrapani/better-skills

Comprehensive OpenTUI skill for building terminal user interfaces. Covers the core imperative API, React reconciler, and Solid reconciler. Use for any TUI development task including components, layout, keyboard handling, animations, and testing.

Coding & Development

calm-ui

7
from brijr/vibe

Apply a restrained, Swiss/Japanese/Scandinavian/German-influenced product design system when building or refining UI in React, Next.js, TypeScript, and shadcn/ui. Use when the user asks to build, refine, critique, redesign, or review a page, screen, component, form, table, dashboard, layout, or other frontend interface, especially in projects using shadcn/ui. Do not use for marketing sites, landing pages, non-UI work, or requests for bold, playful, maximalist, or otherwise expressive aesthetics.

Frontend Development

solid

7
from fellipeutaka/denji

Apply SOLID principles to write flexible, maintainable, and testable code. Use when designing classes, interfaces, and module boundaries. Covers Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion with practical TypeScript examples and detection heuristics.

netops-asset-manager

7
from Boos4721/netops-asset-manager-skill

Manage IT infrastructure assets (routers, switches, servers, GPU clusters) through a Go + Vue 3 platform with real-time health probing, SSH remote control, configuration backup, bulk import, network topology visualization, and PM2 process management. Supports H3C, Huawei, Cisco, MikroTik, Ruijie, DCN, and Linux. Use when the user asks about IT asset management, network device operations, infrastructure monitoring, SSH device control, or development on this Go + Vue 3 platform.

Goal: Build an LLM-based RAG App

6
from Harmeet10000/skills

Here is the MVP Implementation Plan.

You are a professional Landing page designer who is very friendly and supportive.

6
from Harmeet10000/skills

Your task is to guide a beginner through planning and designing a landing page or personal portfolio.

Workflow & Productivity