How to Build a REST API with Node.js and Express (2026)
Build a working REST API from an empty folder to running routes. Every step explained, with the Express patterns you'll actually use on the job.
Quick Answer
Install Node, run npm init, add Express, and write a server that listens on a port. Add routes for GET, POST, PUT, and DELETE, use express.json() to read request bodies, send data with res.json(), and test with curl or Postman. You can have a working API answering requests in about 30 minutes. This guide walks through each step.
What you need before you start
Step 1: Set up the project
Step 2: Write the server
Step 3: Add your routes
Step 4: Test it
Step 5: Handle errors and next steps
Boot.dev
Want structured backend practice?
Boot.dev teaches backend development through hands-on coding, not video. Their courses cover HTTP servers, databases, and API design with automated feedback on every exercise. A solid next step once you've built your first Express routes.
Explore Boot.devThis is an outbound link. We are not in this platform's affiliate program and earn nothing if you sign up. We only recommend platforms we rate.
Frequently Asked Questions
Do I need to know JavaScript before building an Express API?
You need the basics: variables, functions, arrays, and objects. You don't need to be an expert. If you can read the code snippets in this guide and follow what they do, you're ready. If not, spend a couple of weeks on JavaScript fundamentals first, then come back.
What is the difference between Node.js and Express?
Node.js is the runtime that lets JavaScript run outside a browser, including on a server. Express is a framework that runs on top of Node and makes handling HTTP requests and routes much simpler. You need Node installed; Express is a package you add to make the work easier.
Do I need a database to build a REST API?
No, not to learn. You can store data in a plain array in memory, like this guide does, which is perfect for practice. The catch is that the data resets every time the server restarts. Once the routes make sense, adding a real database like PostgreSQL is the next step.
How do I test my API without a front end?
Use curl from the terminal or a tool like Postman or Thunder Client. They let you send GET, POST, PUT, and DELETE requests directly to your routes and see the responses, no front end required.
Recommended Courses
The Odin Project's Node.js path covers Express.js, databases with PostgreSQL, authentication, APIs, and deployment. Build real-world backend applications through hands-on projects.
Back End Development and APIs
Learn Node.js and Express by building real-world API projects. Covers npm, package.json, basic node, Express routing, and MongoDB. Free verified certificate.