# FDA Product Lookup

**GET** `/v1/inventory/fda-lookup`

Proxies a barcode lookup against the open.fda.gov API. Automatically detects the barcode type (NDC, UDI/GS1, or UPC) and queries the appropriate FDA dataset. Results are cached for 24 hours per barcode.

### Query parameters

| Field | Type | Description |
|---|---|---|
| `barcode` | string | NDC, UDI, UPC, or GS1 barcode |
| `category` | string | FDA product category: `drug`, `device`, `food`, or `auto` (default). Use `auto` to let the platform detect from the barcode format. |

### Category values

| Value | FDA dataset queried | Typical use case |
|---|---|---|
| `auto` | Detected from barcode format (see below) | General-purpose; works for most tenants |
| `drug` | FDA Drug Label (`drug/label.json`) via NDC | Pharmacy, wholesale drug distribution |
| `device` | FDA Device UDI (`device/udi.json`) | Medical device distributors |
| `food` | FDA Food enforcement | Food & beverage retail |

### Barcode type detection (when category = auto)

| Type | Pattern | Dataset queried |
|---|---|---|
| `ndc` | 10–11 digits | FDA Drug NDC |
| `udi` | Starts with `01` prefix (GS1) | FDA Device UDI |
| `upc` | Other formats | FDA Drug NDC → Drug Label fallback |

### Response fields

| Field | Type | Description |
|---|---|---|
| `barcode` | string | The barcode queried |
| `barcode_type` | string | `ndc`, `udi`, or `upc` |
| `cached` | boolean | Whether the result came from the 24h cache |
| `product.product_name` | string | Brand or device name |
| `product.brand` | string | Brand name |
| `product.generic_name` | string | Generic / INN name |
| `product.manufacturer` | string | Labeller / manufacturer name |
| `product.dosage_form` | string | e.g. `TABLET`, `CAPSULE` |
| `product.strength` | string | Active ingredient(s) with strength |
| `product.package_description` | string | Package size/type |
| `product.application_number` | string | FDA NDA/ANDA/510k number |
| `product.source` | string | `fda_drug_ndc`, `fda_device_udi`, `fda_drug_label_ndc`, or `fda_food` |

### Error codes

- `400` — Invalid `category` value.
- `404` — No FDA record found for the barcode.
- `502` — FDA API unavailable or timed out (8s timeout).
