Quickly mocking a REST API

Talles L - Sep 5 '22 - - Dev Community

For quick tests, there are some good public mock APIs available such as httpbin.org, ReqBin, or Reqres.

But for a simple GET request my favorite is requesting some word on Wikipedia API (like "pencil"):

https://en.wikipedia.org/api/rest_v1/page/summary/<some word>
Enter fullscreen mode Exit fullscreen mode

Or a random article:

https://en.wikipedia.org/api/rest_v1/page/random/summary
Enter fullscreen mode Exit fullscreen mode

Another quick but effective option for simple GET requests is creating a bunch of files on a folder then running a HTTP server out of it with Python:

$ vim somedata.json
$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [04/Sep/2022 23:10:07] "GET /somedata.json HTTP/1.1" 200 -
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .