The ingestion API is used to send new device data to Edge Impulse. It's available on both HTTP and HTTPS endpoints and requires an API key to authenticate.
With the ingestion API, you can upload the following types of files:
JPG, PNG images
MP4, AVI video files
WAV audio files
CBOR/JSON files in the Edge Impulse data acquisition format
CSV files in the Edge Impulse data acquisition format
*.labels
file, with or without the need to go through the uploader (as long as it's in the same batch). See Labels acquisition formats
There are three endpoints available:
POST /api/training/files
- for gathering training data.
POST /api/testing/files
- for gathering testing data. If you have the 'Live classification' page open in your browser the file will automatically be classified against the current impulse.
POST /api/anomaly/files
- for anomaly data from deployed devices.
The maximum number of files you can upload in a single request is 1000. The maximum size of a single file is 100 MB.
Because the files
endpoints expect Content-Type
to be multipart/form-data
, there are also available legacy endpoints that require simpler requests:
POST /api/training/data
POST /api/testing/data
POST /api/anomaly/data
The API is located at:
HTTP
HTTPS
x-api-key
- API Key (required).
x-label
- Label (optional). If this header is not provided a label is automatically inferred from the filename through the following regex: ^[a-zA-Z0-9\s-_]+
- For example: idle.01 will yield the label idle. If you don't want to assign the label nor derive it from the file name, provide an x-no-label
header with the value 1
.
x-disallow-duplicates
- When set, the server checks the hash of the message against your current dataset (optional). We'd recommend setting this header but haven't enabled it by default for backward compatibility.
x-add-date-id
: 1 - to add a date ID to the filename. For example: if you upload with filename test.wav the file name will be test - set this option and we'll add a unique ID to the end (this is what we use on the daemon to create unique names).
Content-type
- format of data used. Can be application/cbor
, application/json
, multipart/form-data
.
All responses are sent with content type text/plain
. The following response codes may be returned:
200
- Stored the file, file name is in the body.
400
- Invalid message, e.g. fields are missing, or are invalid. See body for more information.
401
- Missing x-api-key
header, or invalid API key.
421
- Missing header, see body for more information.
500
- Internal server error, see body for more information.
On the embedded devices, usually, there are no available high-level libraries to perform HTTP requests. In this case, you can use the following example to prepare an HTTP request to the ingestion API:
The ingestion service accepts raw requests with data formatted as JSON or CBOR. We will use the following JSON structure as an example sample:
In the following examples, for readability purposes, request bodies are presented using Python notation for binary strings. Normally they are just a stream of bytes.
data
endpointThe minimal request to the api/training/data
endpoint is the following:
files
endpointThe minimal request to the api/training/files
endpoint is the following: