Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a REST API suited for interactive software or games?

Tags:

rest

Specifically, I'm wondering if it would be possible to implement a network-based Tetris game using a REST API. The resources would be: current-block, grid, score, etc... Moving a block would be a POST request on the current-block resource with the arguments embedded in the request body. To get the current gamestate a GET request would be used, etc...

Does it make sense to do it this way?

like image 838
StackedCrooked Avatar asked Oct 14 '25 09:10

StackedCrooked


1 Answers

Such approach would be fine for game like Chess, but it not so great for Tetris.

Tetris is a real-time game. To keep that aspect, either server would have to run the game and expect client to poll state very often, or the client would have to run game simulation, and then server isn't really needed.

For realtime game you usually need lower overhead message passing and streaming. This can be done over HTTP (COMET, Server-Sent events API, Web Sockets), but I wouldn't call it REST.

like image 86
Kornel Avatar answered Oct 17 '25 17:10

Kornel