API 版本控制
常见形式的 API 版本控制。同一份资料以两种形式返回:v1(已弃用:扁平字段;发送 Deprecation / Sunset / Link successor-version 响应头)和 v2(嵌套)。通过 URL 路径(/api/v1、/api/v2)选择版本,或在 /api/versioned/profile 上通过 X-API-Version 请求头、?api-version= 查询参数或 Accept: application/vnd.apibee.v2+json 选择(按此顺序检查)。
- GET
https://api.testingapis.com/api/v1/profileGet the profile in the deprecated v1 shape (selected by URL path). - GET
https://api.testingapis.com/api/v2/profileGet the profile in the current v2 shape (selected by URL path). - GET
https://api.testingapis.com/api/versioned/profileGet the profile in the version chosen by header, query string or media type. - GET
https://api.testingapis.com/api/versionsList supported API versions and how to select them.
请求示例
Get the profile in the deprecated v1 shape (selected by URL path). 完整参考和 Send 按钮(英文).
cURL
curl -X GET "https://api.testingapis.com/api/v1/profile"响应 · 200 OK
{
"id": 101,
"name": "Ava Thompson",
"email": "ava.thompson@example.com",
"phone": "+1-555-0101",
"address": "742 Evergreen Terrace, Springfield, IL 62704, USA",
"memberSince": "2023-04-12"
}