API Documentation¶
This part of the documentation covers all the methods, classes and exceptions in the datakick package.
Main Interface¶
All of datakick’s functionality can be accessed by these 5 methods.
- datakick.add_image(gtin14, img_path)[source]¶
Adds an image to the product on the Datakick database and returns the url to that image.
- Parameters
gtin14 – barcode (ean/upc)
img_path – path to the image
- Raises
requests.HTTPError – if the gtin14 is invalid
datakick.exceptions.ImageTooLarge – if the image is larger than 1MB
datakick.exceptions.InvalidImageFormat – if the image format is not one of the approved formats.
- Returns
url
str
- Return type
str
- datakick.add_product(gtin14, **kwargs)[source]¶
Adds or modifies a product on the Datakick database and returns it.
- Parameters
gtin14 – barcode (ean/upc)
name – name
brand_name – brand name
size – net weight or volume (i.e. 20oz or 500g)
ingredients – string of the ingredients
serving_size – serving size of the product
servings_per_container – number of servings per container
calories – number of calories
fat_calories – number of calories from fat
fat – amount of fat in grams (g)
saturated_fat – amount of saturated fat in grams (g)
trans_fat – amount of trans fat in grams (g)
polyunsaturated_fat – amount of polyunsaturated fat in grams (g)
monounsaturated_fat – amount of monounsaturated fat in grams (g)
cholesterol – amount of cholesterol in milligrams (mg)
sodium – amount of sodium in milligrams (mg)
potassium – amount of potassium in milligrams (mg)
carbohydrate – amount of carbohydrates in grams (g)
fiber – amount of fiber in grams (g)
sugars – amount of sugar in grams (g)
protein – amount of protein in grams (g)
author – name of the author of the book
publisher – name of the publisher of the book
pages – number of pages in the book
alcohol_by_volume – percentage of alcohol
- Returns
DatakickProduct
object- Return type
- datakick.find_product(gtin14)[source]¶
Finds and returns the product from the Datakick database matching the barcode supplied.
- Parameters
gtin14 – barcode (ean/upc)
- Raises
requests.HTTPError – if the gtin14 is invalid or the product is not found in the database
- Returns
DatakickProduct
object- Return type
Model(s)¶
- class datakick.models.DatakickProduct(json_response)[source]¶
Object which contains all the attributes of a product from the Datakick database.
- property alcohol_by_volume¶
Alcohol by volume as a percent.
- property author¶
Name of the author (of the book).
- property brand_name¶
The brand name.
- property calories¶
Amount of calories.
- property carbohydrate¶
Amount of carbohydrates.
- property cholesterol¶
Amount of cholesterol in milligrams (mg).
- property fat¶
Amount of fat in grams (g).
- property fat_calories¶
Amount of calories from fat.
- property fiber¶
Amount of fiber in grams (g).
- property gtin14¶
The barcode (ean/upc).
- property images¶
list
of urls to each image.
- property ingredients¶
str
of ingredients.
- property monounsaturated_fat¶
Amount of monounsaturated fat in grams (g).
- property name¶
Name of the product.
- property pages¶
Number of pages (in the book).
- property polyunsaturated_fat¶
Amount of polyunsaturated fat in grams (g).
- property potassium¶
Amount of potassium in milligrams (mg).
- property protein¶
Amount of protein in grams (g).
- property publisher¶
Name of the (book) publisher.
- property saturated_fat¶
Amount of saturated fat in grams (g).
- property serving_size¶
The serving size.
- property servings_per_container¶
The servings per container.
- property size¶
The net weight or volume.
- property sodium¶
Amount of sodium in milligrams (mg).
- property sugars¶
Amount of sugar in grams (g).
- property trans_fat¶
Amount of trans fat in grams (g).