LongPort OpenAPI
Access LongPort OpenAPI for diversified and flexible support tailored to your programmatic trading needs. Enhance your trading strategies with ease.
LongPort OpenAPI Documentation
LongPort OpenAPI provides programmatic quote trading interfaces for investors with research and development capabilities and assists them to build trading or quote strategy analysis tools based on their own investment strategies. The functions fall into the following categories:
- Trading - Create, amend, cancel orders, query today's/past orders and transaction details, etc.
- Quotes - Real-time quotes, acquisition of historical quotes, etc.
- Portfolio - Real-time query of the account assets, positions, funds
- Real-time subscription - Provides real-time quotes and push notifications for order status changes
Interface Type
LongPort provides diversified access methods such as HTTP / WebSockets interfaces for accessing the underlying services and SDK (Python / C++, etc.) encapsulated in the upper layer, allowing flexible choices.
How to Enable OpenAPI
-
Log in to the LongPort App to complete the account opening process;
-
Log in to the longportapp.com and enter the developer platform, complete the developer verification (OpenAPI permission application), and obtain a token.
Quote Coverage
Trading
Supported trading functions include:
| Market | Stock and ETF | Warrant & CBBC | Options |
|---|---|---|---|
| HK Market | ✓ | ✓ | |
| US Market | ✓ | ✓ | ✓ |
Rate Limit {#rate-limit}
| Category | Limitation |
|---|---|
| Quote API | One account can only create one long link and subscribe to a maximum of 500 symbols at the same timeNo more than 10 calls in a 1-second interval and the number of concurrent requests should not exceed 5 |
| Trade API | No more than 30 calls in a 30-second interval, and the interval between two calls should not be less than 0.02 seconds |
:::success
The OpenAPI SDK has done effective frequency control internally:
- Quote: The methods under
QuoteContextwill be actively controlled by the SDK according to the server's rate limit. When the request is too fast, the SDK will automatically delay the request. Therefore, you do not need to implement the frequency control details separately. - Trade: The methods under
TradeContextare not limited by the SDK. Due to the special nature of the trading order placement scenario, this is left to the user to handle.
:::
Pricing {#pricing}
LongPort does not charge any additional fees for activating or using interface services. You only need to open a LongPort Integrated A/C and get OpenAPI service permissions to use it for free. For actual transaction fees, please contact the brokerage firm where you have opened your securities account.
Other
The OpenAPI services are provided by LongPort and the applicable affiliates (subject to the agreement). openapi-trade.longportapp.com
SDK
Docs
Socket
- Control commands
- Endpoints
- Subscribe Real-Time Market Data
- Access differences between WebSocket and TCP
- Subscribe Real-Time Trading Data
- Data Commands
Protocol
- Parse Header of Packet
- Parse Request Packet
- Parse Response Packet
- Parse Handshake
- Communication Model
- Parse Push Packet
- Protocol Overview
Qa
Trade
Execution
Asset
Order
- Withdraw Order
- Order Details
- Estimate Maximum Purchase Quantity
- Submit Order
- Get History Order
- Replace Order
- Get Today Order
Quote
Pull
- Option Chain Expiry Date List
- Current Market Temperature
- Basic Information of Securities
- Historical Market Temperature
- Real-time Quotes of Warrant
- Real-time Quotes Of Securities
- Broker IDs
- Security Depth
- Calculate Indexes Of Securities
- Warrant Filter
- Warrant Issuer IDs
- Security Trades
- Security Capital Flow Intraday
- Trading Session of The Day
- Security Candlesticks
- Security Brokers
- Option Chain By Date
- Market Trading Days
- Security Capital Distribution
- Real-time Quotes of Option
- Security Intraday
- Security History Candlesticks
Individual
Subscribe
Security
Push
Automate transactions like real-time eligibility checks and claims processing with developer-friendly, JSON-based APIs that support thousands of payers.
Primev is building mev-commit, a credible commitment network for mev actors.
Dynamic offers a suite of tools for effortless log in, wallet creation and user management. Designed for users. Built for developers.
Mesh enables safer, easier crypto transfers and payments from 300+ leading exchanges and wallets, all without leaving your platform
Earn revenue today without delaying your roadmap. Payment processing for SaaS by SaaS.
FlowX.AI is redefining banking modernization with the first-ever unified, open, AI platform built to free banks from restrictive point solutions.
Markets, illuminated — World's largest provider of trading indicators for every market from stocks, crypto, and forex.