Python SDK
The Python SDK is the primary and most actively maintained SDK for the LAMP Platform. It is recommended for data analysis, scripting, and automation.
Installationโ
pip install LAMP-core
Connectingโ
import LAMP
LAMP.connect('email@address.com', 'password', 'api.lamp.digital')
Replace with your credentials and server address. If using the default hosted server, use api.lamp.digital.
Querying Dataโ
List Researchers, Studies, and Participantsโ
# Get all researchers
researchers = LAMP.Researcher.all()
# Get studies for a researcher
studies = LAMP.Study.all_by_researcher(researcher_id)
# Get participants in a study
participants = LAMP.Participant.all_by_study(study_id)
Retrieve Sensor Dataโ
# Get GPS data for a participant
events = LAMP.SensorEvent.all_by_participant(
participant_id,
origin='lamp.gps'
)
Results are limited to 1000 entries per request. Use the _from and to parameters (Unix timestamps in milliseconds) for range queries:
events = LAMP.SensorEvent.all_by_participant(
participant_id,
origin='lamp.gps',
_from=start_timestamp,
to=end_timestamp
)
Retrieve Activity Dataโ
events = LAMP.ActivityEvent.all_by_participant(participant_id)
Each event contains:
timestampโ When the activity was completed (Unix ms).durationโ Time spent (milliseconds).activityโ Activity identifier.temporal_slicesโ Array of individual responses.
Export to CSVโ
import pandas as pd
# Collect GPS data for all participants in a study
all_data = []
for participant in LAMP.Participant.all_by_study(study_id)['data']:
events = LAMP.SensorEvent.all_by_participant(
participant['id'],
origin='lamp.gps'
)
for event in events['data']:
all_data.append({
'participant': participant['id'],
'timestamp': event['timestamp'],
**event['data']
})
df = pd.DataFrame(all_data)
df.to_csv('gps_data.csv', index=False)
Next Stepsโ
For automated feature computation from raw data, see Cortex.