Everything you need to add food search, barcode lookup, and AI photo scanning to your application โ in minutes.
Production-ready SDKs with type safety, error handling, and built-in barcode scanning.
Full PHP 8.1+ support with readonly DTOs, PSR-3 logging, and server-side QR code decoding.
composer require grubscan/grubscan-php
Python 3.9+ with Pydantic models, barcode decoding via pyzbar, and context manager support.
pip install grubscan
Universal SDK for Node.js and browsers with browser barcode scanning via ZXing.
npm install @grubscan/sdk
Drop-in barcode scanner component with react-native-vision-camera integration.
npm install @grubscan/react-native
Quick start examples for each official SDK. All SDKs support food search, barcode lookup, AI photo scanning, and scan history.
composer require grubscan/grubscan-php
# Via Composer
composer require grubscan/grubscan-php
use Grubscan\GrubscanClient;
$client = new GrubscanClient([
'api_key' => 'gs_your_api_key_here',
]);
// Search for foods
$results = $client->searchFoods('chicken breast', 10);
foreach ($results->data as $food) {
echo "{$food->description}: {$food->calories} cal\n";
}
// Lookup barcode
$product = $client->lookupBarcode('074807750100');
echo $product->brandOwner;
// Upload a food photo for AI analysis
$result = $client->scanFood('/path/to/food.jpg');
echo $result->detectedFood; // "Grilled Chicken Salad"
echo $result->confidenceScore; // 0.92
echo $result->estimatedNutrition->calories;
use Grubscan\Exceptions\{AuthenticationException, NotFoundException, RateLimitException};
try {
$product = $client->lookupBarcode('123456789');
} catch (AuthenticationException $e) {
// 401 - Invalid API key
} catch (NotFoundException $e) {
// 404 - Product not found
} catch (RateLimitException $e) {
// 429 - Monthly limit reached
if ($e->isUpgradeRequired()) {
echo "Please upgrade your plan\n";
}
}
No SDK for your language? Use the REST API directly. All endpoints return JSON and use standard HTTP status codes.
https://grubscan.io/api/v1
All API requests require a Bearer token in the Authorization header. Generate API keys from your dashboard (Pro/Scale plans).
Authorization: Bearer gs_your_api_key_here
/foods
Search the USDA FoodData Central database by food name. Returns matching foods with per-100g macros.
# Query parameters:
?query=chicken (required)
&limit=20 (max 100)
&offset=0 (pagination)
/foods/{fdcId}
Retrieve full nutritional data for a specific USDA food by its FDC ID.
# Example:
GET /api/v1/foods/171477
/barcode/{barcode}
Look up a product by GTIN/UPC/EAN. Falls back to Open Food Facts when USDA has no match.
# Example:
GET /api/v1/barcode/074807750100
/scans
Upload a food image (multipart/form-data). Returns detected food name, confidence score, and nutritional breakdown.
# Form data:
image: <binary file> (required, max 10MB)
/scans
Get paginated list of all AI photo scans for the authenticated tenant.
# Query parameters:
?page=1 (pagination)
/scans/{id}
Retrieve details of a specific scan by its ID.
# Example:
GET /api/v1/scans/01jqxxxxxx
{
"data": {
"scan_id": 42,
"detected_food": "Grilled Chicken Salad",
"confidence_score": 0.92,
"all_predictions": [
{ "name": "Grilled Chicken Salad", "confidence": 0.92 },
{ "name": "Caesar Salad", "confidence": 0.65 }
],
"estimated_nutrition": {
"calories": 350,
"protein": 32.0,
"fat": 14.0,
"carbs": 18.0,
"fibre": 4.5,
"serving_size": "1 bowl (approx 350g)"
},
"usda_enhanced": false
}
}
200 Success201 Created (scan submitted)400 Bad Request401 Unauthorized - Invalid API key403 Forbidden - Account suspended404 Not Found422 Validation Error429 Rate Limit - Upgrade required500 Server ErrorEach plan has a monthly API quota. When exceeded, the API returns:
{
"error": "Rate limit exceeded",
"upgrade_required": true,
"retry_after": 3600
}
Generate an API key from the API Keys page (Pro/Scale plans), then authenticate every request with a Bearer token.
curl -X POST https://grubscan.io/api/v1/scans \
-H "Authorization: Bearer gs_YOUR_API_KEY" \
-F "image=@/path/to/meal.jpg"
Need support for another language? Reach out for custom integration help or request an official SDK.
Need GrubScan in another language? Contact us for support with your technical integration.
We are constantly expanding our library of official SDKs. If we don't currently support the language or framework you need, please reach out and let us know.
Sign up for free, generate your first API key, and make your first request in under two minutes.