# Events

Retrieving event information

## Fetch an Event

`GET /events/{id}`

Returns a single Event record with full context for the specified identifier

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `id` (path, integer, required)
  Type: integer

Responses:

- 200: OK

Content type: application/json

Type: Event

Schema: [Event](https://sourcey-traccar.pages.dev/api-reference/models/event/index.md)

- `id` (optional)
  Type: integer, int64
  
  Unique event identifier

- `type` (optional)
  Type: string
  
  Event type name

- `eventTime` (optional)
  Type: string, date-time
  
  in ISO 8601 format. eg. `1963-11-22T18:30:00Z`

- `deviceId` (optional)
  Type: integer, int64
  
  Device associated with the event

- `positionId` (optional)
  Type: integer, int64
  
  Position record linked to the event when applicable

- `geofenceId` (optional)
  Type: integer, int64
  
  Geofence referenced by the event if any

- `maintenanceId` (optional)
  Type: integer
  
  Maintenance record tied to the event

- `attributes` (optional)
  Type: object
  
  Additional event-specific attributes

- 401: Unauthorized

- 404: Not found

## Examples

### cURL

```bash
curl -X GET 'https://demo.traccar.org/api/events/0' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/events/0', {
  method: 'GET',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://demo.traccar.org/api/events/0',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```
