plaid-node
plaid-node copied to clipboard
Force transactions_sync endpoint to return historical data.
From the documentation
In the first call to /transactions/sync for an Item, the endpoint will return all historical transactions data associated with that Item up until the time of the API call (as "adds"), which then generates a next_cursor for that Item. In subsequent calls, send the next_cursor to receive only the changes that have occurred since the previous call.
However when I call transactions sync for the first time (with next_cursor not present) after linking the accounts I receive INITIAL_UPDATE_COMPLETE and only 30 days of transactions.
Is there a way to force the endpoint to return historical transactions when first linking to the account? I would like to avoid using webhooks if neccessary.
There is not a way to keep the initial transaction pull from being broken into two parts (historical and initial). If you don't want to wait for the webhook, I suppose you could just wait for a few minutes before calling the sync endpoint to have really good odds that the fetch is complete, or alternatively you could poll /transactions/sync on the item, watch the transactions_update_status field, wait for it to update toHISTORICAL_UPDATE_COMPLETE, and then re-call /transactions/sync on that item with a null cursor to get all the transactions from the beginning. However, we strongly encourage you to implement webhooks, since they are pretty core to how Plaid handles async behaviors, and the Plaid API has a lot of async behaviors, especially when using the transactions endpoints.
Thanks for your reply... I cant seem to find in the documentation how/where to declare the webhook url programmatically for transactions. It seems as though I need to proceed with webhook approach.
Its unfortunate that historical data is not readily available. Even with a debounce + poll it still returns initial.
The webhook url is set when calling /link/token/create: https://plaid.com/docs/api/tokens/#link-token-create-request-webhook
If you are not getting historical data ever, I suggest you:
- Make sure you are setting
days_requestedcorrectly https://plaid.com/docs/api/tokens/#link-token-create-request-transactions-days-requested - Try waiting ~10 minutes before calling the sync endpoint for the first time (if this fixes the issue there's probably a problem in your code regarding how you're handling cursors...see my note about polling the sync endpoint to watch for updates to the
transactions_update_statusfield and then calling with anullcursor after it updates) - Try linking a different account to rule out issues with your specific bank
Closing this out as it's not related to the node client library -- if you continue to have trouble, feel free to file a support ticket