projectx-api
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| projectx_api-0.1.0.tar.gz | 8.6 kB | Without provenance | Details for projectx_api-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| projectx_api-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for projectx_api-0.1.0-py3-none-any.whl |
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
|
Security for projectx-api 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.