Question
How do we make a resource not a verb... but still maintain its special actions outside the default GET
, POST
, PUT
, DELTE
actions?
Details
I have been searching for some time now about the proper way to build a RESTful API. Tons of great information out there. Now I am actually trying to apply this to my website and have run into a few snags.
What our site does:
Our site site allows people to play games and win prizes.
The API will allow developers to build their own games and use our backend to collect, validate, store user information and give out prizes.
Scenario:
Developers will create their game then make a call to our API to let the player play the game (play_game
). This play_game
method combines multiple functions that we do not want a developer to run independently.
Here is what a play_game
call does on the server:
- It accepts player data the developer wants to store.
- Validates the data (compares it to rules setup in the control panel)
- Calculate what prize should be given.
- Returns what prize was won to the Developer.
- In addition there are multiple functions behind the scenes that get triggered like sending emails, etc.
Resource This is what our current resource looks like:
http://site.com/api/play_game
Issue:
This doesn't hold to the idea of no verbs in RESTful API's.
How do we make this resource not a verb... but still maintain its special actions outside the default GET
, POST
, PUT
, DELTE
actions?
Notes:
After asking this question I have decided to use Phil Sturgeons RESTful Framework... unless someone has a better idea.