RESTFUL API sample for blog

http://api.blog.com/

{
  "current_user_url": "https://api.blog.com/user",
  "authorizations_url": "https://api.github.com/authorizations",
  "article_search_url": "https://api.blog.com/search/article?q={query}{&page,per_page,sort,order}",
  "commit_search_url": "https://api.blog.com/search/commits?q={query}{&page,per_page,sort,order}",
  "emails_url": "https://api.blog.com/user/emails",
  "events_url": "https://api.blog.com/events",
  "followers_url": "https://api.blog.com/user/followers",
  "following_url": "https://api.blog.com/user/following{/target}",
  "keys_url": "https://api.blog.com/user/keys",
  "notifications_url": "https://api.blog.com/notifications",
  "organization_url": "https://api.blog.com/orgs/{org}",
  "rate_limit_url": "https://api.blog.com/rate_limit",
  "user_url": "https://api.blog.com/users/{user}",
  "user_organizations_url": "https://api.blog.com/user/orgs",
  "user_search_url": "https://api.blog.com/search/users?q={query}{&page,per_page,sort,order}"
}

api首页展示了该网站所有可前往的网页的url路由指引。

http://api.blog.com/users{?page,per_page,sort}

[
  {
    "login": "user1",
    "id": 1,
    "node_id": "MDQ6VXNlcjE=",
    "gravatar_id": "",
    "url": "https://api.blog.com/users/user1",
    "html_url": "https://blog.com/user1",
    "followers_url": "https://api.blog.com/users/user1/followers",
    "following_url": "https://api.blog.com/users/user1/following{/other_user}",
    "subscriptions_url": "https://api.blog.com/users/user1/subscriptions",
    "organizations_url": "https://api.blog.com/users/user1/orgs",
    "events_url": "https://api.blog.com/users/user1/events{/privacy}",
    "received_events_url": "https://api.blog.com/users/user1/received_events",
	"article_url": "https://api.blog.com/users/user1/articles/{article}",
    "type": "User",
    "site_admin": false
  },
...

这一页面根据url末尾附加的可选项(page指定显示的页数,per_page显示每页显示的条目数,sort表示对结果按一定规则进行排序)实现了对用户该要信息与网页导航的展示。数据是以数组的形式给出,不指定可选项的话,默认第一页,每页20条目,不进行排序。

http://api.blog.com/users/user1

{
  "login": "user1",
  "id": 445767,
  "node_id": "MDQ6VXNlcjQ0NTc2Nw==",
  "gravatar_id": "",
  "url": "https://api.blog.com/users/user1",
  "html_url": "https://blog.com/user1",
  "followers_url": "https://api.blog.com/users/user1/followers",
  "following_url": "https://api.blog.com/users/user1/following{/other_user}",
  "subscriptions_url": "https://api.blog.com/users/user1/subscriptions",
  "organizations_url": "https://api.blog.com/users/user1/orgs",
  "events_url": "https://api.blog.com/users/user1/events{/privacy}",
  "received_events_url": "https://api.blog.com/users/user1/received_events",
  "article_url": "https://api.blog.com/users/user1/articles/{article}",
  "type": "User",
  "site_admin": false,
  "name": null,
  "company": null,
  "blog": "",
  "location": null,
  "email": null,
  "followers": 0,
  "following": 0,
  "created_at": "2010-10-19T17:55:09Z",
  "updated_at": "2019-08-10T00:48:08Z"
}

特定的用户api页面除了在上个页面中所展示的url导航外,还多了一系列以键值对形式出现的信息概要。这些信息将在用户注册或者进行相关活动时被修改,并在此页面展示出来。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值