TrueLayer API calls can be made both in a Synchronous and Asynchronous way.
Advantages of Async
- Async is in general preferred as it mitigates issues that are beyond the control of TrueLayer.
- TrueLayer automatically implements a retry mechanism for Asynchronous calls, so would remove the need for you to write your own error and retry logic.
- The Data API supports asynchronous requests on all endpoints.
Please note that the
/tokenendpoint cannot be implemented Asynchronously.
Performing an Async request
- Pass a query parameter
results_uriparameter that will contain the results of your request once they are available.
- After making an asynchronous API call, you can poll the
results_uriand wait for completion.
To avoid polling, you can pass a
webhook_uri parameter to receive real-time notification via
HTTP POST (Webhook) when the request is completed.
Please note that even if
webhook_uri is passed the results will not be part of the
HTTP POST payload but must be fetched at
When the results are ready, they will be available to fetch at the
The query will return one of the following
|Queued||The query is waiting to run|
|Running||The query is currently running|
|Succeeded||The query has successfully returned results|
|Failed||The query is has failed to retrieve the query results|
Therefore, a good practice would be to query for the Status of the request and only fetch the results only in case of a Successful status.
Check our API Reference for API requests examples.