Skip to main content

Trayn API: samples

Selection of samples to access data from Trayn

Updated today

Here are some examples for using the Trayn API. As the Trayn API mostly uses JSON, the following samples use jq, a powerful command line processor for JSON data. In the examples below, we have omitted the full URL and the authentication headers, so

curl -X GET /s/user/settings

translates to

curl -X GET \
https://api.trayn.com/backend/rest/s/user/settings
-H "authorization: token ***"

Export users as CSV

In order to export a list of users in CSV format, we select as many users as possible (1000), order by last name and use jq's @csv format:

curl -X GET /s/search?type=user&orderBy=lastname&max=1000 \
| jq -r '.[] | [.id,.lastname,.firstname,.primaryEmailAddress] | @csv'

This will give you something like this

"012","Columbus","Christofer","cristoforo.colombo@trayn.com"
"013","Magellan","Ferdinand","fernao.de.magalhaes@trayn.com"
"014","Vespucci","Amerigo","amerigo.vespucci@trayn.com"

If you only want to export athletes, add the role parameter:

curl -X GET /s/search?type=user&role=ATHLETE&orderBy=lastname&max=1000

Find test parameters

You can get a list of all test parameters using

curl -X GET /s/performance/definition

If you want to find out which test parameters include your heart rate, you can filter by "hr" and export the results as a CSV

curl -X GET /s/performance/definition?q=hr \
| jq -r '.[] | [ .id, .name, .shortcut, ([.unit[].id] | join("|")) ] | @csv'

Unit IDs will be folder into one column and separated with a '|'

Did this answer your question?