How to use RAML with an api based on ?action=method


#1

Hi,

I have an api that i can access via : http://example.com/api.php?action=method
with method corresponding to a request.
For instance to get a location of a site from the db you do a GET to http://example.com/api.php?action=getlocation&site=107.

So almost every request works on the same principle. I don’t see how to implement this with RAML using resources.
The only way i found so far is to put http://example.com as baseUri and api.php?acton=getlocation as a ressource.

is there a better way to do this?

Thank you in advance


#2

Hi @seblanore I am not sure RAML is the right tool for your API.

From what I see in your description, your API is at level 0 of Richardson Maturity Model for REST APIs. RAML is a language which best describes APIs in levels 1-2, and possibly 3 (there is a lot of discussion about this).


#3

I am interested to what extent RAML can support level 3… with response links. More importantly, but probably less likely for a REST only spec like RAML, is the ability to declare response links contextually, or in some way describe each link at the very least to indicate an application specific user/role/group context that a link may be part of the response for. This may be a general issue with modeling a rest API via a spec like RAML or JSON even. But it would be interesting to hear how people might go about indicating a given request, response, links, etc would apply to different user roles, access rights, etc. Like I said, it’s outside the REST only realm and more tied to specific application implementations of using REST within an organization.