Introduction
The Ans API allows you to automate certain processes within Ans, for example provisioning users, assignments and question banks. It is also possible to use our webhook to listen to certain changes in Ans and act based on these events.
In the following articles we’ll explain how to use the Ans API to create, update and destroy users, question banks and assignments. You can view the entire API documentation via this link: https://ans.app/api/docs
Prerequisites
Before you begin, you should have a basic understanding of a REST API and HTTP actions, such as: GET, CREATE, UPDATE, DELETE.
If you don’t yet have an API token, follow these instructions: here
The generated token is a Bearer token and must be sent with every request in the request header for authorisation.
The school_id attribute which is required for viewing and creating users can be found on the API token page in the user settings.
Pagination
The API generates several headers due to its use of pagination, this includes:
- Link, the standard link header defined in RFC 8288 - Current-Page, which shows the current page of the requested data - Page-Items, which shows the amount of items per page - Total-Pages, which shows the total amount of pages available - Total-Count, which shows the total count of objects that was requested
By default every list request returns 20 records. It is possible to adjust the number of records per page with the usage of the "items" paramater. You can choose between 5, 10, 20, 50 and 100 records per page. For example:
GET https://ans.app/api/v2/background_jobs?page=2&items=10
Rate Limits
The API enforces a rate limit of 500 request per minute per ip-address. If the rate limit is exceeded, the API responds with a HTTP 429 Too Many Requests response code.
You can use the following response headers to confirm the current rate limit and monitor the number of requests remaining in the current minute.
- RateLimit-Limit, the current limit for your account - RateLimit-Remaining, the number of remaining requests in the current minute - RateLimit-Reset, the number of seconds until the limit is reset
Comments
0 comments
Please sign in to leave a comment.