Using the Python API Bindings

The Python SDK is built on top of the Edge Impulse Python API bindings, which is known as the edgeimpulse-api package. These are Python wrappers for all of the web API calls that you can use to interact with Edge Impulse projects programmatically (i.e. without needing to use the Studio graphical interface).

The API reference guide for using the Python API bindings can be found here.

Example

The following is a quick demonstration to show you how to use the Python API Bindings. To start, install the edgeimpulse_api package

python -m pip install edgeimpulse-api

Note that if you install the edgeimpulse Python SDK package, the edgeimpulse-api package will be installed as a dependency.

Now, you can use the edgeimpulse-api package independently to control your data collection, model training, and deployment at a lower level. Create a project in the Edge Impulse Studio, navigate to Dashboard and click on the Keys tab to view your API keys. Double-click on the API key to highlight it, right-click, and select Copy.

Copy API key from Edge Impulse project

Change the api_key in the script below to match your API key.

from edgeimpulse_api import Configuration, ApiClient, ProjectsApi

# Settings
host = "https://studio.edgeimpulse.com/v1"
api_key = "ei_dae2..."

# Create a client object that can connect to our project
config = Configuration(host=host, api_key={"ApiKeyAuthentication": api_key})
client = ApiClient(config)

# Get info about the project
projects = ProjectsApi(client)
project_list = projects.list_projects()
print(project_list.projects[0])

When you run the code above, it will print out information about the project associated with the API key supplied. You should see something like the following:

id=43 name='my-project' description='This is your Edge Impulse project. From here you acquire new training data, design impulses and train models.' created=datetime.datetime(2023, 4, 3, 17, 31, 46, 651000, tzinfo=datetime.timezone.utc) owner='Shawn Hymel' ...

You can use this information to gain insights into your projects, and you can build these insights into your MLOps pipelines. Additionally, this should give you a start on using the Edge Impulse Python API to construct your own pipelines for data collection, training, deployment, and so on.

Last updated

Revision created

tab only