-
-
Notifications
You must be signed in to change notification settings - Fork 929
API v2
qrush edited this page Jul 26, 2011
·
22 revisions
We've gone about as far as we can go to make API v1 better without breaking backwards compatibility. Compiled here is a non-exhaustive list of changes that will require a version bump.
-
More RESTful. Despite aspiring to be a RESTful API, some aspects of API v1 show a fundamental misunderstanding of REST. For example, it is redundant to say
DELETE /api/v1/web_hooks/remove
orDELETE /api/v1/gems/yank
. In v2, you'll be able to simply call theDELETE
method on the resource/api/v1/web_hooks
or/api/v1/gems
. To register a new web hook or gem, simplyPOST
to the same resource. To list your existing web hooks or gems, simplyGET
that resource. -
More concise. Some routes are unnecessarily long, for example
/api/v1/versions/[GEM NAME]-[GEM VERSION]/downloads/search.json
. This hierarchy serves no useful purpose. In v2, all routes should be designed to have no more than two levels of nesting. - More consistent. The API should explicitly declare what response formats are supported (e.g. JSON, Marshal, XML, YAML) and every resource should respond to a request for any supported format. If a user makes a request for a particular format, the response should always be in that format, even in the case of a 4xx error. This will make parsing responses easier.
- More complete. All methods should support a JSON-P response format, to allow anyone (including us) to build a complete RubyGems front-end. For example, the ability to update links via the API. This has the potential to dramatically increase the speed of development on RubyGems.org.
- More secure. Any methods that require authentication should only be accessible over HTTPS.
-
More semantic. Parameters (i.e. things that come after the question mark in a
GET
request) should always be optional. -
Pagination. There should be a consistent pagination scheme that can be applied to any
GET
method that can't return all of its results. I'd recommend adopting the GitHub v3 pagination scheme. - Better XML. XML responses should have non-dasherized keys (using underscores instead). This is perfectly valid XML and will make this response format more consistent with JSON and YAML responses.
Thoughts? Edit away, it's a wiki for a reason! :) -@qrush