CocoaPods trunk is moving to be read-only. Read more on the blog, there are 7 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Feb 2017 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Food Facts.
| Depends on: | |
| Alamofire | >= 0 |
| SwiftyJSON | >= 0 |
FoodFactsSDK Helps you get started with our amazing API in seconds.
FoodFactsSDK is available through CocoaPods. To install it, simply add the following line to your Podfile:
For Swift 3 use :
pod "FoodFactsSDK"For Swift 2 use :
pod "FoodFactsSDK", "0.2.7"In your AppDelegate , import FoodFactsSDK.
import FoodFactsSDKNext Add Your account credentials.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FoodFacts().configuration(username: "YOUR USERNAME GOES HERE", password: "YOUR PASSWORD GOES HERE")
return true
}You’re all set and ready to go!
Use FoodFacts().categoryList to get all Categories.
FoodFacts().categoryList(callback: {response in
for Category in response.categoies{
print(Category.name)
}
})Use FoodFacts().subCategoryList(category_id: ) to get all Sub Categories. Use the parent category id for the category_id parameters.
FoodFacts().subCategoryList(category_id: 21, callback: {response in
for category in response.categoies{
for sub_category in category.subCategories{
print(sub_category.name)
}
}
})Use FoodFacts().productsByCategory(category_id: Int, subcategory_id: Int, per_page: Int, page: Int, sort_by: String) to get all products for a category.
FoodFacts().productsByCategory(category_id: 21, subcategory_id: 256, per_page: 4, page: 1, sort_by: "peg_name.sort", callback: {response in
for products in response.results.products{
print(products.title)
}
})
Use FoodFacts().productsBySearchTerm(search_term: String, per_page: Int, page: Int, sort_by: String) to get all products by search term.
FoodFacts().productsBySearchTerm(search_term: "apples", per_page: 4, page: 1, sort_by: "peg_name.sort", callback: {response in
for products in response.results.products{
print(products.title)
}
})
Use FoodFacts().productInformationByID(product_id: String) to get a product information.
FoodFacts().productInformationByID(product_id: "", callback: {response in
print(response.results.productDetail.title)
})Use FoodFacts().productInformationByUPC(upc: String) to get a product information.
FoodFacts().productInformationByUPC(upc: "075720004096", callback: {response in
print(response.results.productDetail.title)
})FFProduct contains:
FFProductIngredient)FFCategory contains:
FFSubCategory)FFSubCategory contains:
FFCategoryListResponse contains:
FFCategory)FFProductAllergen contains:
FFProductDetail contains:
FFProductIngredient contains:
FFProductNutrition contains:
FFProductReportCard contains:
FFProductResponse contains:
FFProductResults FFProductResults contains:
FFProductDetail FFProductDetail)FFProductVitamin)FFProductIngredient)FFProductAllergen)FFProductReportCard)FFProductVitamin contains:
FFProductsResponse contains:
FFProductsResults FFProductsResults contains:
FFProduct)FoodFactsSDK is available under the MIT license. See the LICENSE file for more info.