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 an API Key to interact with the API endpoints mentioned in this tutorial. API Keys are available to all active Reboot Motion customers. If you do not already have an API Key from Reboot Motion, you can generate one from your Reboot Motion Dashboard.

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.

Initial Step: Understanding the Endpoint

First, let’s take a look at the Reboot Motion API documentation for Data Export. You'll notice an endpoint:

EndpointDescription
POST /data_exportCreate 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:

TermDefinition
session_idThe ID of the motion capture session (for example, game or practice) for which the returned aggregated files were initially uploaded.
movement_type_idThe 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_idThe ID used by your organization to identify the player.
data_typeThe 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_formatThe 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, so let's make sure you have the following import statements and constants at the top of your file — we are going to use the os.getenv() function to get our API Key from wherever it is currently stored:

import os

import requests 

API_KEY = "API_KEY_FROM_REBOOT"

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.

Note that "API_KEY_FROM_REBOOT" would be replaced with your actual API Key, given to you by Reboot Motion, as detailed in the Getting Set Up tutorial. In our example, we are hard-coding the API key for ease of understanding, but in practice it's wise to read the API key from an environment variable leveraging a library like python-dotenv. As mentioned in the tutorial, please be incredibly careful not to commit your API Key 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.

Main Step: 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 

API_KEY = "API_KEY_FROM_REBOOT"
API_HEADER = {'x-api-key': API_KEY}

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=API_HEADER,
        json=data_export_input
    )

    print(create_data_export.json())

if __name__ == "__main__":
main()

Running this file will allow you to create a Data Export, and will print out the JSON values of the response to your terminal.

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 401: Unauthorized

You need to include a proper 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!