ProductsAPI

interface ProductsAPI

Define our Open Food Facts API endpoints. All REST methods such as GET, POST, PUT, UPDATE, DELETE can be stated in here.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
@GET(value = "contributor/{contributor}.json?nocache=1")
abstract suspend fun byContributor(@Path(value = "contributor") contributor: String): Search
Link copied to clipboard
@GET(value = "country/{country}.json")
abstract suspend fun byCountry(@Path(value = "country") country: String): Search
Link copied to clipboard
@GET(value = "nutrient-level/{nutrient_level}.json")
abstract suspend fun byNutrientLevel(@Path(value = "nutrient_level") nutrientLevel: String): Search
Link copied to clipboard
@GET
abstract suspend fun downloadFile(@Url fileUrl: String): ResponseBody
Link copied to clipboard
@GET(value = "/cgi/product_image_crop.pl")
abstract suspend fun editImage(@Query(value = "code") code: String, @QueryMap fields: Map<String, @JvmSuppressWildcards String?>): JsonNode
Link copied to clipboard
@GET(value = "/cgi/product_image_crop.pl")
abstract suspend fun editImages(@Query(value = "code") code: String, @QueryMap fields: Map<String, @JvmSuppressWildcards String?>?): ObjectNode

This method is to crop images server side

Link copied to clipboard
@GET(value = "state/to-be-completed/{page}.json?nocache=1")
abstract suspend fun getIncompleteProducts(@Path(value = "page") page: Int, @Query(value = "fields") fields: String): Search

This method gives a list of incomplete products

Link copied to clipboard
@GET(value = "informer/{contributor}/state/to-be-completed/{page}.json?nocache=1")
abstract suspend fun getInfoAddedIncompleteProducts(@Path(value = "contributor") contributor: String, @Path(value = "page") page: Int): Search
Link copied to clipboard
@GET(value = "informer/{contributor}/{page}.json?nocache=1")
abstract suspend fun getInfoAddedProducts(@Path(value = "contributor") contributor: String?, @Path(value = "page") page: Int): Search
Link copied to clipboard
@GET(value = "api/v0/product/{barcode}.json?fields=ingredients")
abstract suspend fun getIngredientsByBarcode(@Path(value = "barcode") barcode: String?): ProductState
Link copied to clipboard
@GET(value = "photographer/{contributor}/state/to-be-completed/{page}.json?nocache=1")
abstract suspend fun getPicturesContributedIncompleteProducts(@Path(value = "contributor") contributor: String?, @Path(value = "page") page: Int): Search
Link copied to clipboard
@GET(value = "/photographer/{contributor}/{page}.json?nocache=1")
abstract suspend fun getPicturesContributedProducts(@Path(value = "contributor") contributor: String, @Path(value = "page") page: Int): Search
Link copied to clipboard
@GET(value = "api/v0/product/{barcode}.json")
abstract suspend fun getProductByBarcode(    @Path(value = "barcode") barcode: String,     @Query(value = "fields") fields: String,     @Query(value = "lc") locale: String,     @Header(value = "User-Agent") header: String): ProductState
Link copied to clipboard
@GET(value = "brand/{brand}/{page}.json")
abstract suspend fun getProductByBrands(    @Path(value = "brand") brand: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "category/{category}/{page}.json")
abstract suspend fun getProductByCategory(    @Path(value = "category") category: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "store/{store}/{page}.json")
abstract suspend fun getProductByStores(    @Path(value = "store") store: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "api/v0/product/{barcode}.json?fields=images")
abstract suspend fun getProductImages(@Path(value = "barcode") barcode: String): ObjectNode

Returns images for the current product

Link copied to clipboard
@GET(value = "additive/{Additive}.json")
abstract suspend fun getProductsByAdditive(@Path(value = "Additive") additive: String?, @Query(value = "fields") fields: String?): Search

@GET(value = "additive/{additive}/{page}.json")
abstract suspend fun getProductsByAdditive(    @Path(value = "additive") additive: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search

call API service to return products using Additives

Link copied to clipboard
@GET(value = "allergen/{allergen}/{page}.json")
abstract suspend fun getProductsByAllergen(    @Path(value = "allergen") allergen: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "code/{Code}.json")
abstract suspend fun getProductsByBarcode(@Path(value = "Code") code: String): Search
@GET(value = "api/v0/search")
abstract suspend fun getProductsByBarcode(    @Query(value = "code") barcodes: String,     @Query(value = "fields") fields: String,     @Header(value = "User-Agent") header: String): Search
Link copied to clipboard
@GET(value = "brand/{brand}.json")
abstract suspend fun getProductsByBrand(@Path(value = "brand") brand: String): Search
Link copied to clipboard
@GET(value = "category/{category}.json")
abstract suspend fun getProductsByCategory(@Path(value = "category") category: String): Search
Link copied to clipboard
@GET(value = "city/{city}.json")
abstract suspend fun getProductsByCity(@Path(value = "city") city: String): Search
Link copied to clipboard
@GET(value = "contributor/{contributor}/{page}.json?nocache=1")
abstract suspend fun getProductsByContributor(    @Path(value = "contributor") contributor: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "country/{country}/{page}.json")
abstract suspend fun getProductsByCountry(    @Path(value = "country") country: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "entry-dates/{EntryDates}.json")
abstract suspend fun getProductsByEntryDates(@Path(value = "EntryDates") entryDates: String): Search
Link copied to clipboard
@GET(value = "informer/{informer}.json?nocache=1")
abstract suspend fun getProductsByInformer(@Path(value = "informer") informer: String?): Search
Link copied to clipboard
@GET(value = "ingredient/{ingredient}.json")
abstract suspend fun getProductsByIngredient(@Path(value = "ingredient") ingredient: String): Search
Link copied to clipboard
@GET(value = "label/{label}.json")
abstract suspend fun getProductsByLabel(@Path(value = "label") label: String): Search
@GET(value = "label/{label}/{page}.json")
abstract suspend fun getProductsByLabel(    @Path(value = "label") label: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "language/{language}.json")
abstract suspend fun getProductsByLanguage(@Path(value = "language") language: String): Search
Link copied to clipboard
@GET(value = "last-edit-date/{LastEditDate}.json")
abstract suspend fun getProductsByLastEditDate(@Path(value = "LastEditDate") lastEditDate: String): Search
Link copied to clipboard
@GET(value = "manufacturing-place/{manufacturing-place}/{page}.json")
abstract suspend fun getProductsByManufacturingPlace(    @Path(value = "manufacturing-place") manufacturingPlace: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "nutrition-grade/{nutriscore}.json")
abstract suspend fun getProductsByNutriScore(@Path(value = "nutriscore") nutritionGrade: String): Search
Link copied to clipboard
@GET(value = "origin/{origin}/{page}.json")
abstract suspend fun getProductsByOrigin(    @Path(value = "origin") origin: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "packager-code/{packager_code}.json")
abstract suspend fun getProductsByPackagerCode(@Path(value = "packager_code") packagerCode: String): Search
Link copied to clipboard
@GET(value = "packaging/{packaging}.json")
abstract suspend fun getProductsByPackaging(@Path(value = "packaging") packaging: String): Search
@GET(value = "packaging/{packaging}/{page}.json")
abstract suspend fun getProductsByPackaging(    @Path(value = "packaging") packaging: String,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String): Search
Link copied to clipboard
@GET(value = "period-after-opening/{PeriodAfterOpening}.json")
abstract fun getProductsByPeriodAfterOpening(@Path(value = "PeriodAfterOpening") periodAfterOpening: String): Call<Search>
Link copied to clipboard
@GET(value = "photographer/{Photographer}.json?nocache=1")
abstract suspend fun getProductsByPhotographer(@Path(value = "Photographer") photographer: String): Search
Link copied to clipboard
@GET(value = "purchase-place/{purchasePlace}.json")
abstract suspend fun getProductsByPurchasePlace(@Path(value = "purchasePlace") purchasePlace: String): Search
Link copied to clipboard
@GET(value = "state/{state}.json")
abstract suspend fun getProductsByState(@Path(value = "state") state: String, @Query(value = "fields") fields: String): Search
@GET(value = "state/{State}/{page}.json")
abstract suspend fun getProductsByState(    @Path(value = "State") state: String?,     @Path(value = "page") page: Int,     @Query(value = "fields") fields: String?): Search
Link copied to clipboard
@GET(value = "store/{store}.json")
abstract suspend fun getProductsByStore(@Path(value = "store") store: String): Search
Link copied to clipboard
@GET(value = "trace/{trace}.json")
abstract suspend fun getProductsByTrace(@Path(value = "trace") trace: String): Search
Link copied to clipboard
@GET(value = "unknown-nutrient/{UnknownNutrient}.json")
abstract suspend fun getProductsByUnknownNutrient(@Path(value = "UnknownNutrient") unknownNutrient: String): Search
Link copied to clipboard
@GET(value = "cgi/suggest.pl")
abstract suspend fun getSuggestions(@Query(value = "tagtype") tagType: String, @Query(value = "term") term: String): ArrayList<String>
Link copied to clipboard
@GET
abstract suspend fun getTaglineLanguages(@Header(value = "User-Agent") header: String): ArrayList<TagLineLanguage>

This method gives the news in all languages

Link copied to clipboard
@GET(value = "contributor/{contributor}/state/to-be-completed/{page}.json?nocache=1")
abstract suspend fun getToBeCompletedProductsByContributor(@Path(value = "contributor") contributor: String, @Path(value = "page") page: Int): Search
Link copied to clipboard
@GET(value = "/1.json?fields=null")
abstract suspend fun getTotalProductCount(@Header(value = "User-Agent") header: String): Search

This method is used to get the number of products on Open X Facts

Link copied to clipboard
@GET(value = "/cgi/ingredients.pl?process_image=1&ocr_engine=google_cloud_vision")
abstract suspend fun performOCR(@Query(value = "code") code: String, @Query(value = "id") imgId: String): JsonNode
Link copied to clipboard
@Multipart
@POST(value = "/cgi/product_image_upload.pl")
abstract suspend fun saveImage(@PartMap fields: Map<String, @JvmSuppressWildcards RequestBody?>): JsonNode
Link copied to clipboard
@FormUrlEncoded
@POST(value = "cgi/product_jqm2.pl")
abstract suspend fun saveProduct(    @Field(value = "code") code: String?,     @FieldMap parameters: Map<String?, @JvmSuppressWildcards String?>?,     @Field(value = "comment") comment: String?): ProductState
Link copied to clipboard
@GET(value = "cgi/search.pl?search_simple=1&json=1&action=process")
abstract suspend fun searchProductByName(    @Query(value = "search_terms") name: String,     @Query(value = "fields") fields: String,     @Query(value = "page") page: Int): Search
Link copied to clipboard
@FormUrlEncoded
@POST(value = "/cgi/session.pl")
abstract suspend fun signIn(    @Field(value = "user_id") login: String?,     @Field(value = "password") password: String?,     @Field(value = ".submit") submit: String?): Response<ResponseBody>
Link copied to clipboard
@GET(value = "/cgi/product_image_unselect.pl")
abstract suspend fun unSelectImage(@Query(value = "code") code: String, @QueryMap fields: Map<String, @JvmSuppressWildcards String?>?): String