{"id":19093946,"url":"https://github.com/bekcodingaddict/json-server","last_synced_at":"2026-05-14T22:05:10.162Z","repository":{"id":240597554,"uuid":"802882344","full_name":"BekCodingAddict/JSON-Server","owner":"BekCodingAddict","description":"A JSON server is a lightweight backend server that allows you to quickly create a REST API using JSON files as the database. It is particularly useful for prototyping, testing, and building front-end applications without needing to set up a complex backend.","archived":false,"fork":false,"pushed_at":"2024-05-20T14:15:00.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T07:56:01.592Z","etag":null,"topics":["deployment","json","json-api","json-server","restful-api"],"latest_commit_sha":null,"homepage":"https://json-server-2-mezl.onrender.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BekCodingAddict.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-19T14:25:35.000Z","updated_at":"2024-05-20T14:16:38.000Z","dependencies_parsed_at":"2024-05-20T02:38:29.252Z","dependency_job_id":"996ba47b-9f89-4910-b7cb-ddead5b86f4c","html_url":"https://github.com/BekCodingAddict/JSON-Server","commit_stats":null,"previous_names":["bekcodingaddict/json-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BekCodingAddict/JSON-Server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BekCodingAddict%2FJSON-Server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BekCodingAddict%2FJSON-Server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BekCodingAddict%2FJSON-Server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BekCodingAddict%2FJSON-Server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BekCodingAddict","download_url":"https://codeload.github.com/BekCodingAddict/JSON-Server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BekCodingAddict%2FJSON-Server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33045149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deployment","json","json-api","json-server","restful-api"],"created_at":"2024-11-09T03:26:50.400Z","updated_at":"2026-05-14T22:05:10.140Z","avatar_url":"https://github.com/BekCodingAddict.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON SERVER\n## About:\n - \u003cb\u003ejson-server\u003c/b\u003e is a tool that allows you to create a full fake REST API with zero coding in less than 30 seconds. It's particularly useful for prototyping, front-end development, and testing without needing to set up a complex backend. json-server uses a simple JSON file as a database and generates a complete RESTful API based on that file.\n## Features of json-server:\n - No coding required: Quickly create a REST API without writing any backend code.\n - CRUD operations: Automatically handles Create, Read, Update, and Delete operations.\n - Custom routes: Allows you to define custom routes for more complex scenarios.\n - Middleware: Supports middleware for adding custom behavior.\n - Real-time updates: Watches the JSON file for changes and updates the API in real-time.\n## How to Set Up and Use json-server:\n - Here’s a step-by-step guide to setting up and using json-server:\n     1. Install Node.js:\n       - Make sure you have Node.js installed on your machine. You can download it from the [Node.js official website](https://nodejs.org/en).\n     2.  Install json-server:\n     - Install json-server globally using npm (Node Package Manager):\n        ```sh\n            npm install -g json-server\n        ```\n     3. Create a JSON File:\n     - Create a JSON file (db.json) that will act as your database. For example:\n        ```json\n           {\n             \"posts\": [\n                { \"id\": 1, \"title\": \"Hello World\", \"author\": \"John Doe\" },\n                { \"id\": 2, \"title\": \"JSON Server\", \"author\": \"Jane Doe\" }\n             ],\n            \"comments\": [\n               { \"id\": 1, \"postId\": 1, \"body\": \"Great post!\" },\n               { \"id\": 2, \"postId\": 1, \"body\": \"Thanks for sharing.\" }\n            ]\n           }\n        ```\n      4. Start json-server:\n      - Run the json-server with the following command:\n        - ```sh\n          json-server --watch db.json\n          ```\n        - This command starts a server and watches the db.json file for changes. By default, json-server \n          runs on port 3000. You can access your API at http://localhost:3000.\n      5. Using the API:\n      - With the server running, you can perform CRUD operations on your JSON data. Here are some example API endpoints:\n         - GET /posts: Fetch all posts.\n         - GET /posts/1: Fetch the post with id 1.\n         - POST /posts: Add a new post.\n         - PUT /posts/1: Update the post with id 1.\n         - DELETE /posts/1: Delete the post with id 1.\n      6. Custom Routes:\n      - You can create a custom routes file to define more complex routing. Create a routes.json file:\n          ```json\n           {\n             \"/api/\": \"/\",\n             \"/api/posts/:id\": \"/posts/:id\"\n           }\n           ```\n         - Then, start the json-server with the routes file:\n           - ```sh\n             json-server --watch db.json --routes routes.json\n             ```\n      7. Middleware and Customization:\n      - You can add custom middleware to json-server for additional functionality. Create a server.js file:\n         ```js\n            const jsonServer = require('json-server');\n            const server = jsonServer.create();\n            const router = jsonServer.router('db.json');\n            const middlewares = jsonServer.defaults();\n\n            // Custom middleware example\n            server.use((req, res, next) =\u003e {\n              if (req.method === 'POST') {\n              req.body.createdAt = Date.now();\n            }\n              next();\n            });\n\n            server.use(middlewares);\n            server.use(router);\n\n            server.listen(3000, () =\u003e {\n            console.log('JSON Server is running on http://localhost:3000');\n            });\n            ```\n          - Run the server using Node.js:\n            - ```sh\n              node server.js\n              ```\n      8. Conclusion:\n      - json-server is a powerful and easy-to-use tool for creating a mock REST API. It is ideal for:\n         - Prototyping and rapid development.\n         - Building front-end applications without a real backend.\n         - Testing and debugging front-end code.\n      - By following the steps above, you can quickly set up a functional REST API based on a simple JSON file, allowing you to focus on developing and testing your front-end applications.\n\n\n\n\n\n          \n         \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbekcodingaddict%2Fjson-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbekcodingaddict%2Fjson-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbekcodingaddict%2Fjson-server/lists"}