getFood
Fetches details for one food item by FDC ID
Retrieves a single food item by an FDC ID. Optional format and nutrients can be specified.
/v1/food/{fdcId}
Usage and SDK Samples
curl -X GET "https://api.apieco.ir/fooddata/fdc/v1/food/{fdcId}?api_key=&format=&nutrients="
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.FDCApi;
import java.io.File;
import java.util.*;
public class FDCApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure API key authorization: ApiKeyAuth
ApiKeyAuth ApiKeyAuth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
ApiKeyAuth.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.setApiKeyPrefix("Token");
FDCApi apiInstance = new FDCApi();
String apiecoKey = apiecoKey_example; // String |
String apiKey = apiKey_example; // String | Don't Change The Value
String fdcId = fdcId_example; // String | FDC id of the food to retrieve
String format = format_example; // String | Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default).
array[Integer] nutrients = ; // array[Integer] | Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element.
try {
inline_response_200 result = apiInstance.getFood(apiecoKey, apiKey, fdcId, format, nutrients);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FDCApi#getFood");
e.printStackTrace();
}
}
}
import io.swagger.client.api.FDCApi;
public class FDCApiExample {
public static void main(String[] args) {
FDCApi apiInstance = new FDCApi();
String apiecoKey = apiecoKey_example; // String |
String apiKey = apiKey_example; // String | Don't Change The Value
String fdcId = fdcId_example; // String | FDC id of the food to retrieve
String format = format_example; // String | Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default).
array[Integer] nutrients = ; // array[Integer] | Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element.
try {
inline_response_200 result = apiInstance.getFood(apiecoKey, apiKey, fdcId, format, nutrients);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling FDCApi#getFood");
e.printStackTrace();
}
}
}
Configuration *apiConfig = [Configuration sharedConfig];
// Configure API key authorization: (authentication scheme: ApiKeyAuth)
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"api_key"];
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//[apiConfig setApiKeyPrefix:@"Bearer" forApiKeyIdentifier:@"api_key"];
String *apiecoKey = apiecoKey_example; //
String *apiKey = apiKey_example; // Don't Change The Value (default to 0VemvF7RetM9c3eqaowR5a8xy83u7gKspRNkR8dh)
String *fdcId = fdcId_example; // FDC id of the food to retrieve
String *format = format_example; // Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default). (optional)
array[Integer] *nutrients = ; // Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element. (optional)
FDCApi *apiInstance = [[FDCApi alloc] init];
// Fetches details for one food item by FDC ID
[apiInstance getFoodWith:apiecoKey
apiKey:apiKey
fdcId:fdcId
format:format
nutrients:nutrients
completionHandler: ^(inline_response_200 output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var FoodDataCentralApi = require('food_data_central_api');
var defaultClient = FoodDataCentralApi.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
var ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix['api_key'] = "Token"
var api = new FoodDataCentralApi.FDCApi()
var apiecoKey = apiecoKey_example; // {{String}}
var apiKey = apiKey_example; // {{String}} Don't Change The Value
var fdcId = fdcId_example; // {{String}} FDC id of the food to retrieve
var opts = {
'format': format_example, // {{String}} Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default).
'nutrients': // {{array[Integer]}} Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.getFood(apiecoKey, apiKey, fdcId, opts, callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace Example
{
public class getFoodExample
{
public void main()
{
// Configure API key authorization: ApiKeyAuth
Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer");
var apiInstance = new FDCApi();
var apiecoKey = apiecoKey_example; // String |
var apiKey = apiKey_example; // String | Don't Change The Value (default to 0VemvF7RetM9c3eqaowR5a8xy83u7gKspRNkR8dh)
var fdcId = fdcId_example; // String | FDC id of the food to retrieve
var format = format_example; // String | Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default). (optional)
var nutrients = new array[Integer](); // array[Integer] | Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element. (optional)
try
{
// Fetches details for one food item by FDC ID
inline_response_200 result = apiInstance.getFood(apiecoKey, apiKey, fdcId, format, nutrients);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling FDCApi.getFood: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: ApiKeyAuth
Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
$api_instance = new Swagger\Client\ApiFDCApi();
$apiecoKey = apiecoKey_example; // String |
$apiKey = apiKey_example; // String | Don't Change The Value
$fdcId = fdcId_example; // String | FDC id of the food to retrieve
$format = format_example; // String | Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default).
$nutrients = ; // array[Integer] | Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element.
try {
$result = $api_instance->getFood($apiecoKey, $apiKey, $fdcId, $format, $nutrients);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FDCApi->getFood: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::FDCApi;
# Configure API key authorization: ApiKeyAuth
$WWW::SwaggerClient::Configuration::api_key->{'api_key'} = 'YOUR_API_KEY';
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
#$WWW::SwaggerClient::Configuration::api_key_prefix->{'api_key'} = "Bearer";
my $api_instance = WWW::SwaggerClient::FDCApi->new();
my $apiecoKey = apiecoKey_example; # String |
my $apiKey = apiKey_example; # String | Don't Change The Value
my $fdcId = fdcId_example; # String | FDC id of the food to retrieve
my $format = format_example; # String | Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default).
my $nutrients = []; # array[Integer] | Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element.
eval {
my $result = $api_instance->getFood(apiecoKey => $apiecoKey, apiKey => $apiKey, fdcId => $fdcId, format => $format, nutrients => $nutrients);
print Dumper($result);
};
if ($@) {
warn "Exception when calling FDCApi->getFood: $@\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: ApiKeyAuth
swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# swagger_client.configuration.api_key_prefix['api_key'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.FDCApi()
apiecoKey = apiecoKey_example # String |
apiKey = apiKey_example # String | Don't Change The Value (default to 0VemvF7RetM9c3eqaowR5a8xy83u7gKspRNkR8dh)
fdcId = fdcId_example # String | FDC id of the food to retrieve
format = format_example # String | Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default). (optional)
nutrients = # array[Integer] | Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element. (optional)
try:
# Fetches details for one food item by FDC ID
api_response = api_instance.get_food(apiecoKey, apiKey, fdcId, format=format, nutrients=nutrients)
pprint(api_response)
except ApiException as e:
print("Exception when calling FDCApi->getFood: %s\n" % e)
Parameters
Name | Description |
---|---|
fdcId* |
String
FDC id of the food to retrieve
Required
|
Name | Description |
---|---|
apieco-key* |
String
Required
|
Name | Description |
---|---|
api_key* |
String
Don't Change The Value
Required
|
format |
String
Optional. 'abridged' for an abridged set of elements, 'full' for all elements (default).
|
nutrients |
array[Integer]
Optional. List of up to 25 nutrient numbers. Only the nutrient information for the specified nutrients will be returned. Should be comma separated list (e.g. nutrients=203,204) or repeating parameters (e.g. nutrients=203&nutrients=204). If a food does not have any matching nutrients, the food will be returned with an empty foodNutrients element.
|