I recently built a restful API to a key value store as a personal project. Version 1 of the API has the read and write URLs in different directories. Separating the read and write calls made some of the back end work simpler and easier to maintain. I’ve considered merging the two API calls into one, but I’m not convinced it’s the best thing to do for my application. If I did merge the calls together, data would be written or read based on the presence/absence of a value parameter.
Example -> http://pastie.org/1224710
What are the advantages and disadvantages of explicit vs. inferred API calls?
For this personal project of a restful API to a key value store, which do you think would be best?
UPDATE: The API that I built is restricted to all GET requests.
REPLIES: Some friends have replied to my question elsewhere so I will post their responses here.
Alex Nielsen Tried to leave a comment on the site but it didn’t stick. IMHO, a truly RESTful API is implicit by definition. It will rely on GET, PUT, POST, and DELETE methods to determine the course of action to take. A call to http://api.sample.com/reso urce/123 will read with a GET method and write with a PUT or POST. To me an implicit API is simpler, lower-maintenance, and a lot more RESTful.
segdeha Andrew Hedges @MikeGrace I prefer explicit, non-overloaded APIs. E.g., jQuery’s is concise, but not explicit w/the same calls both setting & getting.
michaelnatkin@MikeGrace I’d prefer the explicit version. The computer doesn’t care, so I’d decide based on what is best for the human.
brockj@MikeGrace @segdeha my feedback would be to not let doing things “perfectly” get in the way of getting things done. So, either way