DEV Community

Alex Spinov
Alex Spinov

Posted on

Deno Has a Free API You Should Know About

Deno 2 isn't just a runtime — it's a complete platform with built-in HTTP server, KV database, and deployment infrastructure.

Deno.serve — Zero-Config HTTP

Deno.serve({ port: 3000 }, async (req) => {
  const url = new URL(req.url)

  if (url.pathname === '/api/health') {
    return Response.json({ status: 'ok', uptime: Deno.osUptime() })
  }

  if (url.pathname === '/api/users' && req.method === 'POST') {
    const body = await req.json()
    const user = await createUser(body)
    return Response.json(user, { status: 201 })
  }

  return new Response('Not Found', { status: 404 })
})
Enter fullscreen mode Exit fullscreen mode

Deno KV — Built-in Database

No external database needed:

const kv = await Deno.openKv()

// Create
await kv.set(['users', '123'], { name: 'John', email: 'john@test.com' })

// Read
const user = await kv.get(['users', '123'])
console.log(user.value) // { name: 'John', ... }

// List all users
const users = []
for await (const entry of kv.list({ prefix: ['users'] })) {
  users.push(entry.value)
}

// Atomic operations
await kv.atomic()
  .check({ key: ['users', '123'], versionstamp: user.versionstamp })
  .set(['users', '123'], { ...user.value, name: 'Jane' })
  .commit()
Enter fullscreen mode Exit fullscreen mode

Fresh — Full-Stack Framework

// routes/api/posts/[id].ts
import { Handlers } from '$fresh/server.ts'

export const handler: Handlers = {
  async GET(_req, ctx) {
    const post = await db.getPost(ctx.params.id)
    if (!post) return new Response('Not Found', { status: 404 })
    return Response.json(post)
  },
  async PUT(req, ctx) {
    const body = await req.json()
    const updated = await db.updatePost(ctx.params.id, body)
    return Response.json(updated)
  }
}
Enter fullscreen mode Exit fullscreen mode

Deno Queues — Background Jobs

const kv = await Deno.openKv()

// Enqueue a job
await kv.enqueue({ type: 'send_email', to: 'user@test.com', template: 'welcome' })

// Process jobs
kv.listenQueue(async (msg) => {
  if (msg.type === 'send_email') {
    await sendEmail(msg.to, msg.template)
  }
})
Enter fullscreen mode Exit fullscreen mode

Real-World Use Case

A solo developer needed a backend with database, job queue, and hosting. Instead of PostgreSQL + Redis + BullMQ + Heroku, they used Deno KV + Deno Queues + Deno Deploy. One runtime, zero infrastructure. Monthly cost: $0 (free tier covers 100K requests/day).

Deno is the entire backend stack in a single binary.


Build Smarter Data Pipelines

Need to scrape websites, extract APIs, or automate data collection? Check out my ready-to-use scrapers on Apify — no coding required.

Custom scraping solution? Email me at spinov001@gmail.com — fast turnaround, fair prices.

Top comments (0)