geneontology / go-api

Gene Ontology API deployment
http://api.geneontology.org/api
5 stars 1 forks source link

API guidelines discussion #4

Open dustine32 opened 6 years ago

dustine32 commented 6 years ago

@tmushayahama What was the API spec that you added in the zoom chat? Can you add that here too?

dougli1sqrd commented 6 years ago

I have opinions about this: I think there are a couple things that I think are fairly fundamental to a good REST API, and I'll outline them here.

Resources

REST works with URIs that traverse different nested "resources". So, each thing between the / represents an object that could be accessed with the API. So, GET /users/123/friends might return a json list of user ids that are friends of the user with id 123. And GET /users would get the list of all resources (a collection). Designing the API in terms of how the resources are related to each other I think is one major important consideration when making a REST API.

HTTP Methods (and idempotentcy)

REST over HTTP wants the HTTP method specs to be obeyed.

That's what I have for now. I'll update if I think of anything else.

Idempotent

An operation is idempotent if running it multiple times does not change the state beyond running it the first time. Running an idempotent operation once is identical to running it N > 1 times. For example, setting the name of user ID 124 to "Morgoth" is idempotent because, before the update, the name is "Melkor", and then updating the name yields {"name": "Morgoth"}, and then updating the name again to Morgoth yields {"name": "Morgoth"}, the same result as before.

tmushayahama commented 6 years ago

These are pretty good, one is summary and other is in detail https://geemus.gitbooks.io/http-api-design/en/ https://github.com/WhiteHouse/api-standards

These design practices can be opinionated, but i have seen them being applied on some of the best designed apis out there. You can look no further than GitHub https://developer.github.com/v3/ and my personal favorite is Paypal https://developer.paypal.com/docs/api/overview/

And since this will be a collection of apis, a welcome page like Google's Maps api might help section our apis https://developers.google.com/maps/get-started/

And maybe a change log page https://developers.google.com/ad-exchange/buyer-rest/relnotes

Without repeating the articles, Let's make use of status codes https://developer.mozilla.org/en-US/docs/Web/HTTP/Status rather than saying {response.result :"There is an error, mouse gene not supported and version number has changed"}

For Panther i think GET services/overrep might be a bad endpoint name for panther overrepresentation. It doesn't tell what resources I am getting