import { useState } from "react"; import { Check, Copy } from "lucide-react"; const ORIGIN = typeof window !== "undefined" ? window.location.origin : "https://goods.tangshasha.com"; const BASE = `${ORIGIN}/api/v1`; function CopyBtn({ text }: { text: string }) { const [done, setDone] = useState(false); return ( ); } function Code({ children }: { children: string }) { return (
        {children}
      
); } function Method({ m }: { m: string }) { const color = m === "GET" ? "bg-sky-100 text-sky-700" : "bg-emerald-100 text-emerald-700"; return {m}; } type Param = { name: string; required?: boolean; desc: string }; function Endpoint({ method, path, title, desc, params, example, response, }: { method: string; path: string; title: string; desc: string; params?: Param[]; example: string; response: string; }) { return (
{path}
{title}

{desc}

{params && params.length > 0 && ( {params.map((p) => ( ))}
参数 必填 说明
{p.name} {p.required ? "是" : "否"} {p.desc}
)}
请求示例
{example}
返回示例
{response}
); } export default function ApiDocs() { return (

API 调用说明

天工商品档案公共仓提供公开、只读、免鉴权的商品事实 REST API,任何人都可直接调用, 用于按条码/名称查询商品的客观资料(品牌、品类、净含量、产地、配料、营养成分、Nutri-Score、 厂商建议零售价快照等)。返回均为 JSON(UTF-8)。本服务不含任何购买/交易接口。

基础地址:{BASE}
  • 无需 API Key / Token,直接 GET 即可。
  • 分页参数 page(默认 1)、 size(默认 20,最大 100)。
  • 未找到资源返回 404,错误体形如 {` {"error":{"code","message","request_id"}}`}
  • 请合理控制调用频率;商品数据遵循各来源许可,引用时请注明天工商品档案公共仓及原始来源。
数据可能存在误差或滞后,按「现状」提供,不构成医疗/购买建议。商品资料版权归各原始来源所有, 请遵循其许可(如 OpenFoodFacts 的 ODbL)。
); }