How to Build an API as a Solo Developer
Step-by-step guide to building an API by yourself. Tech stack, timeline, costs, and practical advice.
What You're Building
An API (Application Programming Interface) is a service that other software talks to. It receives requests, processes data, and returns responses. APIs power everything from mobile apps to integrations to entire platforms. Building and selling API access is one of the most scalable solo developer businesses because your customers are other developers, and developers pay for tools that save them time.
I've built several APIs, both internal ones that power my own products and a public one that third-party developers pay to use. The process is more straightforward than you'd think.
Difficulty & Timeline
| Aspect | Detail |
|---|---|
| Difficulty | Medium |
| Time to MVP | 3-4 weeks |
| Ongoing Maintenance | Medium |
| Monetization | Usage-based pricing (per API call), subscription tiers |
Recommended Tech Stack
FastAPI (Python) for the framework, PostgreSQL for the database, and Railway or Render for hosting. FastAPI auto-generates your API documentation from your code, which is a massive time-saver. If you're a JavaScript developer, Hono on Cloudflare Workers is an excellent serverless alternative.
Here are the real current versions to pin when you start, so you're not chasing a moving target mid-build (all checked on 2026-05-30):
| Component | Latest version | Notes |
|---|---|---|
| FastAPI | 0.136.3 (PyPI) | 98,649 GitHub stars, still pre-1.0 but production-stable |
| Pydantic | 2.13.4 (PyPI) | v2 is the validation engine FastAPI builds on |
| Uvicorn | 0.48.0 (PyPI) | the ASGI server you run FastAPI behind |
| Hono | 4.12.23 (npm) | 30,685 GitHub stars, around 38.5M weekly npm downloads |
| Next.js | 16.2.6 (npm) | for the developer portal and docs site |
A pinned requirements.txt for the Python side looks like fastapi==0.136.3, pydantic==2.13.4, uvicorn[standard]==0.48.0. Pin exact versions for a public API so a surprise upstream release never breaks a customer integration on a redeploy. Check the linked sources below for current numbers before you start, since these move.
Hosting Costs to Budget For
Hosting is the one recurring cost you cannot skip. Real current pricing (checked on 2026-05-30):
- Railway gives a one-time $5 trial credit (no card required), then the Hobby plan is $5/month with included usage, and Pro is $20/month per seat. Billing is per-second on actual CPU, memory, disk, and egress.
- Render has a genuine free tier (512 MB RAM, but free web services spin down after 15 minutes of inactivity and cold-start in 30 to 60 seconds, and free Postgres is deleted after 30 days). The paid Starter web service is $7/month per service, and managed Postgres starts at $6/month. Budget for both at once on a production API.
- Cloudflare Workers (if you go the Hono route) is free up to 100,000 requests per day. The Workers Paid plan is a $5/month minimum and includes 10 million requests per month, then $0.30 per additional million.
For a solo public API, a realistic floor is around $13/month on Render (Starter service plus a Basic Postgres) or roughly $5/month on Railway Hobby, both before traffic-based overages.
Step-by-Step Plan
Phase 1: Foundation (Week 1-2)
Design your API before you code it. Write down the endpoints you need, what data they accept, and what they return. I use a simple markdown document for this. Nothing fancy. Just a list of routes with example request/response payloads.
Set up your project structure with clear separation between routes, business logic, and database queries. Configure your database with proper migrations from day one. Set up API key authentication. This is non-negotiable for a public API. Every request needs to be authenticated and rate-limited.
Phase 2: Core Features (Week 3)
Build your 5-10 most important endpoints. For each one, handle the happy path first, then add error handling, input validation, and edge cases. FastAPI makes validation almost free with Pydantic models, so there's no excuse for accepting bad data.
Implement rate limiting per API key. This protects you from abuse and becomes a natural pricing lever later. I use a simple Redis-based counter per key per minute. Start with generous limits (100 requests/minute) and tighten them for different plan tiers.
Add logging for every request. You'll need this for debugging, billing, and understanding how developers use your API. Log the endpoint, response time, status code, and API key (but never the full request body if it contains sensitive data).
Phase 3: Polish & Launch (Week 4)
Write documentation. This is not optional. Your documentation IS your product when you're selling an API. FastAPI generates Swagger/OpenAPI docs automatically, but you also need a getting-started guide, code examples in multiple languages, and a clear explanation of error codes.
Set up a developer portal. This can be a simple Next.js site with documentation pages and a signup flow where developers get their API keys. Stripe handles billing for different usage tiers.
Deploy to Railway or Render. Both support automatic deployments from Git and include managed PostgreSQL. Set up monitoring so you know when your API goes down before your customers do.
Monetization Strategy
API businesses have beautiful economics. Usage-based pricing means revenue scales with adoption, and margins are high because serving API requests is cheap.
The standard model is tiered pricing. A free tier with 1,000 requests/month to attract developers, a starter tier at $29/month for 50,000 requests, and a pro tier at $99/month for 500,000 requests. Charge per additional request over the limit.
What I've found works best is making the free tier generous enough that developers build real integrations before hitting the paywall. A developer who has already integrated your API into their product will pay happily rather than rip it out and switch to a competitor.
One number to bake into your pricing math from the start is the payment processor cut. Stripe's standard rate for domestic US card payments is 2.9% plus 30 cents per successful transaction (checked on 2026-05-30). On a $29/month starter tier that's about $1.14 per charge, so your real take is closer to $27.86. It barely matters at $99/month tiers, but it quietly erodes a $5 micro-plan, which is one reason most API businesses skip ultra-cheap tiers entirely.
Common Mistakes to Avoid
Bad documentation. I cannot stress this enough. Developers will evaluate your API by reading the docs first. If the docs are confusing, incomplete, or outdated, they'll move to a competitor without ever making a request. Keep docs in sync with your code using auto-generation tools.
Breaking changes without versioning. Once developers depend on your API, breaking their integration is the fastest way to lose them. Version your API from day one (v1, v2) and never change existing endpoint behavior. Add new endpoints instead.
No rate limiting. Without rate limits, one bad actor or buggy integration can take down your entire API. Rate limit by default and treat unlimited access as a premium feature.
Ignoring latency. API response time matters enormously. A 200ms response is fine. A 2-second response is unusable for many applications. Profile your endpoints, optimize database queries, and add caching for frequently accessed data.
Is This Worth Building?
Definitely, if you have access to unique data or can provide a useful transformation that developers need. The API economy is massive, and solo developers can compete effectively because developer experience (good docs, fast responses, reliable uptime) matters more than brand name.
The best API businesses serve a specific niche. Weather data for a specific region, sentiment analysis for a specific language, or data aggregation for a specific industry. Find something developers need, wrap it in a clean API, and charge for access. The recurring revenue model makes this one of the best solo developer businesses you can build.
Common Errors and Fixes
These are the snags that actually slow people down on this exact stack, grounded in the official docs.
A 422 response you didn't expect. FastAPI returns HTTP 422 Unprocessable Entity for request validation failures, not 400. When a Pydantic model rejects the incoming body or a path parameter is the wrong type, the response body is a structured detail list with loc, msg, and type for each bad field. This is correct behavior, not a bug. If your API consumers expect 400, override it with a custom handler via @app.exception_handler(RequestValidationError) rather than loosening your models. See the FastAPI error-handling docs.
Raising versus returning HTTPException. HTTPException must be raised, never returned. raise HTTPException(status_code=404, detail="Item not found") short-circuits the request immediately. Returning it instead sends the exception object back as a serialized response with a 200 status, which silently masks the error from clients. You can also attach custom headers through the headers= argument.
Pydantic v1 syntax on a Pydantic v2 install. With Pydantic 2.13.4, the v1 patterns break. .dict() is now .model_dump(), .parse_obj() is .model_validate(), and config moved from an inner class Config to model_config = ConfigDict(...). If you copy an older tutorial you'll hit deprecation warnings or hard errors. Confirm you're on v2 with python -c "import pydantic; print(pydantic.VERSION)".
Render free service cold starts. On Render's free tier, web services spin down after 15 minutes of inactivity and cold-start in 30 to 60 seconds. The first request after idle will appear to hang or time out. This is expected on free; move to the $7/month Starter service for an always-on API, and remember free Postgres is deleted after 30 days.
Hono on Workers: wrong template or missing deploy step. Scaffold with npm create hono@latest my-app and pick the cloudflare-workers template, then npm i. Deploy with npm run deploy (which wraps Wrangler). A common mistake is editing the worker but never running the deploy command, so the live endpoint keeps serving the old build. The minimal app is const app = new Hono() with export default app.
Uvicorn not reloading or not binding. Run FastAPI in development with uvicorn main:app --reload, and in production drop --reload and bind explicitly with --host 0.0.0.0 --port $PORT so your host platform can route traffic. Forgetting --host 0.0.0.0 is the usual reason a container deploys cleanly but returns connection-refused.
Sources
- FastAPI version 0.136.3 and stars: PyPI fastapi, github.com/fastapi/fastapi (98,649 stars, checked 2026-05-30)
- Pydantic version 2.13.4: PyPI pydantic (checked 2026-05-30)
- Uvicorn version 0.48.0: PyPI uvicorn (checked 2026-05-30)
- Hono version 4.12.23, stars, and weekly downloads: npm hono, github.com/honojs/hono (30,685 stars), api.npmjs.org last-week downloads (38,546,097 for 2026-05-22 to 2026-05-28, checked 2026-05-30)
- Next.js version 16.2.6: npm next (checked 2026-05-30)
- Railway pricing ($5 trial credit, Hobby $5/mo, Pro $20/mo per seat): railway.com/pricing (checked 2026-05-30)
- Render pricing (free tier spin-down, Starter $7/mo, Postgres from $6/mo): render.com/pricing (checked 2026-05-30)
- Cloudflare Workers pricing (free 100,000 requests/day, Paid $5/mo min with 10M requests/mo): developers.cloudflare.com/workers/platform/pricing (checked 2026-05-30)
- Stripe standard US card pricing (2.9% + 30 cents per successful transaction): stripe.com/pricing (checked 2026-05-30)
- FastAPI error handling (422 validation, HTTPException): fastapi.tiangolo.com/tutorial/handling-errors (checked 2026-05-30)
- Hono Cloudflare Workers setup and deploy: hono.dev getting started (checked 2026-05-30)
Like this? You'll like what I'm building too.
Two ways to support and get more of this work.
HEARTH
A privacy-first Life OS for your desktop. Journal, tasks, and notes that stay on your machine. Coming soon, direct download from this site.
Read moreMY TOOLKITS
Receipts-first toolkits for shipping after hours, building Claude agents, publishing on Amazon, and more. The exact methods I used, not theory.
Browse on WhopRelated Articles
Treating Video As Code With Remotion And fal
How I turned a script into a finished video with code instead of a timeline app, and why determinism is the real win for a solo dev.
Build Versus Buy For A Custom AI Feature
How to decide between an off-the-shelf AI tool and a custom AI feature, weighing control, cost, differentiation, and data with a clear framework.
Can One Developer Build Your Whole MVP
An honest look at whether a single full-stack developer can ship your whole MVP, when it works beautifully, and when you should bring in more people.