|
| 1 | +--- |
| 2 | +title: Asset events |
| 3 | +description: Contains list method to get asset's events. |
| 4 | +--- |
| 5 | + |
| 6 | +# Asset events |
| 7 | + |
| 8 | +Contains list method to get asset's events. |
| 9 | + |
| 10 | + |
| 11 | +## API actions |
| 12 | + |
| 13 | +API path: `/asset/history/`. |
| 14 | + |
| 15 | +### `list` |
| 16 | + |
| 17 | +List less than or equal to `limit` of assets' events filtered by event types (`events`) between `from` date/time |
| 18 | +and `to` date/time sorted by **time** field. |
| 19 | + |
| 20 | +#### Parameters |
| 21 | + |
| 22 | +| name | description | type | |
| 23 | +|:------------------|:--------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------| |
| 24 | +| assets | List of objects containing identifier and type to define a list of tracker identifiers. Permitted types: `vehicle`, `employee`. | object array | |
| 25 | +| from | Start date/time for searching. | string [date/time](../../../getting-started/introduction.md#data-types) | |
| 26 | +| to | End date/time for searching. Must be after "from" date. | string [date/time](../../../getting-started/introduction.md#data-types) | |
| 27 | +| events | Optional. Default: all. List of history types. | string array | |
| 28 | +| limit | Optional. Default: [history.maxLimit](../dealer.md). Max count of entries in result. | int | |
| 29 | +| offset | Optional. Default: `0`. Starting offset, used for pagination. | int | |
| 30 | +| ascending | Optional. Default: `true`. If `true`, ordering by time will be ascending, descending otherwise. | boolean | |
| 31 | +| only_emergency | Optional. Default: `false`. If `true`, only emergency events will be included. | boolean | |
| 32 | +| add_tracker_label | Optional. Default: `true`. If `true`, tracker label will be added to "message" field. | boolean | |
| 33 | +| add_tracker_files | Optional. Default: `false`. If `true`, tracker files info will be included. | boolean | |
| 34 | + |
| 35 | +If `events` (event types) not passed then list all event types. |
| 36 | + |
| 37 | +Available event types can be obtained by [/history/type/list](./history_type.md#list) action. |
| 38 | + |
| 39 | +Default and max limit is 1000. (Note for StandAlone: this value configured by maxHistoryLimit config option). |
| 40 | + |
| 41 | + |
| 42 | +#### Example |
| 43 | + |
| 44 | +=== "cURL" |
| 45 | + |
| 46 | + ```shell |
| 47 | + curl -X POST '{{ extra.api_example_url }}/history/tracker/list' \ |
| 48 | + -H 'Content-Type: application/json' \ |
| 49 | + -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "assets": [{"id": 1683258, "type": "employee"}], "from": "2020-12-10 16:44:00", "to": "2020-12-22 16:44:00"}' |
| 50 | + ``` |
| 51 | + |
| 52 | +#### Response |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "list": [{ |
| 57 | + "id": 1, |
| 58 | + "type": "tracker", |
| 59 | + "is_read": false, |
| 60 | + "message": "Alarm", |
| 61 | + "time": "2020-01-01 00:00:00", |
| 62 | + "event": "offline", |
| 63 | + "tracker_id": 2, |
| 64 | + "rule_id": 3, |
| 65 | + "track_id": 4, |
| 66 | + "location":{ |
| 67 | + "lat": 50.0, |
| 68 | + "lng": 60.0, |
| 69 | + "precision": 50 |
| 70 | + }, |
| 71 | + "address": "address", |
| 72 | + "extra": { |
| 73 | + "task_id": null , |
| 74 | + "parent_task_id": null, |
| 75 | + "counter_id": null, |
| 76 | + "service_task_id": null, |
| 77 | + "checkin_id": null, |
| 78 | + "place_ids": null, |
| 79 | + "last_known_location": false, |
| 80 | + "tracker_label": "Tracker label", |
| 81 | + "emergency": false, |
| 82 | + "employee_id": 4563 |
| 83 | + } |
| 84 | + }], |
| 85 | + "limit_exceeded": false, |
| 86 | + "total": 150, |
| 87 | + "total_unread": 10, |
| 88 | + "success": true |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +* `list` - list of zero or more history_entry` objects which described in [Tracker history entry](./index.md#tracker-history-entry). |
| 93 | +* `limit_exceeded` - boolean. `false` when listed all history entries satisfied with conditions and `true` otherwise. |
| 94 | +* `total` - int. Amount of history entries satisfied with conditions. |
| 95 | +* `total_unread` - int. Amount of unread history entries satisfied with conditions. |
| 96 | + |
| 97 | +#### Errors |
| 98 | + |
| 99 | +* 211 – Requested time span is too big - time span between `from` and `to` is more than [report.maxTimeSpan](../dealer.md) days. |
| 100 | +* 212 – Requested `limit` is too big - `limit` is more than [history.maxLimit](../dealer.md). |
0 commit comments