Within the Brain, items
are localized at a location
. When an item moves from one location to another location a 'moved-to' event is created.
Moved-to events are both stored within the events resource and the items resource of the Brain web API.
These events are stored for a limited amount of time.
Retrieving moved-to events from events resource API
https://brain_host
/api/events?topic.resource_type=items&topic.action=moved-to&key=api_key
In the above result, we see that the database contains a total of 21932402 moved-to events.
We only display the first 100 events, the next 100 events are retrievable through the "next_url" property.
Data of a moved-to event:
- resource_url: The URL to the item resource.
- arguments:
- prev_location: Previous
location_id
of the item. - location: Current
location_id
of the item.
- prev_location: Previous
- payload:
- time: Time the item was moved to current location.
- location_label: Label of the location.
- item_label: Label of the item.
- time_move_count: How many time the item was moved.
- time_event: Time the item was moved to the current location.
Retrieving moved-to events from items resource API
https://brain_host
/api/items/moves?populate=item.label,location.label&key=api_key
In the above result, we see that the database contains a total of 21949067 moved-to events.
We only display the first 100 events, the next 100 events are retrievable through the "next_url" property.
Data from a moved-to event:
- URL: The URL to the event resource.
- item:
- URL: URL to item resource.
- id:
item_id
- label: Label of the item.
- location:
- URL: URL to location resource.
- id:
location_id
- label: Label of the location.
- time_moved: Time the item was moved to the current location.
Filtering by date/time
It is also possible to filter events by date using the following keywords in the query. All timestamps should be in ISO 8601 format.
Keyword | Description | Example |
---|---|---|
after , before |
Limits on time_created , exclusive. |
?after=2016-01-27T08:38:55.255Z |
after_id , before_id |
Limits directly on id excludes the given id value, please note that id is chronological. |
?after_id=56a88364e783152127d15340 |
from , until |
Limits on time_created , inclusive. |
?until=2016-01-27T08:38:55.255Z |
from_id , until_id |
Limits on id , includes the given id value. |
?from_id=56a88364e783152127d15340 |
Example using both the before and after keyword in the query:
https://<brain_address>
/api/events?topic.action=moved-to&after=2018-05-10T00:00:00.000Z&before=2018-05-15T23:59:59.999Z&key=<api_key>
Alternative formats
By default the result is returned in JSON
. It is also possible to get the information in CSV or TXT format.
Example of CSV output:
https://<brain_host>
/api/events.csv
?topic.resource_type=items&topic.action=moved-to&key=<api_key>
Example of TXT output:
https://<brain_host>
/api/events.txt
?topic.resource_type=items&topic.action=moved-to&key=<api_key>
Comments
0 comments
Article is closed for comments.