可以把中文域名进行转换的一种编码
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| key | string | 是 | 接口调用密钥 | |
| url | string | 是 | 需要编码的中文域名 | 你好.com |
| format | string | 否 | 默认encode可选decode | encode |
| type | string | 否 | 返回格式,默认json可选text | json |
[
{
"name": "key",
"type": "string",
"required": true,
"description": "接口调用密钥",
"example": ""
},
{
"name": "url",
"type": "string",
"required": true,
"description": "需要编码的中文域名",
"example": "你好.com"
},
{
"name": "format",
"type": "string",
"required": false,
"description": "默认encode可选decode",
"example": "encode"
},
{
"name": "type",
"type": "string",
"required": false,
"description": "返回格式,默认json可选text",
"example": "json"
}
]
{
"openapi": "3.1.1",
"info": {
"title": "Punycode",
"description": "可以把中文域名进行转换的一种编码",
"version": "1.0.0"
},
"paths": {
"/api/zzgj/Punycode/api.php": {
"get": {
"summary": "Punycode",
"description": "可以把中文域名进行转换的一种编码",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "url",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "你好.com"
},
"description": "需要编码的中文域名"
},
{
"name": "format",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "encode"
},
"description": "默认encode可选decode"
},
{
"name": "type",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "json"
},
"description": "返回格式,默认json可选text"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
},
"post": {
"summary": "Punycode",
"description": "可以把中文域名进行转换的一种编码",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "url",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "你好.com"
},
"description": "需要编码的中文域名"
},
{
"name": "format",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "encode"
},
"description": "默认encode可选decode"
},
{
"name": "type",
"in": "query",
"required": false,
"schema": {
"type": "string",
"example": "json"
},
"description": "返回格式,默认json可选text"
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://api.317ak.com",
"description": "当前访问入口(https)"
}
]
}
{
"code": 1,
"text": "xn--6qq79v.com"
}
Punycode 接口用于中文域名与编码格式之间的转换处理。
适用于站长工具场景,帮助开发者快速完成域名编码相关操作。
接口提供免费调用服务。
https://api-v2.317ak.com/api/zzgj/Punycode/api.php
GET、POST
本接口需要进行鉴权,请在请求地址中通过 Query 参数传递调用密钥:
key=…
其中 key 为接口调用密钥。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| key | string | 是 | 接口调用密钥 |
| url | string | 是 | 需要编码的中文域名,例如:你好.com |
| format | string | 否 | 编码模式,默认 encode,可选 decode |
| type | string | 否 | 返回格式,默认 json,可选 text |
请求成功后返回示例:
{
"code": 1,
"text": "xn--6qq79v.com"
}
| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 请求状态标识,成功时返回 1 |
| text | string | 转换后的域名编码结果 |
请求失败时返回 JSON:
{
"code":0,
"msg":"密钥错误",
"errcode":11002
}
| errcode | 含义 |
|---|---|
| 11001 | 未提供调用密钥 |
| 11002 | 密钥错误 |
| 11003 | 密钥已禁用 |
| 11004 | 积分余额不足 |
| 11005 | 请求过于频繁(QPM 限制) |
| 11006 | 接口维护中 |
| 11007 | 接口已禁用 |
| 11008 | 接口不可用 |
| 11009 | 密钥校验暂不可用 |
| 11010 | 积分系统暂不可用 |
| 11011 | 收费接口须提供有效密钥 |
| 11012 | 鉴权方式错误 |
| 11013 | 接口不存在 |
| 11014 | 请求目标地址无效 |
| 11015 | 请求目标地址不允许 |
| 11016 | 请求目标失败 |
| 11017 | 服务暂不可用 |
| 11018 | 请求方式不允许 |
| 11019 | 当前IP不在白名单内 |
| 11020 | 启用请求转发功能须提供有效密钥 |
| 11021 | 未配置可用请求转发服务 |
| 11022 | 请求转发服务不可用 |
| 11023 | 密钥已过期 |
| 11024 | 令牌分配积分不足 |
curl -G "https://api-v2.317ak.com/api/zzgj/Punycode/api.php" \
--data-urlencode "key=你的接口密钥" \
--data-urlencode "url=你好.com" \
--data-urlencode "format=encode" \
--data-urlencode "type=json"
## 注意事项
- 接口调用需要使用密钥,请妥善保管密钥信息,避免将密钥公开发布或直接暴露在前端页面、客户端代码中。
- 请求时请确保通过 HTTPS 方式访问接口地址,减少传输过程中的信息泄露风险。
- `url` 参数用于填写需要处理的中文域名,请确认域名格式正确,例如包含合法的域名后缀,避免因输入错误导致转换结果异常。
- `format` 参数默认使用 `encode`,如需将编码结果转换回原始域名,请传入 `decode`。
- `type` 参数默认返回 JSON 格式,如选择 `text`,返回内容格式会有所变化,调用方需根据实际需求处理返回结果。
- 请根据业务需求合理控制调用频率,避免短时间内大量重复请求影响接口正常使用。
- 返回结果中的 `code` 用于判断请求状态,调用方建议在获取 `text` 内容前先检查接口返回状态。curl -G "https://api-v2.317ak.com/api/zzgj/Punycode/api.php" \
--data-urlencode "key=YOUR_API_KEY" \
--data-urlencode "url=你好.com" \
--data-urlencode "format=encode" \
--data-urlencode "type=json"