Ai Coding Tools

How to Build a Simple API Using Cursor in Under 2 Hours

By BTW Team3 min read

How to Build a Simple API Using Cursor in Under 2 Hours

Building APIs can often feel overwhelming, especially for indie hackers and solo founders who have limited time and resources. But what if I told you that you could build a simple API in under 2 hours using Cursor? In 2026, Cursor has become a go-to tool for developers looking to streamline their coding process. Let's dive into how you can leverage this tool to create an API quickly and effectively.

Time Estimate

You can finish this project in about 2 hours, including setup and testing.

Prerequisites

Before we get started, make sure you have:

  • A free Cursor account (no credit card required).
  • Basic knowledge of JavaScript or Python.
  • A code editor (like VSCode).
  • Postman or any API testing tool.

Step-by-Step Guide

Step 1: Setting Up Cursor

  1. Create a Cursor Account: Go to Cursor’s website and sign up for a free account.
  2. Install the Cursor CLI: Open your terminal and run the following command to install the Cursor Command Line Interface:
    npm install -g cursor-cli
    

Step 2: Create Your API Project

  1. Initialize a New Project: In your terminal, navigate to your desired project directory and run:

    cursor init my-api
    

    This command creates a basic project structure for you.

  2. Set Up Your API Endpoint: Open the index.js file in your code editor. You can use the following code to create a simple GET endpoint:

    const express = require('express');
    const app = express();
    
    app.get('/api/hello', (req, res) => {
        res.json({ message: 'Hello, world!' });
    });
    
    const PORT = process.env.PORT || 3000;
    app.listen(PORT, () => {
        console.log(`Server running on port ${PORT}`);
    });
    

Step 3: Running Your API

  1. Install Dependencies: Make sure to install Express by running:
    npm install express
    
  2. Start the Server: In your terminal, run:
    node index.js
    
    You should see "Server running on port 3000" in your terminal.

Step 4: Testing Your API

  1. Use Postman: Open Postman and create a new GET request to http://localhost:3000/api/hello.
  2. Check the Response: You should receive a JSON response:
    { "message": "Hello, world!" }
    

Troubleshooting

  • Error: Port Already in Use: If you encounter this error, change the PORT variable in the code to another number (like 3001).
  • No Response in Postman: Ensure your server is running and the endpoint path is correct.

What's Next?

Now that you have a simple API running, consider expanding its functionality. You can:

  • Add more endpoints for different resources.
  • Integrate a database like MongoDB or PostgreSQL.
  • Deploy your API using platforms like Vercel or Heroku.

Conclusion

Building a simple API with Cursor is not only possible but can be done in under 2 hours. This is a great starting point for indie hackers looking to integrate APIs into their projects. Start here: sign up for Cursor, follow the steps above, and get coding!

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

10 Mistakes New Developers Make When Using AI Tools

10 Mistakes New Developers Make When Using AI Tools As we dive into 2026, AI tools have transformed the coding landscape. But with all the excitement, new developers often stumble

Mar 16, 20264 min read
Ai Coding Tools

How to Use Cursor.ai for Rapid Prototyping in Under 60 Minutes

How to Use Cursor.ai for Rapid Prototyping in Under 60 Minutes In the fastpaced world of building side projects, getting an idea from concept to prototype can feel overwhelming. Ma

Mar 16, 20263 min read
Ai Coding Tools

Why GitHub Copilot is Overrated: Contrarian Perspectives on AI Coding Assistants

Why GitHub Copilot is Overrated: Contrarian Perspectives on AI Coding Assistants As a solo founder or indie hacker, you’re always on the lookout for tools that genuinely boost your

Mar 16, 20264 min read
Ai Coding Tools

How to Build Your First App Using AI Tools in Under 3 Hours

How to Build Your First App Using AI Tools in Under 3 Hours If you're a solo founder or an indie hacker, the thought of building an app might seem daunting. But what if I told you

Mar 16, 20265 min read
Ai Coding Tools

Top 5 AI Tools for Beginners in 2026: Your Launchpad

Top 5 AI Tools for Beginners in 2026: Your Launchpad As a beginner diving into the world of coding in 2026, the landscape is flooded with AI tools promising to make your journey sm

Mar 16, 20264 min read
Ai Coding Tools

Supabase vs Firebase for AI-Driven Projects: A 2026 Comparison

Supabase vs Firebase for AIDriven Projects: A 2026 Comparison As we dive into 2026, the landscape for building AIdriven applications has evolved significantly. If you're an indie h

Mar 16, 20264 min read