企鹅wx官方翻译,可以把英文和中文进行翻译
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| key | string | 是 | 接口调用密钥 | |
| msg | string | 是 | 需要进行翻译的中英文 | 你好 |
| type | string | 否 | 输出格式,可选json/text输出 | json |
[
{
"name": "key",
"type": "string",
"required": true,
"description": "接口调用密钥",
"example": ""
},
{
"name": "msg",
"type": "string",
"required": true,
"description": "需要进行翻译的中英文",
"example": "你好"
},
{
"name": "type",
"type": "string",
"required": false,
"description": "输出格式,可选json/text输出",
"example": "json"
}
]
{
"openapi": "3.1.1",
"info": {
"title": "企鹅翻译",
"description": "企鹅wx官方翻译,可以把英文和中文进行翻译",
"version": "1.0.0"
},
"paths": {
"/api/yljk/qqfy/api.php": {
"get": {
"summary": "企鹅翻译",
"description": "企鹅wx官方翻译,可以把英文和中文进行翻译",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "msg",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "你好"
},
"description": "需要进行翻译的中英文"
},
{
"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": "企鹅翻译",
"description": "企鹅wx官方翻译,可以把英文和中文进行翻译",
"parameters": [
{
"name": "key",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "接口调用密钥"
},
{
"name": "msg",
"in": "query",
"required": true,
"schema": {
"type": "string",
"example": "你好"
},
"description": "需要进行翻译的中英文"
},
{
"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": 0,
"data": {
"sourceText": "你好",
"targetText": "Hello",
"source": "zh",
"target": "en"
}
}
企鹅翻译提供中英文互译能力,可用于需要文本翻译的应用场景。
支持用户提交中英文内容并获取对应翻译结果。
https://api-v2.317ak.com/api/yljk/qqfy/api.php
GET、POST
接口调用需要提供密钥。
首选鉴权方式:Query
通过请求参数传递密钥:
key=…
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| key | string | 是 | 接口调用密钥,通过 Query 参数 key 传递 |
| msg | string | 是 | 需要进行翻译的中英文内容,例如:你好 |
| type | string | 否 | 输出格式,可选 json 或 text,例如:json |
{
"code": 0,
"data": {
"sourceText": "你好",
"targetText": "Hello",
"source": "zh",
"target": "en"
}
}
| 字段 | 类型 | 说明 |
|---|---|---|
code |
integer | 响应状态标识,成功时返回 0 |
data |
object | 翻译结果数据 |
data.sourceText |
string | 原始待翻译文本 |
data.targetText |
string | 翻译后的文本 |
data.source |
string | 原文本语言类型 |
data.target |
string | 目标语言类型 |
当请求发生异常时,接口将返回 JSON 格式错误信息,格式如下:
{
"code": 0,
"msg": "未提供调用密钥",
"errcode": 11001
}
| 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/yljk/qqfy/api.php" \
--data-urlencode "key=你的接口密钥" \
--data-urlencode "msg=你好" \
--data-urlencode "type=json"
// PHP
$url = "https://api-v2.317ak.com/api/yljk/qqfy/api.php";
$params = [
"key" => "你的接口密钥",
"msg" => "你好",
"type" => "json"
];
$response = file_get_contents($url. "?". http_build_query($params));
echo $response;
key 参数内容,避免泄露或被他人滥用。msg 参数为必填项,请传入需要翻译的中英文内容,内容过长或包含特殊字符时请注意进行正确编码。type 参数为可选项,可根据需求选择输出格式;未填写时请按照接口默认返回格式处理。sourceText、targetText 分别表示翻译前后的文本,可根据业务需求进行展示或处理。curl -G "https://api-v2.317ak.com/api/yljk/qqfy/api.php" \
--data-urlencode "key=YOUR_API_KEY" \
--data-urlencode "msg=你好" \
--data-urlencode "type=json"