JSON formatted responses are also supported by setting the “Accept” value in the http header to “application/json” when making a request.
At Xero we use .NET, and used the Microsoft .NET JSON date format available at the time of original development. We know it's ugly but not something we can fix without a breaking change or a new version of the API. We're really sorry about this. To help you along, below we explain how to handle this date format. An example date/time in JSON is returned like this:
"DateTimeUTC": "\/Date(1439434356790)\/" or "PeriodLockDate": "\/Date(1419937200000+0000)\/"In both cases, the date/time value is a unix timestamp value, but in miliseconds rather than seconds (so divide by 1,000 for seconds). For some elements we also include a date string value on JSON responses to help with reading date values. e.g. DateString, DueDateString.
The easiest way to retrieve resources that have been created or modified since a previous request is to specify a UTC timestamp filter using the If-Modified-Since http parameter. Only items created or updated since the specified timestamp will be returned (accurate to the second).
Please note: Not all changes will trigger a change of the UpdatedDateUTC field. These include changes to partially paid transactions which don't generate a journal such as DueDate or SentToContact, and Contact fields pulled from other sources such as Balances, IsSupplier, and isCustomer. As a result, transactions with these changes may not be returned with an If-Modified-Since query.
Appending a where querystring parameter to the endpoint URL will restrict the amount of data being returned.
Contact.ContactID = Guid("cd09aa49-134d-40fb-a52b-b63c6a91d712")This would translate to the following URL once percent encoded.
https://api.xero.com/api.xro/2.0/Invoices?where=Contact.ContactID%20%3D%20Guid%28%22cd09aa49-134d-40fb-a52b-b63c6a91d712%22%29Example 2 : Retrieve all unpaid ACCREC Invoices against a particular Contact Name using the Invoices endpoint
Contact.Name=="Basket Case" AND Type=="ACCREC" AND STATUS=="AUTHORISED"Example 3 : Retrieve all Bank Accounts using the Accounts endpoint
Type=="BANK"Example 4 : Retrieve all DELETED or VOIDED Invoices using the Invoices endpoint
Status=="VOIDED" OR Status=="DELETED"Example 5: Retrieve all contacts with specific text in the contact name using the Contacts endpoint
Name.Contains("Peter") Name.StartsWith("") Name.EndsWith("")Example 6: For optional elements such as email address, it is best that you add a not null at the starts of the query. If you don’t include it you will get an exception if any of the optional elements aren’t set. This example is using the Contacts endpoint
EmailAddress!=null&&EmailAddress.StartsWith("boom")Example 7: List all accounts of type ‘Asset’, ordered by account code using the Accounts endpoint
where=Type=="ASSET"&order=CodeExample 8: Retrieve invoices with an invoice date between a date range
Date >= DateTime(2015, 01, 01) && Date < DateTime(2015, 12, 31)Note: Long complex WHERE clauses can cause the query to time out. For optimal performance, recommend that the number of WHERE parameters be limited to three or less, and that the request be structured to use AND instead of OR whenever possible since AND queries are far more efficient in our system.
https://api.xero.com/api.xro/2.0/TaxRatesWe recommend all calls to any endpoints that have large result sets use the if-modified-since parameter.
https://api.xero.com/api.xro/2.0/Contacts?order=EmailAddressYou can get results in descending order by using DESC parameter.
POST /api.xro/2.0/Invoices?summarizeErrors=falseNote: The summarizeErrors option is only available for the Accounting API. The summarizeErrors option will not affect AU or US Payroll API calls.
<Invoices> <Invoice status="OK"> ... </Invoice> <Invoice status="OK"> ... </Invoice> <Invoice status="WARNING"> ... </Invoice> <Invoice status="ERROR"> ... </Invoice> </Invoices> </Response>