API 文档

返回单一车组的配属信息

返回一个动车组的配属基础信息,包括车型、配属路局、动车段/所、制造商、速度等级、座椅与服务设施,以及车厢布局。

返回 API 列表
get/api/v2/allocation/emu/{emuCode}
可匿名访问api.allocation.emu.read

场景

适用场景

这个接口适合用在什么地方?下面的场景可以帮你判断它是不是你要找的那个。

  • 做车组详情页,展示车型、配属和车厢布局。
  • 根据 designMaxSpeed 与 operatingMaxSpeed 判断车组适用线路。
  • 展示 coachLayouts,帮助乘客了解车厢座席类型与充电设施。

问答

常见问题

接入时最常遇到的疑问,先看看这里能不能解答。

emuCodeMappings 在这里有什么用?

接口支持别名查询:你传入的编号会被标准化成 emuId,然后通过 emuCodeMappings 返回对应的标准车组编号,方便确认查询结果。

为什么有些字段是空字符串?

v2 约定隐式字段(如 subModel、customType、note)总是返回,没有数据时返回默认值(空字符串、0 或 false),可选项才会省略。

扣费

扣费规则

每次请求按固定额度扣费,不随返回条数变化。

固定 1 点额度/次

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

请求说明

参数

路径参数

emuCodestring 必填

要查询的车组编号,例如 CR400AF-C-2214。车组编号区分大小写,请按页面展示的格式填写。

示例:CR400AF-C-2214

响应说明

状态码与响应格式

200

动车组配属基础信息。

响应头

