Sending an event

How did we do?

Once you've defined your available event types in HiveMP Event Tracking, you can stream event data in from your games, applications or websites.

Sending a single event

You can send events to HiveMP Event Tracking using public, session or administrative API keys. Once you've acquired an API key for your current project, you can send events to event types you've previously defined.

For an event type with a single field, an example for sending an event to HiveMP Event Tracking would look like:

read -r -d '' _request_body << EOM
{
  "test": "My test event data"
}
EOM
curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  --data "$_request_body" \
  -X PUT \
  "https://event-api.hivemp.com/v1/event/insert"\
"?eventType=MyTestEvent"\
"&eventTypeVersion=MyTestEvent"

If the event was ingested successfully, you'll receive a value of true from the API endpoint. If an error is returned, there are fields in the HiveMPSystemErrorData structure that will indicate the cause of the error.

The structure of the data sent will depend on how you declared your event type. For a reference on how to send data for various field types, refer to Event Types.

Sending multiple events

If you need to send multiple events at the same time, or want to send events in batches, you can instead use the PUT /event/batchInsert endpoint, like this:

read -r -d '' _request_body << EOM
[
  {
    "test": "My test event data"
  },
  {
    "test": "Data in another event"
  },
  {
    "test": "Third event"
  }
]
EOM
curl -s \
  -H "X-API-Key: $apiKey" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  --data "$_request_body" \
  -X PUT \
  "https://event-api.hivemp.com/v1/event/batchInsert"\
"?eventType=MyTestEvent"\
"&eventTypeVersion=MyTestEvent"

Further reading