2. API Calls
Introduction:
An application program interface (API) is a software intermediary that allows two applications to talk to each other. In other words, an API is the messenger that delivers your request to the provider that you’re requesting it from and then delivers the response back to you.
We are using two API calls to connect Xero API and get information from the Xero. One API call for login purpose and get the API key and another one is used for the request to get the required information from the xero.
Login API: http://tigeensolutions.com/projects/xero/api/v2/login
Request API: http://tigeensolutions.com/projects/xero/api/v2/request
http://tigeensolutions.com/projects/xero/api/v2/login
Parameters :
- User id
- Consumer key
- Consumer secret
- Private key
- Public key
- Is update
http://tigeensolutions.com/projects/xero/api/v2/request
Parameters :
- API key
- Method
- Arguments (optional)
This API is used for the accessing the data from the Xero based on the parameters sent. We are sending two or three parameters.
- API key: It is common for all the requests.
- Method: The allowed values are
- “contacts” – Dealing with contacts.
- “items” – Dealing with items.
- “invoices” – Dealing with invoices.
- “payments” – Dealing with payments.
- “accounts” – Dealing with accounts.
- “taxrates” – Dealing with tax rates.
- Arguments/Conditions: The allowed values are:
- Id – To update a particular record.
- Invoice type – Mandatory for invoices and payments.
- Invoice status – Mandatory for invoices.
- Payment Status – Mandatory for payments
-
- API Limits:
- API Rate Limits:
- API Limits:
There are some limits to the number of API calls that your application can make against a particular Xero organization.
-
-
-
-
- Minute Limit: 60 calls in a rolling 60 second window
- Daily Limit: 5000 calls in a rolling 24-hour window
-
-
-
If you exceed either rate limit you will receive a HTTP 503 (Service Unavailable) response with the following message in the http response body:
Example API error:
oauth_problem=rate limit exceeded&oauth_problem_advice=please wait before retrying the xero api
You will also receive an X-Rate-Limit-Problem HTTP header with the value of Daily or Minute to indicate which rate limit you have hit.
If you encounter a limit, do not continue to make requests as this may continue to add to your limitation. The most common issue encountered is the 60 requests/min rate limit. If possible, queue requests and allow a few seconds before attempting to make another request.
Request Size Limit:
A single POST to the Accounting or Payroll APIs has a size limit of 3.5MB. There is no limit to the number of elements within a request, provided the overall request size does not exceed 3.5MB. A single POST to the Files API has a size limit of 10MB.
Note: When posting form-encoded xml to the API, the encoded data will be approximately 50% larger than the original xml message.
However, to ensure you receive a timely response from the API (large inserts can take quite a while), we recommend you look to batch elements in bundles of up to 50.