About this project
JSON Server is a Node.js package that creates a fake REST API from a JSON or JSON5 data file. After installing with npm install json-server, you create db.json or db.json5 containing resources such as posts, comments, and profile, then run npx json-server db.json. The server starts by default at http://localhost:3000 and exposes REST endpoints for array resources and singular object resources. Array resources support GET collection and item, POST, PUT, PATCH, and DELETE. Object resources support GET, PUT, and PATCH. Query capabilities include field conditions with operators eq, ne, lt, lte, gt, gte, in, contains, startsWith, and endsWith; sorting with _sort and descending fields prefixed by -; pagination with _page and _per_page, returning metadata like first, prev, next, last, pages, items, and data; relation embedding with _embed; and complex filtering with _where using a JSON object. Dependents can be deleted with _dependent. Static files from ./public are served automatically, and additional static directories can be added with -s. The README notes v0 to v1 migration changes: ids are always strings and auto-generated if missing; pagination uses _per_page instead of _limit; relationships use _embed instead of _expand; and the --delay CLI option is removed in favor of browser DevTools throttling. The README says v1 is beta and may have breaking changes, with stable documentation at v0.17.4.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.