x-api-remainx-api-costRetry-After
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "meta",
        "data"
    ],
    "properties": {
        "meta": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "remain",
                    "cost"
                ],
                "properties": {
                    "remain": {
                        "type": "integer",
                        "required": true
                    },
                    "cost": {
                        "type": "integer",
                        "required": true
                    },
                    "retryAfter": {
                        "type": "integer"
                    }
                }
            }
        },
        "data": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "emuId",
                    "model",
                    "trainSetNo",
                    "bureau",
                    "trainDepot",
                    "depot",
                    "subModel",
                    "customType",
                    "trainsetManufacturer",
                    "trailerManufacturer",
                    "manufactureMonth",
                    "designMaxSpeed",
                    "operatingMaxSpeed",
                    "isPublic",
                    "railwayTravelCodeEnabled",
                    "firstClassPowerLegrest",
                    "toiletStatus",
                    "socketLocation",
                    "businessSeatType",
                    "modelRemark",
                    "note",
                    "tags",
                    "alias",
                    "coachLayouts"
                ],
                "properties": {
                    "emuId": {
                        "type": "integer",
                        "required": true
                    },
                    "emuCodeMappings": {
                        "type": "object",
                        "shape": {
                            "type": "object"
                        }
                    },
                    "model": {
                        "type": "string",
                        "required": true
                    },
                    "trainSetNo": {
                        "type": "string",
                        "required": true
                    },
                    "bureau": {
                        "type": "string",
                        "required": true
                    },
                    "trainDepot": {
                        "type": "string",
                        "required": true
                    },
                    "depot": {
                        "type": "string",
                        "required": true
                    },
                    "subModel": {
                        "type": "string",
                        "required": true
                    },
                    "customType": {
                        "type": "string",
                        "required": true
                    },
                    "trainsetManufacturer": {
                        "type": "string",
                        "required": true
                    },
                    "trailerManufacturer": {
                        "type": "string",
                        "required": true
                    },
                    "manufactureMonth": {
                        "type": "string",
                        "required": true
                    },
                    "designMaxSpeed": {
                        "type": "integer",
                        "required": true
                    },
                    "operatingMaxSpeed": {
                        "type": "integer",
                        "required": true
                    },
                    "isPublic": {
                        "type": "boolean",
                        "required": true
                    },
                    "railwayTravelCodeEnabled": {
                        "type": "boolean",
                        "required": true
                    },
                    "firstClassPowerLegrest": {
                        "type": "boolean",
                        "required": true
                    },
                    "toiletStatus": {
                        "type": "string",
                        "required": true
                    },
                    "socketLocation": {
                        "type": "string",
                        "required": true
                    },
                    "businessSeatType": {
                        "type": "string",
                        "required": true
                    },
                    "modelRemark": {
                        "type": "string",
                        "required": true
                    },
                    "note": {
                        "type": "string",
                        "required": true
                    },
                    "tags": {
                        "type": "array<string>",
                        "required": true,
                        "shape": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    },
                    "alias": {
                        "type": "array<string>",
                        "required": true,
                        "shape": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    },
                    "coachLayouts": {
                        "type": "array<object>",
                        "required": true,
                        "shape": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "required": [
                                    "coachNo",
                                    "coachTypeCode",
                                    "coachTypeName",
                                    "capacity",
                                    "hasPower",
                                    "hasPantograph",
                                    "hasLargeLuggageArea",
                                    "hasAccessibleFacility"
                                ],
                                "properties": {
                                    "coachNo": {
                                        "type": "integer",
                                        "required": true
                                    },
                                    "coachTypeCode": {
                                        "type": "string",
                                        "required": true
                                    },
                                    "coachTypeName": {
                                        "type": "string",
                                        "required": true
                                    },
                                    "capacity": {
                                        "type": "integer",
                                        "required": true
                                    },
                                    "hasPower": {
                                        "type": "boolean",
                                        "required": true
                                    },
                                    "hasPantograph": {
                                        "type": "boolean",
                                        "required": true
                                    },
                                    "hasLargeLuggageArea": {
                                        "type": "boolean",
                                        "required": true
                                    },
                                    "hasAccessibleFacility": {
                                        "type": "boolean",
                                        "required": true
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

示例响应

{
    "ok": true,
    "data": {
        "emuId": 954,
        "emuCodeMappings": {
            "954": "CR400AF-C-2214"
        },
        "model": "CR400AF-C",
        "trainSetNo": "2214",
        "bureau": "北京局集团",
        "trainDepot": "北京动车段",
        "depot": "雄安动车所",
        "subModel": "",
        "customType": "",
        "trainsetManufacturer": "中车青岛四方",
        "trailerManufacturer": "中车青岛四方",
        "manufactureMonth": "2020-09",
        "designMaxSpeed": 350,
        "operatingMaxSpeed": 310,
        "isPublic": true,
        "railwayTravelCodeEnabled": true,
        "firstClassPowerLegrest": true,
        "toiletStatus": "蹲厕、马桶均有",
        "socketLocation": "洗手台(插座);二等座:坐垫接缝处(插座、USB Type A),前排座椅后背(USB Type A);一等座:座椅扶手前端(插座、USB Type A),前排座椅后背(USB Type A)",
        "businessSeatType": "鱼骨式",
        "modelRemark": "本车座椅靠背硬度较大,可能导致一定程度不适。",
        "note": "",
        "tags": [
            "京雄城际定制",
            "ATO"
        ],
        "alias": [],
        "coachLayouts": [
            {
                "coachNo": 1,
                "coachTypeCode": "ZYS",
                "coachTypeName": "一等/商务座车",
                "capacity": 34,
                "hasPower": false,
                "hasPantograph": false,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            },
            {
                "coachNo": 2,
                "coachTypeCode": "ZE",
                "coachTypeName": "二等座车",
                "capacity": 90,
                "hasPower": true,
                "hasPantograph": false,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            },
            {
                "coachNo": 3,
                "coachTypeCode": "ZE",
                "coachTypeName": "二等座车",
                "capacity": 90,
                "hasPower": false,
                "hasPantograph": true,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            },
            {
                "coachNo": 4,
                "coachTypeCode": "ZE",
                "coachTypeName": "二等座车",
                "capacity": 75,
                "hasPower": true,
                "hasPantograph": false,
                "hasLargeLuggageArea": true,
                "hasAccessibleFacility": true
            },
            {
                "coachNo": 5,
                "coachTypeCode": "ZEC",
                "coachTypeName": "二等座车/餐车",
                "capacity": 63,
                "hasPower": true,
                "hasPantograph": false,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            },
            {
                "coachNo": 6,
                "coachTypeCode": "ZE",
                "coachTypeName": "二等座车",
                "capacity": 90,
                "hasPower": false,
                "hasPantograph": true,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            },
            {
                "coachNo": 7,
                "coachTypeCode": "ZE",
                "coachTypeName": "二等座车",
                "capacity": 90,
                "hasPower": true,
                "hasPantograph": false,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            },
            {
                "coachNo": 8,
                "coachTypeCode": "ZES",
                "coachTypeName": "二等/商务座车",
                "capacity": 46,
                "hasPower": false,
                "hasPantograph": false,
                "hasLargeLuggageArea": false,
                "hasAccessibleFacility": false
            }
        ]
    },
    "error": ""
}
400

请求参数不合法:可能是日期格式、游标格式或 limit 不符合要求。

响应头

x-api-remainx-api-costRetry-After
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "meta",
        "error"
    ],
    "properties": {
        "meta": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "remain",
                    "cost"
                ],
                "properties": {
                    "remain": {
                        "type": "integer",
                        "required": true
                    },
                    "cost": {
                        "type": "integer",
                        "required": true
                    },
                    "retryAfter": {
                        "type": "integer"
                    }
                }
            }
        },
        "error": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "code",
                    "message"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "required": true
                    },
                    "message": {
                        "type": "string",
                        "required": true
                    }
                }
            }
        }
    }
}

