LAMP Consortium

Question about Pagination

I’m working on a couple of scripts with the Python library and wondered whether I could ask you get some further explanation / examples.

I’ve realised that due to the massive amount of data that is recorded, that API calls appear to be paginated / restricted – and therefore I’ve noticed that in a lot of the API calls, you have supplied the following optional parameters – for example in the LAMP.ActivityEvent.all_by_participant method:


Name Type Description Notes
participant_id str
origin str [optional]
_from float [optional]
to float [optional]
transform str )

I can’t seem to find in the documentation how to use these extra parameters.

My question is I’m just testing the script to retrieve some data now, but once participants start to answer a lot of different Activities – I’m wondering whether the responses will be paginated and won’t all be returned (I noticed this behaviour when looking for the device ID to send notifications inside SensorEvents – after my device started recording motion, I couldn’t then query for the device ID until I added to the call!), is it possible to query an activity event specifically in the query?

Just wondered if it’s possible to specify an activity ID, sort of like:

result = LAMP.ActivityEvent.all_by_participant(participant_id, origin=activity_id)

Hi @jwbluef,

This is an excellent question - you are correct that api calls have some restrictions on them. By default, both activity event and sensor event queries will return the latest 10,000 results from the database. However, by using the origin parameter, you can filter which results you will receive. To filter sensor events, as you point out, you set origin to the string corresponding to a specific sensor. Filtering activity events requires one extra step - you must find the activity id (I usually do this with LAMP.Activity.all_by_*) - which will be a long alphanumeric string - and then set that value as the origin parameter.

I hope this helps, but please let me know if I can make anything clearer or give more info.


Hi Luke - sorry it took me so long to respond. This works great and has been very helpful - consider this closed.