marcortola / food-data-central
Community API client for the Food Data Central USDA nutrient database
0.0.6
2021-04-18 11:11 UTC
Requires
- php: >=7.4
- ext-json: *
- php-http/discovery: ^1.7
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.5
- phpstan/phpstan: ^0.12.14
- phpstan/phpstan-strict-rules: ^0.12.2
- phpunit/phpunit: ^9.0
- symplify/easy-coding-standard: ^7.3
README
Installation
- Install Composer
- Execute:
$ composer require marcortola/food-data-central
This wrapper doesn't bundle the HTTP client so you are free to use your preferred one. You can inject it in the FoodDataCentralClient constructor or let the wrapper discover it. If you don't know what I am talking about, the fast solution is to require these packages:
$ composer require php-http/curl-client nyholm/psr7 php-http/message
Usage
$foodDataCentralClient = FoodDataCentralClient::create('your_api_key'); // Find food by FDC ID. $foodItem = $foodDataCentralClient->food()->food(781125); // Find food nutrients. See the FoodItem interface for more nutrient finders. $calcium = $foodDataCentralClient->food()->food(781125)->getCalcium();
Read the Food Data Central API documentation here.
License
Licensed under the MIT License. See License File for more information about it.