Ben Lister
Ben Lister

Reputation: 1

Is it possible to retrive the 'account' associated with a xero bank transaction

I'm using Xero's private API to export bank transactions (so I can automate a bunch of financial reporting).

Retrieving the transactions works well (as documented here https://developer.xero.com/documentation/api/banktransactions) but this endpoint doesn't return the account field associated with each transaction, which I want to use to group the transactions into e.g. "Cost of sale", "Operating expenses" and so on.

Does anyone know of a way to find the account for a given transaction via the API?

Further info:

Upvotes: 0

Views: 281

Answers (1)

Rich
Rich

Reputation: 354

It is the LineItems of Bank Transactions that have AccountCodes associated with them and I've not been able to find a bank transaction record without a line item in the data I have available to me.

Is it possible that you are not implementing paging? From the bank transactions documentation you linked to above:

Paging BankTransactions (recommended)

To utilise paging, append a page parameter to the URL e.g. ?page=1. If there are 100 records in the response you will need to check if there is any more data by fetching the next page e.g ?page=2 and continuing this process until no more results are returned.

By using paging all the line item details for each bank transaction are returned which may avoid the need to retrieve each individual bank transaction.

I'm not familiar with the pyXero implementation, but it looks like they support Xero paging. From the pyXero readme:

# Grab 100 invoices created after 01-01-2013
xero.invoices.filter(since=datetime(2013, 1, 1), page=1)

Upvotes: 1

Related Questions