Page MenuHomePhabricator

Hard to find docs for REST api
Closed, ResolvedPublic

Description

When I navigate to https://en.wikipedia.org/api/rest_v1 I get 404
https://en.wikipedia.org/api/rest_v1/ shows me {"items":["feed","media","page","transform"]}
I then tried
https://en.wikipedia.org/api/rest_v1/help
https://en.wikipedia.org/api/rest_v1/?help
https://en.wikipedia.org/api/rest_v1/?action=help
https://en.wikipedia.org/api/rest_v1/?action=docs
https://en.wikipedia.org/api/rest_v1/?docs without any luck.

I've tried googling and can't find what the URL to the help page is.
Finally I found it in an email (https://en.wikipedia.org/api/rest_v1/?doc)

To improve discoverability could we make it clearer how I get to it by making https://en.wikipedia.org/api/rest_v1/ show it by default in a web browser ...?

Event Timeline

Legoktm subscribed.

You can also click the link from https://en.wikipedia.org/api/.

https://en.wikipedia.org/api/rest_v1/ shows me {"items":["feed","media","page","transform"]}

This is not a bug, but a feature. The idea is to provide an API access to the listing of the endpoints on this level for automatic discovery. For example https://en.wikipedia.org/api/rest_v1/page/ would give you the list of resources you can find for the page.

I then tried
https://en.wikipedia.org/api/rest_v1/help
https://en.wikipedia.org/api/rest_v1/?help
https://en.wikipedia.org/api/rest_v1/?action=help
https://en.wikipedia.org/api/rest_v1/?action=docs
https://en.wikipedia.org/api/rest_v1/?docs without any luck.

I think we could loosen the requirements for the query parameter and also support ?docs, ?help, ?action=help and ?action=docs options. @GWicke @mobrovac @Eevans what do you think?

https://en.wikipedia.org/api/rest_v1/ shows me {"items":["feed","media","page","transform"]}

This is not a bug, but a feature. The idea is to provide an API access to the listing of the endpoints on this level for automatic discovery. For example https://en.wikipedia.org/api/rest_v1/page/ would give you the list of resources you can find for the page.

Element of least surprise would be HTML when viewing in a browser; Can we use an Accept header here?

I then tried
https://en.wikipedia.org/api/rest_v1/help
https://en.wikipedia.org/api/rest_v1/?help
https://en.wikipedia.org/api/rest_v1/?action=help
https://en.wikipedia.org/api/rest_v1/?action=docs
https://en.wikipedia.org/api/rest_v1/?docs without any luck.

I think we could loosen the requirements for the query parameter and also support ?docs, ?help, ?action=help and ?action=docs options. @GWicke @mobrovac @Eevans what do you think?

I can't think of any reason not to.

@Eevans Yes yes yes! Varying on content type and showing HTML rather than JSON if viewed in a browser would be great for exploring the API.

@Pchelolo I don't think you need to/should loosen the requirements for the query parameter (what if user is not English?). The thing I've always liked about well built REST APIs is discoverable uris. My main complaint here is that https://en.wikipedia.org/api/rest_v1/?doc is extremely powerful when using a web browser and it's not discoverable. You need to know that docs is a parameter. Maybe 'docs' should be an 'item' if it cannot be shown when API is accessed in a browser?

This is not a bug, but a feature. The idea is to provide an API access to the listing of the endpoints on this level for automatic discovery. For example https://en.wikipedia.org/api/rest_v1/page/ would give you the list of resources you can find for the page.

Yes and I like this aspect of the API. I should note though that it wasn't obvious at first what item meant - I would consider this a path or route. FWIW I should note that https://en.wikipedia.org/api/rest_v1/feed gives an error message but https://en.wikipedia.org/api/rest_v1/feed/ doesn't (trailing '/') which is mildly annoying. Could the 404 be more descriptive?

Ok, I've created a PR https://github.com/wikimedia/hyperswitch/pull/51 that makes it a bit better. There're still some ideas how this could be further improved, but that PR would be a good start and will address all the questions raised here.

The change's been merged, will be deployed soon, so closing this task.

How can I track when this is resolved? I'd suggest only resolving once it's deployed to avoid confusion. At very least can I ask you comment here when deployed?

Looks great! Thanks so much for the speedy response.

Minor complaint: is there anyway that
https://en.wikipedia.org/api/rest_v1
Could not 404?