开发者

API 参考

Prezo 公共 API 通过 HTTPS 以 JSON 格式提供对您企业数据的只读访问:采购、目录、配方和销售。每个请求都使用您企业的 API 令牌进行认证。

基础 URLhttps://api.prezo.es版本v1认证Bearer

认证

每个请求都在 Authorization 头(Bearer)中携带您企业的 API 令牌。令牌属于餐厅或集团,而不是个人:餐厅令牌只能看到该门店,集团令牌可以看到套餐包含 API 的集团门店。如果套餐包含 API,由企业管理员在「管理 > API」中创建令牌,且只在创建时显示一次;如果丢失,请撤销并创建新的令牌。每个端点能读取的内容取决于您企业开通的模块。没有令牌、或令牌已被撤销或过期时,API 返回 401;如果套餐不包含 API、Prezo 已切断访问,或该数据对应的模块未开通,返回 403。

请求头
Authorization: Bearer pz_live_your_token
Accept: application/json

限制与配额

限额由套餐决定:每个餐厅有每月请求配额,由其所有令牌共同使用;每个令牌有自己的每分钟请求上限;集团令牌有自己的限额。配额于每月 1 日重置,每个餐厅和每个集团最多可有 5 个有效令牌。每个响应都会在响应头中告诉您剩余额度;超出时会收到 429,并附带 Retry-After 和 X-RateLimit-Window,后者说明触发的是每分钟限制还是每月限制。列表是分页的(page 和 perPage,最多 500),按日期查询的列表每次请求最多跨 12 个月。金额以十进制字符串("123.45")返回,以免丢失分位。在 v1 内只会新增字段:请忽略您不认识的字段。

请求头
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: 1791367260
X-Monthly-Quota-Limit: 10000
X-Monthly-Quota-Remaining: 8732
X-Monthly-Quota-Reset: 1793487600

Business

2 个端点

The business's restaurants and providers, with their fiscal data: the ids the filters use.

Recipes

2 个端点

Recipes with their cost per restaurant, sale price, food cost and the POS codes they are sold under.

Sales

2 个端点

Sales by restaurant and day, and what was sold item by item with its theoretical cost.

错误

错误遵循 RFC 9457 标准(Problem Details):以 application/problem+json 内容类型返回,并带有一个来自封闭词汇表的 code 字段。请始终根据 code 编程,而不要依赖 title 和 detail 文本,它们使用您在 Accept-Language 头中请求的语言(默认西班牙语)。每个错误还带有 requestId,同样通过 X-Request-Id 头发送:我们需要它来追踪具体的请求。

code 的可能取值
api_key_invalidapi_key_revokedapi_key_expiredsubscription_not_activemodule_inactivevalidation_failednot_foundrate_limit_exceededmonthly_quota_exceededinternal_error
错误响应示例
{
  "type": "https://errors.prezo.es/validation_failed",
  "title": "您发送的数据无效",
  "status": 422,
  "code": "validation_failed",
  "detail": "请检查 errors 中列出的字段。",
  "instance": "/public/v1/delivery-notes",
  "requestId": "01K2M7QW8YB3F4ZC5X6N7P8Q9R",
  "errors": [
    {
      "field": "dateFrom",
      "code": "in",
      "message": "所选值无效。"
    }
  ]
}