Debexpo REST API
Debexpo REST API
Following the discussions on #966297, UDD could extract data from a JSON API. I also believe that an API for mentors could be useful to DD for grabbing info from scripts.
This is a proposal for an implementation of an API for mentors. Being the first time for me creating an API, I look forward to any comments on the design or the implementation.
Dependencies
The modules used for building the API are:
- django rest framework, PTS, Docs
- django rest framework extentions (for nested routes), PTS, Docs
- django filters, PTS, Docs
Objects and routes
Currently two objects are exposed: Package
and PackageUpload
.
Both can be fetched from /api/packages/
and /api/uploads/
.
Single object can be fetch from /api/<object>/:id
, id
being the primary key exposed in the main listing.
Uploads of a package can also be fetched from /api/packages/:id/uploads/
as a nested collection.
Both objects have been consolidated in order to make the results nicer. For instance, PackageUpload
return directly the name of component
or distribution
instead of an id. Package
, similarly to what we have in the detail page, have uploaders (as a list of emails) and versions (as a dict of distributions/versions).
Objects can be filtered by their model attributes (not consolidated).
API management
The API is browsable.
The API is versioned using the AcceptContent header, currently at version 1
.
It is also throttled to avoid people curling the api every minutes. The current limit is at 200 which correspond to 2 requests every 15 minutes.
The API results are automatically paginated at 1000 results.
Testing
I'd like to make it available for you to test on https://debexpo.debian.net. Are you OK with me adding the required deps to the mentors package?
I did not add any tests yet as I want to validate the design/wanted results before I start writing those.