How to get a list of Events using REST API
This guide explains how to obtain a list of events using REST API.
Requisites
- Read how to enable REST API
- Read how to generate the REST API token
- Read how to obtain the userID from a user
Resource used
Events > Eventrules
This is the first resource we will use. We need to gather a list of EventRuleIds to use later on with the next resource Events.
How to
We start using the eventrules resource (2) to get the event rules id's:
1. Login to http://host_name/comGpsGate/api/v.1/test
Note: replace host_name with your actual server IP address or host name.
2. Click on the resource name, then > Try it out
3. Insert the parameters required. This API resource requires app ID and date, userID, From, Until and Filter. Then press Execute.
Note: If you don't know your Application ID, you can obtain it as explained here.
4. In the response you should receive a list of the event rules available in the application selected with their respective IDs.
5. Now that we know the eventIDs we can use them in our next query using the resource events (1)
6. We enter the parameters requested by this resource
Example: we want to list all Overspeeding events. Overspeeding events have the ID 206 in our previous screenshot.
7. The answer will give us all events from that date for the selected unit of the specified date. Each repetition in the structure of the response is one different event.
Performance and Pagination
To improve the performance and have better scalability, there is a limit of 1000 records in the response of an HTTP GET request. This number can be decreased by sending PageSize parameters in the query string of your request, however, it cannot exceed 1000. If there are more records than the number specified in the PageSize parameter (or 1000 by default), a link to the next page is sent back along with the response in x-pagination header. Here is an example of an x-pagination header for a request where the specified PageSize was 100.
x-pagination: {
|