【问题标题】:What's mean of the API style that matching symbols?匹配符号的 API 样式是什么意思?
【发布时间】:2015-04-21 13:40:34
【问题描述】:

API url 中的特殊匹配符号 eg: {?name} , {/other_user}

如何与客户打交道?

为什么要使用它?

参考:

https://api.github.com/repos/boot2docker/boot2docker/releases

例子:

{
"upload_url": "https://uploads.github.com/repos/boot2docker/boot2docker/releases/1161957/assets{?name}", 
"id": 1161957,
"tag_name": "v1.6.0",
"author": {
    "following_url": "https://api.github.com/users/tianon/following{/other_user}",
    "gists_url": "https://api.github.com/users/tianon/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/tianon/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/tianon/subscriptions",
    "organizations_url": "https://api.github.com/users/tianon/orgs",
    "repos_url": "https://api.github.com/users/tianon/repos",
    "events_url": "https://api.github.com/users/tianon/events{/privacy}",
}
}

【问题讨论】:

    标签: json api url github-api restful-url


    【解决方案1】:

    他们是URI templatesGitHub API documentation 包含展示使用这些模板的好处的示例。

    GitHub API 文档在其示例中使用了 Ruby uri_template 库。虽然 uri_template 是一个 Ruby gem,但您可以找到大多数流行编程语言的 URI 模板库。 This wiki(或快速的 Google 搜索)可能会帮助您找到适合您选择的语言的 URI 模板库。

    【讨论】:

    • URI 模板的最大好处是什么?
    猜你喜欢
    • 1970-01-01
    • 2010-09-29
    • 2011-04-18
    • 2011-04-07
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    • 2022-12-22
    • 1970-01-01
    相关资源
    最近更新 更多