/i/bulk

Bulk session, metric, event data writing

❗️

Bulk method limitations

Countly v16.02 had issues with parallelization. Basically there is no guarantee that bulk requests will be executed in the order you provided them, they also can be executed simultaneously.

If order of execution does not matter (as events, crashes, user info), you can use bulk API. But if order of execution matters, like in sessions, then results may be inconsistent with what you would receive if you execute all requests separately.

This has been since fixed in Countly v16.06

Basically instead of sending separate requests to /i with session data, metrics and events, you can combine them in one single HTTP request (for example when sending older data with timestamp, while user did not have Internet connection)

For that you would need to convert normal /i request parameters into JSON object, so for example, sending bulk data which combine 4 normal requests:

  1. to start session with metrics

  2. to update session duration

  3. to send an event

  4. to end session

[ { "device_id":"1234567890", "app_key":"9a4d196c01d3ca82876c0398ab774e5e", "begin_session":1, "metrics": { "_os": "IOS", "_os_version": "7.1", "_resolution": "2048x1536", "_density": "200dpi", "_device": "iPod", "_carrier": "Telecom", "_app_version": "1.2" } }, { "device_id":"1234567890", "app_key":"9a4d196c01d3ca82876c0398ab774e5e", "session_duration":30 }, { "device_id":"1234567890", "app_key":"9a4d196c01d3ca82876c0398ab774e5e", "events": [ { "key": "test2", "count": 2, "sum":1.50, "segmentation": { "country": "Latvia", "market": "googleplay" } } ] }, { "device_id":"1234567890", "app_key":"9a4d196c01d3ca82876c0398ab774e5e", "end_session":1 } ];

Also, it's possible to combine the 'start_session', 'metrics', 'session_duration', 'events' and 'end_session' together into one JSON block, with the appropriate device_id and api_key. You only need to make sure that the order is correct.

Here's an example:

var params = [ {"device_id":DEVICE_ID, "app_key":APP_KEY, "begin_session":1, "metrics":{"os": "Android"}}, {"device_id":DEVICE_ID, "app_key":APP_KEY, "session_duration":30}, {"device_id":DEVICEID+"A", "app_key":APP_KEY, "end_session":1} ];
Query Params
string

(optional) global app_key, you can also provide separate app_key for each request in it's object

Form Data
string

JSON Array as string with request objects that you would usually pass to /i api path

Response

Language
Choose an example:
application/json