示例响应

{
    "meta": {
        "remain": 159,
        "cost": 1
    },
    "error": {
        "code": "invalid_param",
        "message": "date 必须使用 YYYYMMDD 格式。"
    }
}
401

请求未携带有效的认证信息,或提供的 API Key 已失效。

响应头

x-api-remainx-api-costRetry-After
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "meta",
        "error"
    ],
    "properties": {
        "meta": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "remain",
                    "cost"
                ],
                "properties": {
                    "remain": {
                        "type": "integer",
                        "required": true
                    },
                    "cost": {
                        "type": "integer",
                        "required": true
                    },
                    "retryAfter": {
                        "type": "integer"
                    }
                }
            }
        },
        "error": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "code",
                    "message"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "required": true
                    },
                    "message": {
                        "type": "string",
                        "required": true
                    }
                }
            }
        }
    }
}

示例响应

{
    "meta": {
        "remain": 159,
        "cost": 1
    },
    "error": {
        "code": "invalid_api_key",
        "message": "API Key 无效或已过期。"
    }
}
403

当前凭证缺少调用该接口所需的 scope。

响应头

x-api-remainx-api-costRetry-After
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "meta",
        "error"
    ],
    "properties": {
        "meta": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "remain",
                    "cost"
                ],
                "properties": {
                    "remain": {
                        "type": "integer",
                        "required": true
                    },
                    "cost": {
                        "type": "integer",
                        "required": true
                    },
                    "retryAfter": {
                        "type": "integer"
                    }
                }
            }
        },
        "error": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "code",
                    "message"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "required": true
                    },
                    "message": {
                        "type": "string",
                        "required": true
                    }
                }
            }
        }
    }
}

示例响应

{
    "meta": {
        "remain": 159,
        "cost": 1
    },
    "error": {
        "code": "forbidden",
        "message": "缺少调用该接口所需的权限。"
    }
}
404

未找到该动车组的配属信息。

响应头

x-api-remainx-api-costRetry-After
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "meta",
        "error"
    ],
    "properties": {
        "meta": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "remain",
                    "cost"
                ],
                "properties": {
                    "remain": {
                        "type": "integer",
                        "required": true
                    },
                    "cost": {
                        "type": "integer",
                        "required": true
                    },
                    "retryAfter": {
                        "type": "integer"
                    }
                }
            }
        },
        "error": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "code",
                    "message"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "required": true
                    },
                    "message": {
                        "type": "string",
                        "required": true
                    }
                }
            }
        }
    }
}

示例响应

{
    "meta": {
        "remain": 159,
        "cost": 1
    },
    "error": {
        "code": "not_found",
        "message": "未找到该动车组配属信息"
    }
}
429

额度不足或请求过于频繁,建议等 Retry-After 提示的时间后再试。

响应头

x-api-remainx-api-costRetry-After
application/jsonobject

响应结构

{
    "type": "object",
    "required": [
        "meta",
        "error"
    ],
    "properties": {
        "meta": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "remain",
                    "cost"
                ],
                "properties": {
                    "remain": {
                        "type": "integer",
                        "required": true
                    },
                    "cost": {
                        "type": "integer",
                        "required": true
                    },
                    "retryAfter": {
                        "type": "integer"
                    }
                }
            }
        },
        "error": {
            "type": "object",
            "required": true,
            "shape": {
                "type": "object",
                "required": [
                    "code",
                    "message"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "required": true
                    },
                    "message": {
                        "type": "string",
                        "required": true
                    }
                }
            }
        }
    }
}

示例响应

{
    "meta": {
        "remain": 159,
        "cost": 1
    },
    "error": {
        "code": "rate_limited",
        "message": "额度不足,请稍后再试。"
    }
}