POST
https://api.nutritionix.com/v1_1/asset?appId=YOUR_APP_ID&appKey=YOUR_APP_KEY
Required
appId
(string)appKey
(string)file
orurl
(file overrides url if both are present)url
(A URL that points to a public facing asset that you wish to be uploaded)file
(A file to be uploaded)
- HEADERS
Content-Type: application/json
(required for posting JSON)
Required for processing
file_group
- 1 = front of package photo
- 2 = nutrition label photo
- 3 = ingredient statement photo
upc
(string or int)
Optional
app_user_id
A unique identifier to link a record to a user in your appitem_id
An identifier from our API that matches the UPC being submittedbrand_id
the associated brand_id of the item that mathced the UPC
Notes
- If the required parameters are not present the item will not be queued for processing.
file_group
can only be a one of the integers listed above.- Assets can only be accessed by the
appId
andappKey
that created them. - Assets cannot be destroyed at this time.
Example JSON POST Request using URL POST /v1_1/asset
{
"appId":"YOUR_APP_ID",
"appKey":"YOUR_APP_KEY",
"url":"http://www.sweettaterblog.com/wp-content/uploads/2012/05/coke__01676_zoom.jpeg",
"file_group":1,
"upc":4900000036,
"app_user_id":"YOUR_APPS_USER_ID", // OPTIONAL
"item_id":null // If you know a matching `item_id` from our API
"brand_id":null // If you know a matching `brand_id` from our API
}
Example CURL multipart/form-data upload (FILE)
curl https://api.nutritionix.com/v1_1/asset \
-F "file=@/absolute/path/to/file/coke__01676_zoom.jpeg" \
-F 'appId=YOUR_APP_KEY' \
-F 'appKey=YOUR_APP_ID' \
-F 'file_group=1' \
-F 'upc=4900000036' \
-F 'app_user_id=YOUR_APPS_USERS_ID'
Example HTML for multipart/form-data upload (FILE)
<form method="post" enctype="multipart/form-data"
action="https://api.nutritionix.com/v1_1/asset?apiId=YOUR_APP_ID&appKey=YOUR_APP_KEY">
<input type="file" name="file">
<input type="number" name="file_group">
<input type="text" name="upc">
<!-- OPTIONAL ATTRIBUTES -->
<!-- You can use URL instead of file -->
<!-- <input type="text" name="url"> -->
<input type="text" name="app_user_id">
<input type="text" name="item_id">
<input type="text" name="brand_id">
<input type="submit">
</form>
{
"dimensions": {
"height": 359,
"width": 450
},
"format": "jpg",
"type": "image",
"file_name": "coke__01676_zoom.jpeg",
"file_group": 1,
"app_user_id": "xZ1kdD",
"appId": "YOUR_APP_ID",
"_id": "524052007bafa63fa3000015",
"created_at": "2013-09-23T14:36:48.913Z",
"foreign_ids": {
"item_id": null,
"brand_id": null,
"upc": 4900000036
},
"url": "http://res.cloudinary.com/nutritionix/image/upload/v1379947002/524052007bafa63fa3000015.jpg"
}
You can use the _id to retrieve the asset from the GET
request below
GET
https://api.nutritionix.com/v1_1/asset/:id?appId=YOUR_APP_ID&appKey=YOUR_APP_KEY