Skip to content

More RESTful API: include resource URLs in responses

Description

At the moment, the GitLab API is distinctly non-REST in that results do not include resource URLs. You have to manually construct URLs to resources yourself with logic in the client, instead. This is particularly an issue when trying to reach "collections of Y for X" from X (e.g., collections of MRs for project 1).

For example, here's the GitHub issue response: https://developer.github.com/v3/issues/ - all the url and *_url parameters allow a client to avoid hardcoding a large number of URLs, and also to avoid having to construct URLs out of a predefined list of strings + extracted IDs, etc.

Proposal

Include links to self and related resources in API responses. I wouldn't necessarily do this the same way GitHub does - sprinkling _url attributes all over isn't that pleasant. One option might be to adopt a JSON 'standard' for the API globally., e.g., HAL, or just take a few notes from it.

Links / references

http://stateless.co/hal_specification.html

http://microformats.org/wiki/rest/opacity

https://gitlab.com/gitlab-org/gitlab-ce/issues/20070