DEV Community

Alex Spinov
Alex Spinov

Posted on

PocketBase Has a Free API: An Entire Backend in a Single Binary

What if your entire backend — database, auth, file storage, real-time subscriptions, admin dashboard — was a single 15MB executable?

What Is PocketBase?

PocketBase is an open-source backend in a single Go binary. Download, run, done.

./pocketbase serve
# Admin UI: http://127.0.0.1:8090/_/
# API: http://127.0.0.1:8090/api/
Enter fullscreen mode Exit fullscreen mode

No Docker. No database setup. No environment variables. One file.

The REST API

PocketBase auto-generates a REST API for every collection you create:

# List records
curl http://127.0.0.1:8090/api/collections/posts/records

# Create record
curl -X POST http://127.0.0.1:8090/api/collections/posts/records \
  -H "Content-Type: application/json" \
  -d '{"title": "Hello World", "content": "My first post"}'

# Filter and sort
curl 'http://127.0.0.1:8090/api/collections/posts/records?filter=created>"2024-01-01"&sort=-created&perPage=20'

# Expand relations
curl 'http://127.0.0.1:8090/api/collections/posts/records?expand=author,comments'
Enter fullscreen mode Exit fullscreen mode

JavaScript SDK

import PocketBase from 'pocketbase'

const pb = new PocketBase('http://127.0.0.1:8090')

// Auth
await pb.collection('users').authWithPassword('user@example.com', 'password')

// CRUD
const posts = await pb.collection('posts').getList(1, 20, { sort: '-created' })
const post = await pb.collection('posts').create({ title: 'New post', content: '...' })

// Real-time subscriptions
pb.collection('posts').subscribe('*', (e) => {
  console.log(e.action, e.record) // 'create', 'update', 'delete'
})
Enter fullscreen mode Exit fullscreen mode

What's Included

  • SQLite database — embedded, zero-config
  • Authentication — email/password, OAuth2 (Google, GitHub, etc.), OTP
  • File storage — local or S3-compatible
  • Real-time — WebSocket subscriptions for any collection
  • Admin UI — full CRUD dashboard at /_/
  • API rules — fine-grained access control per collection
  • Hooks — extend with Go or JavaScript

Why PocketBase

A solo developer built a SaaS with PocketBase on a $5/month VPS. It handles 10K daily active users. The entire backend is one file that starts in 50ms.

Deploy: scp pocketbase server:~/ && ssh server "./pocketbase serve"


Building backends or need data tools? Check out my developer toolkit or email spinov001@gmail.com.

Top comments (0)