To export Xero to PostgreSQL, connect Xero to TradieBridge and choose the Postgres export. You
get one .sql file. Load it with psql -v ON_ERROR_STOP=1 -f your-export.sql your_database,
and every Xero record lands in a xero_backup schema, ready to query.
Why Xero data is hard to get into Postgres
Xero’s own exports are reports, one at a time, each a snapshot of one day. The Xero API has all the data, but you must register an app, handle OAuth sign-in, page through each endpoint, stay under the rate limits and decide on a table for every resource. That is weeks of work before you write your first query.
How the export works
- Connect Xero to TradieBridge with a sign-in you approve. TradieBridge only reads.
- TradieBridge copies 43 Xero resources and keeps them current.
- Open the Xero connection, choose Postgres and press Email me the zip. The emailed link works for 7 days.
- Unzip it and load the .sql file with psql into your own database or Supabase.
TradieBridge reads every table from one snapshot, so the tables agree with each other. A payment never points at an invoice that the export missed.
What lands in your database
The file creates a xero_backup schema with one table for each resource, for example
xero_invoices, xero_payments, xero_bank_transactions,
xero_contacts, xero_journals and xero_payslips. Each row
holds the Xero ID and the full record as jsonb, exactly as Xero sent it. Nothing is flattened
away, so any field Xero returns is there to query.
Query it like any other table
Who owes you money, largest first:
SELECT data #>> '{Contact,Name}' AS customer,
sum((data ->> 'AmountDue')::numeric) AS owing
FROM xero_backup.xero_invoices
WHERE data ->> 'Type' = 'ACCREC'
AND data ->> 'Status' = 'AUTHORISED'
GROUP BY customer
ORDER BY owing DESC; Other formats
The same copy also exports as CSV for spreadsheets and as JSON for developers. See Xero backup for what TradieBridge keeps and how deleted records stay in your copy. If you would rather ask than write SQL, connect Claude, ChatGPT or Copilot to the same data.
Docs Every Xero resource TradieBridge holds