Search code examples
restchess

What RESTful API would you use for a turn-based game server?


How would you model a turn-based game server as a RESTful API? For example, a chess server, where you could play a game of chess against another client of the same API. You would need some way of requesting and negotiating a game with the other client, and some way of playing the individual moves of the game.

Is this a good candidate for a REST (RESTful) API? Or should this be modelled a different way?


Solution

  • What are the resources you're trying to model? I would seem to have four: You, your opponent, the particular game (session, instance) and the game board state. So it would start with something like

    /game
    /game/gameID/gamer/gamerID
    /game/gameID/board
    

    we've got a good intro/overview on InfoQ.