GS1 标准与编号
GS1 Digital Link:URI 是怎么拼出来的,以及标准没有承诺什么
扫描一个 GS1 Digital Link 符号,得到的是一个网址。但它并不是"里面放了个链接的二维码"。这项标准定义的是一套语法:把 GTIN、批号、序列号这些 GS1 标识符写进 URI 的路径里,让同一个符号既能被扫码系统读取,也能被浏览器打开。
本文依据 GS1 Digital Link URI Syntax 正式版 1.7.0(2026 年 8 月批准)。文中引号内的英文均为该规范原文。它是一份语法标准:规定标识符怎么写,不规定扫码后应当显示什么,也不规定这个地址最终解析到哪里。
哪些写进路径,哪些写进查询串
主标识符排在最前。对零售商品来说就是 GTIN,写在应用标识符 01 之后:
https://id.gs1.org/01/09521234543213
GTIN 一律写成 14 位。规范要求 "GTIN value to be expressed using 14 digits",所以 GTIN-8、GTIN-12、GTIN-13 要在前面补零,而不是按原本的长度书写。
key qualifier 跟在 GTIN 后面,顺序是固定的:
| 成分 | AI | 在路径中的位置 |
|---|---|---|
| 消费者商品变体(CPV) | 22 |
GTIN 之后的第一个 |
| 批号(batch/lot) | 10 |
变体之后 |
| 序列号(serial) | 21 |
最后 |
规范明确写了换顺序是不被接受的——写错顺序意味着 "the sequential ordering of the key qualifier components is not preserved"。所以这四者只有 /01/.../22/.../10/.../21/... 一种合法排列。
数据属性则完全不进路径。有效期 AI 17 不是 qualifier,规则没有含糊余地:"Data attributes and their values SHALL be expressed via the URI query string as key=value pairs."
https://id.gs1.org/01/09521234543213/10/ABC123?17=281231
这一刀切分是最容易弄错的地方:路径回答"是哪一件商品",查询串承载"关于它的事实"。
域名之后区分大小写
"Following the domain name, the remainder of the Web URI is case sensitive."
由此引出两件在实际作业中会出问题的事。
scheme 可以大写——1.7.0 把 HTTP 和 HTTPS 一并写进了语法。但批号和序列号的取值字符集同时包含大写和小写字母。于是把整个 URI 转成大写时,scheme 和数字 AI 都不受影响,小写的批号却被悄悄改成了另一个值——在接收系统看来,那就是另一个批次。
BarcodeMate 的 GS1 Digital Link QR Code 示例写成了大写形式,而它的示例批号本身就是大写,所以没有被改动。这只是该示例的一个属性,不是建议:规范通篇没有讨论大写 URI,也没有讨论 QR Code 的编码模式。
canonical 形式是给装不下网址的载体用的
规范把 canonical GS1 Digital Link URI 定义为 "The definitive GS1 Digital Link URI for a given resource, that always begins with the scheme "HTTPS" and the domain "id.gs1.org."" 它的用途说得很窄——"in some contexts (e.g., to support carriers that cannot embed a Web URI) it is necessary to identify a single well-known or default version"。
标准列出的 canonical 规则:
- scheme SHALL 为 HTTPS,域名 SHALL 为
id.gs1.org - GTIN-8、GTIN-12、GTIN-13 SHALL 保持补零到 14 位
- 查询串 SHALL NOT 含有键名不是 GS1 应用标识符的 key=value
- 若有多个 key=value,应按键名的字典序(而非数值顺序)排列
- SHALL NOT 带结尾斜杠
所以 http://example.com/01/09520123456788/22/2A?linkType=gs1:traceability 的 canonical 等价形式是 https://id.gs1.org/01/09520123456788/22/2A:域名换掉,去掉 linkType,不留结尾斜杠。
canonical 并不是你应该印在包装上的形式。用自己的域名是标准有意保留的能力,不是偏离:"A GS1 Digital Link URI can be constructed in any domain name, may contain additional key=value pairs in the query string and so on. This flexibility is a deliberate feature." 另外,仅仅使用了 id.gs1.org 域名的 URI 叫 reference GS1 Digital Link URI,这个条件比 canonical 宽松——canonical 还同时约束 scheme、查询串和结尾斜杠。
标准明确没有承诺的事
要围绕它做项目,这一节值得先看。
- 这个地址不一定能打开。 "Applications SHALL NOT assume that a URL that follows the syntax defined in this standard will point to a resolver." 解析服务属于另一份标准(GS1-Conformant Resolver Standard),不在本标准范围内。
- URI 本身不带含义。 "a GS1 Digital Link URI, like any Web URI or URL, does not have any intrinsic meaning."
- 它不改变 AI 取值的校验规则。 "Nothing in this GS1 specification changes the existing validation rules that apply to the values of GS1 Application Identifiers; this document only specifies how valid GS1 AI values shall be expressed in the GS1 Digital Link structure."
- 它不管标签上那个符号怎么用。 "The use of GS1 Digital Link URIs in data carriers is governed by the GS1 General Specifications";人类可读解释(HRI)的规则同样 "defers entirely to the GS1 General Specifications"。
还有一点规范没有提,因为不在它的范围内:把一个 GTIN 写进 URI,不等于这个 GTIN 就归你所有。商品编号来自你所在的 GS1 成员组织,编码器只负责排列字符。
哪些符号能承载它
"A GS1 Digital Link URI can be encoded natively in any data carrier that can support the encoding of a Web address (URL)." 规范举的例子是 QR codes、Data Matrix codes 和 NFC 标签,并没有给出一份封闭的符号清单。
这里也是一个常见的混淆点。GS1 Data Matrix 输入的是括号式应用标识符,例如 (01)09521234543213(17)120508(10)ABCD1234;GS1 Digital Link Data Matrix 输入的是本文通篇在讲的 URI 形式。两者印在标签上长得像,但输入内容不能互换:
| 生成器 | 应当输入什么 |
|---|---|
| GS1 Data Matrix | 括号式 AI:(01)...(10)... |
| GS1 QR Code | 括号式 AI |
| GS1 Digital Link Data Matrix | URI:https://id.gs1.org/01/... |
| GS1 Digital Link QR Code | URI |
压缩形式也存在。1.7.0 能识别压缩和部分压缩的写法,并指出早先的压缩算法 "will not be maintained after version 1.1.4",而带标志位的新形式 "expected to be used in future Application Standards"。压缩方法本身由另一份文档规定。
关于 2027 年的零售 POS
业界普遍提到 2027 年零售收银端支持二维码的时间节点。本文写作时我们无法从一手来源核实它的适用范围和具体日期:gs1.org 对我们的自动请求返回 HTTP 403,尝试的 GS1 US 页面返回 404。与其把厂商的转述当成事实复述,不如把具体口径交还给 GS1 自己的材料——用浏览器可以正常打开。URI 语法标准本身没有规定任何零售期限。
动手做一个
在 GS1 Digital Link QR Code 或 GS1 Digital Link Data Matrix 生成器里输入 URI,不要输入括号式 AI。两者都在浏览器里运行,可下载 PNG 或 SVG。想在选型前把它们和其它 GS1 载体放在一起比较,可以看每种格式的示例图。
按符号要求的尺寸打印,保留静空区,再用生产中实际使用的设备扫一次印出来的标签。屏幕上看着清楚,不等于印出来通过验证。