How To: Export Data via the Reboot Motion API
This tutorial uses code samples written in Python; however, if your organization uses a different language, you can still use the tutorials as a reference point — you will just need to translate the examples to the language of your choosing.
If you need help with getting set up to use the Reboot Motion API, you can check out our Getting Set Up tutorial here.
Welcome! This tutorial walks you through the process of creating a Data Export via the Reboot Motion API. For more information about the endpoints included in this tutorial, or any other endpoint, you can check out our API documentation.
Note: You will need a valid Access Token (or legacy API Key) to interact with the API endpoints mentioned in this tutorial. Access to the Reboot Motion API is available to all active Reboot Motion customers, and you can find authentication-related documentation in the Reboot Motion API Documentation.
What exactly is a Data Export? A Data Export is a set of aggregated data that Reboot Motion has processed for your organization. The result is a DataExport
object, which contains pre-signed URL(s) to download the data.
In this tutorial, we're going to export inverse-kinematics
data in the parquet
file format. Supported file formats that you can request are csv
and parquet
. Other data types (not just inverse kinematics) are available for export; view the relevant API documentation for a list of supported options.
Understanding the Endpoint
First, let’s take a look at the Reboot Motion API documentation for Data Export. You'll notice an endpoint:
Endpoint | Description |
---|---|
POST /data_export | Create Data Export |
Let's understand the POST /data_export
endpoint parameters below:
{ "session_id": "32dee2b3-8433-4dbc-ad39-694d4966d745", "movement_type_id": 2, "org_player_id": "668933", "data_type": "inverse-kinematics", "data_format": "parquet" }
There are some Reboot Motion-specific terms in here, like session_id
, movement_type_id
, org_player_id
, data_type
, and data_format
— let’s define those:
Term | Definition |
---|---|
session_id | The ID of the motion capture session (for example, game or practice) for which the returned aggregated files were initially uploaded. |
movement_type_id | The type of movement we want to analyze. For our example case, we are looking at baseball pitching movements, so we are using a movement_type_id of 2. For the names and IDs of other movement types, you can query the API via the List Movement Types endpoint. |
org_player_id | The ID used by your organization to identify the player. |
data_type | The type of data you're looking to export. Options include: inverse-kinematics , momentum-energy or metadata . For more details, see the Create a Data Export doc. |
data_format | The format in which you'd like to download the aggregated data. Available options are csv or parquet. |
Before we start, we want to set up our main.py
file properly, we want to set up our main.py
file properly, so let's make sure you have the any required import statements and constants at the top of your file —, like the os
library for interacting with environment variables, and the requests
library for making HTTP requests.
import os import requests ACCESS_TOKEN = "<YOUR ACCESS TOKEN>"
If you're not sure what any of these import statements or constants are doing, hop over to our Getting Set Up tutorial, which walks you through each of those.
Also note that the ACCESS_TOKEN
constant above would reflect an actual access token provided by our authentication process, which is detailed in the Getting Set Up tutorial. In our example, we are hard-coding a token value for ease of understanding, but in practice, you'll need to ensure your credentials are stored securely and an access token is retrieved before making your API requests. It is wise to read your credentials from a secure value store or from an environment variable, rather than hard-coding them into your code. As mentioned in the tutorial, please be incredibly careful not to commit your credentials to a public repository.
As a reminder: all the values used in this tutorial are example values. You cannot plug and play with the example values as they currently are; you will need to put in the correct values for your organization/player/etc. The example values used in this tutorial are for a fictional example player.
Creating the Data Export
Here we create the Data Export and simply print the JSON response from the API. Working in our main.py
file created earlier, the file should now look like the below, and you should be able to create a Data Export.
import os import requests ACCESS_TOKEN = "<YOUR ACCESS TOKEN>" def main(): data_export_input = { "session_id": "32dee2b3-8433-4dbc-ad39-694d4966d745", "movement_type_id": 2, "org_player_id": "778935", "data_type": "inverse-kinematics", "data_format": "parquet" } create_data_export = requests.post( "https://api.rebootmotion.com/data_export", headers={ "Authentication": f"Bearer {ACCESS_TOKEN}" }, json=data_export_input ) print(create_data_export.json()) if __name__ == "__main__": main()
Running the above code snippet will allow you to create a Data Export, and will print out the JSON values of the response to your terminal. As a reminder, you should NOT just copy/paste/run the above code; instead, you should modify it to fit your individual use case.
The sample output should look like the data below if no error is encountered:
{ "session_id": "2dee2b3-8433-4dbc-ad39-694d4966d745", "movement_type_id": 2, "org_player_id": "778935", "data_type": "inverse-kinematics", "data_format": "parquet", "download_urls": [<the url to download the aggregated data>, ...] }
Please note that the download_urls key in the returned output data is a list of one or more URLs. If more than one URL is present, each one will contain a portion of the aggregated data, so you'll want to handle downloading/combining them in your code. The number of URLs returned depends on the size of the aggregated data set.
Common Errors
Ideally, you wouldn't run into any errors while going through this tutorial, but there's a lot of information here and sometimes errors happen. That being said, let's go through some of the more common errors and the first steps to take to troubleshoot those errors to save you some time.
You can always access a full list of errors in the Reboot Motion documentation, but we will walk you through some more specific error messages you may encounter while trying to create a Data Export.
ModuleNotFoundError: No module named '<module_name>'
This error comes from the module in question not being installed — you will need to install the module in order to use it. You can do this by running pip install <module_name>
in your terminal. If you are using a different package manager, you will need to use the appropriate command for that package manager.
HTTP Exception 403: Forbidden
You need to include a valid access token (or legacy API Key). If you don't know how to get this, take a look at the Getting Set Up tutorial.
HTTP Exception 500: Internal Server Error
This means something is wrong on the Reboot Motion server's end - please reach out to the team at [email protected].
If you need to retry the API call after a failure, check that you have everything above correct, restart your server, and make the call again. If you continue to get an error message and can't figure out why, feel free to reach out to the Reboot Motion team.
Please feel free to reach out to the team with any additional questions you may have, or if you run into any issues that weren't addressed above!