3 ways to reduce your API spend with smarter calls
Get more value from your API plan
Using APIs to add location intelligence to your forms can be an effective way to increase customer engagement, collect accurate address data and maximise your revenue. However, if you’re not smart about how you use APIs, you can quickly chew through your credits.
And with organisations around the country tightening their budgets, naturally everyone is looking to get more value out of their investments.
The good news is there are several features included in Predictive API and Addresses API to help you reduce the amount of calls you need. Here are three ways to be smarter with your code and get more value from your address verification API usage.
1. Use Predictive API debounce
When using Predictive API, the common but inefficient way to implement it is by calling the API after every keystroke. But that will mean you quickly burn through your transaction credits.
Make smarter use of your API calls by implementing a debounce.
Debounce detects when the user pauses their typing and then calls the API with their total input. This saves you the cost of unnecessary calls.
It makes sense to delay until the user has paused, rather than calling after each keystroke. Generally, users don’t look at the screen while typing, so displaying results they won’t see is a waste of time – and money. In addition, only calling once they’ve paused will return a more accurate result, since they’ve typed more in to narrow down the selection.
Using debounce also speeds up the performance of your webpage by reducing the number of API calls you make. And importantly, it saves you money on the number of calls to the API.
See more at GitHub.
2. ‘Include’ parameter
Another way to reduce the number of calls you make to both the Predictive API and Addresses API – and therefore how much it will cost you – is to make smart use of the ‘include’ parameter.
The ‘include’ parameter specifies what information you want returned from the API. You can just ask for basic information, like the geocode. But you can also ask for more advanced data, like the ABS remoteness index, which tells you if the user is in a major metropolitan centre or a regional town.
If you need more than one type of information returned, the smart way is to set ‘include’ to return ‘all’. This will return everything known about the address in one call.
The ‘include all’ parameter saves you money since you only require one call to the API to get all the information you need.
3. Response headers
Keeping an eye on how much your API is costing you is a good way to take control of your spending.
Your API subscription plan allows you a certain number of transactions per month. The type of API call you make determines how many transactions it costs.
To help you keep track of your balance, each API call returns the cost of the transaction in the ‘x-attr-basicTransaction’ response header. This can help you optimise your code to save you money.
Code smarter to save money
Reducing the number of times you call your address validation APIs will save you money. You can do this by coding smarter – using debounce and the include ‘all’ parameter, and by tracking your spend from information supplied in the response header.
Want more advice about getting the most out of your API subscription? Contact our helpful support team at email@example.com.