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/token
endpoint cannot be implemented Asynchronously.
Performing an Async request
- Pass a query parameter
async=true
and aresults_uri
parameter that will contain the results of your request once they are available. - After making an asynchronous API call, you can poll the
results_uri
and 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 results_uri
.
When the results are ready, they will be available to fetch at the results_uri
.
The query will return one of the following status
messages:
STATUS | DESCRIPTION |
---|---|
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.
Comments
0 comments
Please sign in to leave a comment.