readthedocs / readthedocs.org

The source code that powers readthedocs.org
https://readthedocs.org/
MIT License
7.98k stars 3.57k forks source link

Design APIv3 #4286

Closed humitos closed 5 years ago

humitos commented 6 years ago

We have been talking about creating a new APIv3 since APIv1 is deprecated (uses old non-maintained 3rd party libs) and APIv2 is not as useful as we want (we can't query anything by slug for example).

This issue is a way to collect data/info/thoughts and start writing a document with the design proposed before coding anything new.

I also raised the idea of using GraphQL in another issue, https://github.com/rtfd/readthedocs.org/issues/4182

Suggested documents/videos/etc:

Core, feel free to edit the list below. We can use cases here to build up our opinions on what apiv3 needs

What are the problems with apiv2?

I documented some of the problems with APIv2 in a note in the docs: https://docs.readthedocs.io/en/latest/api/v2.html

Decisions made by Core Team

We are going to split the work in different phases, aiming to keep it simple but start offering an API with useful features as soon as possible.

Phase I

Next phases

Nice to have

Considerations

stsewd commented 6 years ago

Would this API also be read only?

davidfischer commented 6 years ago

Would this API also be read only?

I would say that it shouldn't be but if it helps to get it out the door it could be read-only to start and add write capability to the same endpoints later.

Adding write capabilities means having to do some form of authentication which the current API doesn't really do at all (it will use your session token if you make the call from the browser but that's about it). Getting auth right is hard and will require good amount of work and testing.

davidfischer commented 6 years ago

Also, related, impossible to find your project id now, slugs++

This is now not such a big deal! https://readthedocs.org/api/v2/project/?slug=pip

Relationships between API objects is not obvious. Return for a Project doesn't give me an easy way of querying API for versions. I have to hand construct a URL for versions. HTML URL relationship serializer would solve this problem

This is still true but it is at least better with the documentation and filtering that went live today. https://readthedocs.org/api/v2/version/?project__slug=pip

How will apiv3 be better?

I think a good idea here is to start just writing down the endpoints we think we need and what they should return. We know (I don't but I could if I looked hard enough) what API endpoints the build system uses. We know what API endpoints public documentation needs: the footer API.

Here's some thoughts to get the creative juices going:

davidfischer commented 6 years ago

Just to add a note based on a discussion with @agjohnson, I think APIv3 should require authentication. The lack of authentication in APIv1 and APIv2 makes upgrading/deprecation a huge pain. Currently, we don't have a good idea who is using the API and for what. On a similar note, the default for the API should probably be to show "my" projects and builds rather than all projects and all builds. I think this would make the API considerably more usable.

davidfischer commented 6 years ago

I think APIv3 should require authentication.

One drawback of this would be that if somebody needed to use the API during a build, they would need a way to expose their API key securely to the Read the Docs builder.

stsewd commented 6 years ago

A way to expose their api key can be with https://github.com/rtfd/readthedocs.org/issues/3992

davidfischer commented 6 years ago

A way to expose their api key can be with #3992

I was looking for this and I couldn't find it. Thanks.

modelmat commented 6 years ago

Couple of things I would definitely like to see:

agjohnson commented 5 years ago

We don't do anything special with generated index files. If anything this data will make its way into our search, but I don't know if it would warrant it's own api endpoint

stsewd commented 5 years ago

Request from #4649

API provides a feature to enable/disable build for specific branch

stsewd commented 5 years ago

Request from #4650

Query the build status of a version

jaraco commented 5 years ago

At a high level, ideally the API wouldn’t be a bolt-on consideration after the service is created, but would be the foundation on which a service is built, such that all actions available in the UI are also available in the API because the UI relies on the API to perform its operations. I realize such an approach may not be a good fit for this project in its current state, but it may be worth considering at this juncture. If you could build a v3 API that is designed to supply the complete suite of operations demanded by any client, it will help avoid cases where some basic features (like project creation) aren’t available through an API.

stsewd commented 5 years ago

Request from #2725

Create a project using the API

humitos commented 5 years ago

I update the description of this issue to write what we talked in our meeting last week and the decisions we made. I will start modifying the document proposed at #4863 soon.