DOCS

获取交路运行图图片

根据交路表和首末站坐标生成交路运行图

返回 API 列表
get/api/v1/timetable/train/{trainCode}/circulation/image
可匿名访问api.timetable.train.circulation.image.read

COST

扣费规则

根据上游 LaTeX 编译是否命中缓存决定扣费档位。

缓存命中 2 点/次,缓存未命中 20 点/次,失败 2 点/次

实际扣费以响应头 x-api-cost 为准。

请求说明

参数

路径参数

trainCodestring 必填

要查询的车次号,例如 D2212。

示例:D2212

查询参数

formatpng | pdf

运行图输出格式;留空时默认使用 png。

示例:png

binarytrue | false

当值为 true 时,接口直接返回原始二进制内容;否则返回 JSON 包裹结构。

示例:false

响应说明

状态码与响应格式

200

运行图生成成功。

响应头

x-api-remainx-api-cost
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "ok",
        "data",
        "error"
    ],
    "properties": {
        "ok": {
            "type": "boolean",
            "required": true
        },
        "data": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "requestTrainCode",
                    "trainCode",
                    "documentId",
                    "imageUrl"
                ],
                "properties": {
                    "requestTrainCode": {
                        "type": "string",
                        "required": true
                    },
                    "trainCode": {
                        "type": "string",
                        "required": true
                    },
                    "documentId": {
                        "type": "string",
                        "required": true
                    },
                    "imageUrl": {
                        "type": "string",
                        "required": true
                    }
                }
            }
        },
        "error": {
            "type": "string",
            "required": true
        }
    }
}

示例响应

{
    "ok": true,
    "data": {
        "requestTrainCode": "G2492",
        "trainCode": "G2492",
        "documentId": "8d2fca6e88c2a1e3c2106a4f28f0d5e7b3147427ec8d1b4af75a4b6b485b92ce",
        "imageUrl": "http://127.0.0.1:8080/8d2fca6e88c2a1e3c2106a4f28f0d5e7b3147427ec8d1b4af75a4b6b485b92ce/png/1"
    },
    "error": ""
}
image/pngstring

响应结构

{
    "type": "string"
}
application/pdfstring

响应结构

{
    "type": "string"
}
400

路径参数、binary 查询参数或 format 查询参数无效。

响应头

x-api-remainx-api-cost
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "ok",
        "data",
        "error"
    ],
    "properties": {
        "ok": {
            "type": "boolean",
            "required": true
        },
        "data": {
            "type": "string",
            "required": true
        },
        "error": {
            "type": "string",
            "required": true
        }
    }
}

示例响应

{
    "ok": false,
    "data": "binary 必须是 true/false",
    "error": "invalid_param"
}
404

当前时刻表或交路数据不可用。

响应头

x-api-remainx-api-cost
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "ok",
        "data",
        "error"
    ],
    "properties": {
        "ok": {
            "type": "boolean",
            "required": true
        },
        "data": {
            "type": "string",
            "required": true
        },
        "error": {
            "type": "string",
            "required": true
        }
    }
}

示例响应

{
    "ok": false,
    "data": "当前暂无交路数据",
    "error": "not_found"
}
422

今日时刻表数据不完整,无法生成运行图。

响应头

x-api-remainx-api-cost
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "ok",
        "data",
        "error"
    ],
    "properties": {
        "ok": {
            "type": "boolean",
            "required": true
        },
        "data": {
            "type": "string",
            "required": true
        },
        "error": {
            "type": "string",
            "required": true
        }
    }
}

示例响应

{
    "ok": false,
    "data": "交路节点 G2492 的首末站缺少经纬度",
    "error": "invalid_schedule_data"
}
502

上游 LaTeX 渲染服务不可用或编译失败。

响应头

x-api-remainx-api-cost
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "ok",
        "data",
        "error"
    ],
    "properties": {
        "ok": {
            "type": "boolean",
            "required": true
        },
        "data": {
            "type": "string",
            "required": true
        },
        "error": {
            "type": "string",
            "required": true
        }
    }
}

示例响应

{
    "ok": false,
    "data": "运行图渲染服务暂时不可用",
    "error": "upstream_unavailable"
}