Optimising API Performance

Optimising API Performance

Top ↑


Below you'll find a variety of ways that you can optimise your API code. by optimising the API's performance you will avoid slowing down your internal systems and BrandMail account.

Minimise method calls.

The following practices suggest ways to minimise method calls so you can transfer the least amount of data possible.

  1. Search for the specific records you need before performing a method that transfers data. (Note: Search using the last_modified_time field to only retrieve the records that have changed since the last update.)

  2. Avoid using the API to poll your data several times a minute for real-time updates. Since most statistics are not updated that often, this unnecessarily slows down your system. Create a schedule for finding and adding updates that balances system efficiency with your customers' expectations.

    If the amount of data you usually transfer affects your system's performance, consider running a batch job that retrieves statistics once a day.

  3. Set Up Redundancy Models - Server connection failures often occur because the server is down, so repeated access attempts waste resources. Set connection reattempts to a minimal number of times, and configure your system to send the request again in 30 minutes or an hour.

  4. Cache data returned by an API method if you plan to use it in additional API calls. This enables you to specify a List of Contacts with a single method call rather than calling the method for each Contact.

Perform error checking after each method call.

Method calls may be unsuccessful for a variety of reasons. For example, the connection may have failed, or the system may be in read-only mode. At times, the API may be unavailable due to maintenance. Use the following best practices for addressing failed method calls:

  • Design the API application to gracefully handle any errors and to attempt to recover from them where possible.
  • Log application activity and any error messages returned by the API to aid in debugging.


JSON-RPC response is faster and requires fewer resources than decoding the equivalent XML-RPC response. If possible, use JSON-RPC to make method calls.

Use a packet analyser tool to troubleshoot API issues.

Use a packet analyser tool such as Wireshark or Fiddler to troubleshoot communications between your application and the API.

See Also