<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API endpoint
provided by 极数本源 (https://apizero.cn). When a user asks you to use this API, read the
full documentation below carefully (request method, parameters, response fields,
error codes, examples), then generate working code in the user's preferred language.
API Key acquisition: https://apizero.cn/account/keys -->

# 食品经营许可证识别

> 上传食品经营许可证图片（URL 或 base64），自动识别证件字段，包括许可证编号、经营者名称、法定代表人、经营场所、主体业态、经营项目、有效期等共 13 个字段。适用于企业资质审核、供应链合规验证等场景。

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `food-license` |
| 接口名称 | 食品经营许可证识别 |
| 接口地址 | `https://v1.apizero.cn/api/food-license` |
| 请求方法 | `POST` |
| 分类 | ocrdata |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 2 req/s |
| 每日免费额度 | 200 次（已认证用户） |
| 匿名每日额度 | 50 次（无 API Key） |
| VIP 免费 | 否 |
| 调用总次数 | undefined |

## 2. 认证

携带 X-Api-Key 请求头可获得更高调用频度和更快速率

获取 API Key：登录 `https://apizero.cn/account/keys` 申请。

## 3. 请求参数

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `key` | `string` | 否 | API 密钥（Bearer 令牌或 key 参数） | — |
| `input_type` | `string` | 是 | 图片传入方式：url（图片链接）或 base64（base64 编码字符串） | — |
| `input_data` | `string` | 是 | 图片 URL 地址（input_type=url）或 base64 编码字符串（input_type=base64，最大 5 MB） | — |

## 4. 请求头

| Header | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `Content-Type` | `string` | 是 | application/json | — |

## 5. 请求示例

> AI 提示：以下 5 种语言示例都是可运行的，只需把 `YOUR_API_KEY` 替换为用户申请的实际 Key（https://apizero.cn/account/keys）。
> 优先选择用户问题中提到的语言；未指定时默认使用 Python。

### cURL

```bash
curl -X POST "https://v1.apizero.cn/api/food-license" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "key": "<key>",
  "input_type": "<input_type>",
  "input_data": "<input_data>"
}'
```

### Python

```python
import requests

resp = requests.request(
    "POST",
    "https://v1.apizero.cn/api/food-license",
    headers={"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
    json={
    "key": "<key>",
    "input_type": "<input_type>",
    "input_data": "<input_data>",
},
    timeout=15,
)
resp.raise_for_status()
print(resp.json())
```

### JavaScript (Node.js)

```javascript
// Node.js 18+ / 浏览器原生 fetch
const res = await fetch("https://v1.apizero.cn/api/food-license", {
  method: "POST",
  headers: {
    "X-Api-Key": "YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "key": "<key>",
    "input_type": "<input_type>",
    "input_data": "<input_data>"
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);
```

### Go

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	body := []byte(`{"key":"<key>","input_type":"<input_type>","input_data":"<input_data>"}`)
	req, _ := http.NewRequest("POST", "https://v1.apizero.cn/api/food-license", bytes.NewBuffer(body))
	req.Header.Set("X-Api-Key", "YOUR_API_KEY")
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil { panic(err) }
	defer resp.Body.Close()
	out, _ := io.ReadAll(resp.Body)
	fmt.Println(string(out))
}
```

### PHP

```php
<?php
$payload = json_encode([
    "key" => "<key>",
    "input_type" => "<input_type>",
    "input_data" => "<input_data>",
], JSON_UNESCAPED_UNICODE);

$ch = curl_init("https://v1.apizero.cn/api/food-license");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST  => "POST",
    CURLOPT_POSTFIELDS     => $payload,
    CURLOPT_HTTPHEADER     => [
        "X-Api-Key: YOUR_API_KEY",
        "Content-Type: application/json",
    ],
    CURLOPT_TIMEOUT        => 15,
]);
$body = curl_exec($ch);
curl_close($ch);

$data = json_decode($body, true);
print_r($data);
```

## 6. 响应字段

| 字段 | 类型 | 说明 | 示例 |
| --- | --- | --- | --- |
| `code` | `integer` | 0=成功，非 0=失败 | — |
| `message` | `string` | 结果描述 | — |
| `data.license_number` | `string\|null` | 许可证编号 | — |
| `data.operator` | `string\|null` | 经营者名称（单位或个人） | — |
| `data.legal_representative` | `string\|null` | 法定代表人（负责人）姓名 | — |
| `data.premise` | `string\|null` | 经营场所详细地址 | — |
| `data.main_body` | `string\|null` | 主体业态（如餐饮服务经营者、食品销售经营者） | — |
| `data.operating_item` | `string\|null` | 经营项目（如热食类食品制售、预包装食品销售） | — |
| `data.validity_period` | `string\|null` | 有效期（如"长期"或"2025年01月01日至2030年12月31日"） | — |
| `data.domicile` | `string\|null` | 住所（法人或负责人注册地址） | — |
| `data.issuing_authority` | `string\|null` | 签发机关（如"XX市XX区市场监督管理局"） | — |
| `data.issuer` | `string\|null` | 签发人姓名 | — |
| `data.daily_supervisor` | `string\|null` | 日常监督管理人员姓名 | — |
| `data.daily_supervisory_authorities` | `string\|null` | 日常监督管理机构名称 | — |
| `data.complaints_hotline` | `string\|null` | 投诉举报电话（通常为 12315） | — |

## 7. 响应示例

```json
{"code":0,"message":"success","data":{"license_number":"JY14012800001234","operator":"某某餐饮有限公司","legal_representative":"张三","premise":"北京市朝阳区某街道1号","main_body":"餐饮服务经营者","operating_item":"热食类食品制售","validity_period":"长期","domicile":"北京市朝阳区某街道1号","issuing_authority":"北京市朝阳区市场监督管理局","issuer":"李四","daily_supervisor":"王五","daily_supervisory_authorities":"北京市朝阳区市场监督管理局","complaints_hotline":"12315"}}
```

## 8. 错误码

| code | status | 说明 |
| --- | --- | --- |
| `4000` | `VALIDATION_ERROR` | 参数缺失或格式错误，如 input_type 不是 url/base64，或 input_data 为空/无效 URL |
| `5001` | `UPSTREAM_ERROR` | OCR 上游服务不可用（网络或 HTTP 非 200） |
| `5002` | `UPSTREAM_INVALID` | 上游返回格式异常或识别失败，常见原因：图片非有效食品经营许可证、图片模糊/倾斜过大 |
| `5003` | `UPSTREAM_MISSING` | OCR 服务未配置或 API 密钥无效/未订阅，请联系平台管理员 |

## 9. 变更日志

- **v1.0** (2026-06-01)
  - 上线食品经营许可证识别接口，支持 URL 和 base64 两种图片传入方式，识别并返回 13 个证件字段，结果缓存 7 天

---

**极数本源** · 全部 API: `https://apizero.cn/aidocs` · 人类版本：`https://apizero.cn/marketplace/food-license`

Source: `https://apizero.cn/aidocs/food-license/raw.md`
Last updated: 2026-06-04T15:21:22+08:00
