Add New Data
Add a new data item. You can add a maximum of 10000 files directly through this API. Use `addOrganizationDataFile` to add additional files. There are examples of using this API in Python, cURL and Nod
post
https://studio.edgeimpulse.com/v1
/api/organizations/{organizationId}/data/add
Add new data
This API requires multipart form data to be posted. This is how you call the API in a variety of languages:
Python
cURL
Node.js
1
import requests
2
3
ORGANIZATION_ID = 1
4
API_KEY = 'ei_...'
5
6
r = requests.post(
7
'https://studio.edgeimpulse.com/v1/api/organizations/' + ORGANIZATION_ID + '/data/add',
8
headers={
9
'x-api-key': API_KEY
10
},
11
files=(
12
('name', (None, 'data item name')),
13
('dataset', (None, 'dataset')),
14
('metadata', (None, '{\"key\":\"value\"}')),
15
('bucketName', (None, 'Internal datasets')),
16
('files[]', ('hello.txt', open('/Users/janjongboom/Downloads/hello.txt', 'rb'), 'text/plain')),
17
('files[]', ('world.png', open('/Users/janjongboom/Downloads/world.png', 'rb'), 'image/png')),
18
)
19
)
20
21
print('request returned', r, r.content)
Copied!
1
curl -X POST -H \"x-api-key: ei_YOUR_API_KEY\" \\
2
https://studio.edgeimpulse.com/v1/api/organizations/ORGANIZATION_ID/data/add \\
3
-F bucketName=\"Internal datasets\" \\
4
-F dataset=\"dataset\" \\
5
-F name=\"data item name\" \\
6
-F metadata='{\"key\":\"value\"}' \\
7
-F files[]=@/Users/janjongboom/Downloads/hello.txt -F files[]=@/Users/janjongboom/Downloads/world.png
Copied!
1
const request = require('request');
2
const fs = require('fs');
3
4
const ORGANIZATION_ID = 1;
5
const API_KEY = 'ei_...';
6
7
// Make the request with an empty 'formData' object, so we can manipulate this later
8
let req = request.post(`https://studio.edgeimpulse.com/v1/api/organizations/${ORGANIZATION_ID}/data/add`, {
9
headers: {
10
'Content-Type': 'multipart/form-data',
11
'x-api-key': API_KEY
12
},
13
formData: { }
14
}, (_err, resp, body) => {
15
if (_err) {
16
return console.error('Error when doing request', _err);
17
}
18
else if (resp.statusCode !== 200) {
19
return console.error('statusCode was not 200, but ' + resp.statusCode);
20
}
21
else {
22
console.log('Request succeeded', body);
23
}
24
});
25
26
// the request actually gets sent at the next tick so we can still manipulate this
27
let form = req.form();
28
form.append('name', 'data item name');
29
form.append('dataset', 'dataset');
30
form.append('bucketName', 'Internal datasets');
31
form.append('metadata', JSON.stringify({
32
key: 'value',
33
}));
34
form.append('files[]', fs.readFileSync('/Users/janjongboom/Downloads/hello.txt'), {
35
contentType: 'text/plain',
36
filename: 'hello.txt'
37
});
38
form.append('files[]', fs.readFileSync('/Users/janjongboom/Downloads/world.png'), {
39
contentType: 'image/png',
40
filename: 'world.png'
41
});
Copied!
Export as PDF
Copy link