1. Development and testing
- Use a Delayed Application Key first. Start with the Delayed Application Key for initial development and functional testing.
- Model and test with historical data. Use Betfair Historical Data for strategy modelling and analysis.
- Request Live access only when ready. Apply for Live Application Key access only when you are ready to transact on the Exchange.
- Understand key types. See the Personal Betting Access Overview for the difference between Delayed and Live Application Keys.
2. Login and session management
- Create and maintain one session. Use Login to create a session and Keep Alive to extend it where permitted.
- Reuse sessions. Use one session across multiple API calls or threads. Do not log in for every API call.
- Check session duration rules. Sessions last up to 24 hours by default, but maximum length varies by country. See the Keep Alive guidance.
- Recover cleanly from expired sessions. Handle INVALID_SESSION_TOKEN by creating a new session via API login.
- Avoid login limit blocks. If you exceed login limits, new login requests are blocked for 20 minutes. Existing sessions remain valid.
3. General best practices
- Minimise transactions. Make the fewest transactions and changes needed. See Transaction Charges.
- Stay within data limits. Observe Market Data Limits for listMarketCatalogue, listRunnerBook, listMarketBook and listMarketProfitandLoss.
- Protect queue position. Prefer leaving an order in place instead of cancelling and replacing it.
- Use streaming for frequent updates. Use the Stream API instead of polling wherever possible, especially for high-frequency trading.
- Log useful diagnostics. Capture enough detail to support investigations, including the Stream API connectionId.
- Use betting enhancements where appropriate. Review available betting enhancements.
4. Check API status before troubleshooting
Before contacting Developer Support, check the API status page: http://status.developer.betfair.com.
The status page measures response latency and error rates every second, then updates automatically when thresholds are breached.
5. Avoid the Expect: 100-Continue header
Do not send this header. It can return: "The remote server returned an error: (417) Expectation Failed."
For .NET Framework, prevent the header being added with:
System.Net.ServicePointManager.Expect100Continue = false; |
6. Enable HTTP compression
Enable HTTP compression to reduce response size and improve performance. Send this request header with all Betfair API requests:
Accept-Encoding: gzip, deflate |
Some environments also require you to explicitly decompress the response.
HTTP persistent connections
Set Connection: keep-alive on requests to reduce latency. Idle keep-alive connections to API endpoints close every 3 minutes.
Long-lived connections are encouraged, especially for the Stream API, but they may still close unexpectedly. Add reconnection logic to handle connection termination.
Other performance tips
For more HTTP client performance guidance, see Apache performance tuning.
Comments
0 comments
Article is closed for comments.