Skip to main content

projectx-api

PyPI - Version PyPI - Downloads

projectx-api is an async Python SDK for the ProjectX Gateway API. It allows programmatic access to accounts, orders, positions, market data, and more.


📦 Installation

pip install projectx-api

🚀 Features

  • ✅ Async HTTP client powered by httpx
  • ✅ Supports all endpoints described in the documentation
  • ✅ Supports both API key and application-based authentication
  • ✅ Automatic session revalidation (24h token auto-refresh)
  • 🚧 WebSocket support (Realtime Updates) coming soon

🔧 Usage Example

import asyncio
from projectx_api import ProjectXClient, Environment, LoginKeyCredentials, OrderSide, OrderType

async def main():
    client = ProjectXClient(Environment.TOPSTEP_X)
    await client.login(
        LoginKeyCredentials(userName="test", apiKey="test")
    )
    
    accounts = await client.search_for_account()
    print("Accounts:", accounts)
    accountId = accounts[0]["id"]
    
    orders = await client.search_for_open_orders(accountId=accountId)
    print("Open orders:", orders)
    
    positions = await client.search_for_positions(accountId=accountId)
    print("Positions:", positions)
    
    contracts = await client.search_for_contracts(searchText="NQ", live=True)
    print("Contracts:", contracts)
    contractId = contracts[0]["id"]
    
    result = await client.place_order(
        accountId=accountId,
        contractId=contractId,
        type=OrderType.LIMIT,
        side=OrderSide.BUY,
        size=1,
        limitPrice=2000,
    )
    print("Place Order", result)
    orderId = result["orderId"]
    
    result = await client.cancel_order(accountId=accountId, orderId=orderId)
    print("Cancel Order", result)
    
    await client.logout()

asyncio.run(main())

🌍 Supported Environments

You can see the supported environments here

📄 License

This project is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for projectx-api 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for projectx-api 0.1.0
File Size Uploaded
projectx_api-0.1.0.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for projectx-api 0.1.0
File Interpreter ABI Platform
projectx_api-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / projectx_api-0.1.0.tar.gz

Download URL projectx_api-0.1.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
92be9755c74539c77775401c5312cb2e37c86e9e951e1397632a21dd4abe0dae
BLAKE2b-256 checksum
How to use checksums
a44e9d9ac30f6a89a20ab36a92a61e698f03b58db89f1e114c979db6b6ab4fe0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / projectx_api-0.1.0-py3-none-any.whl

Download URL projectx_api-0.1.0-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ca59aa2e8d75bf0677b578b4e192d8d1b71a03eb88c659c8b475687abd01ba0
BLAKE2b-256 checksum
How to use checksums
e70017509e4a91a603763b9265b3d4aced3ae87f0847e9bb2a91ced4caabbbe4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page