DEV Community

Alex Spinov
Alex Spinov

Posted on

Encore Has a Free API You've Never Heard Of

Encore is a backend development platform that uses static analysis to understand your app and automatically provisions infrastructure. Write TypeScript or Go, and Encore handles databases, pub/sub, cron, and cloud deployment.

What Makes Encore Special?

  • Infrastructure from code — declare what you need, Encore provisions it
  • Free tier — deploy to Encore Cloud for free
  • Auto-generated docs — API documentation from your code
  • Distributed tracing — built-in observability
  • Multi-cloud — deploy to AWS or GCP

The Hidden API: Declarative Infrastructure

import { api } from 'encore.dev/api';
import { SQLDatabase } from 'encore.dev/storage/sqldb';
import { Topic, Subscription } from 'encore.dev/pubsub';
import { CronJob } from 'encore.dev/cron';

// Database — Encore auto-provisions PostgreSQL
const db = new SQLDatabase('users', { migrations: './migrations' });

// API endpoint — auto-generates OpenAPI docs
export const getUser = api(
  { method: 'GET', path: '/users/:id', expose: true },
  async ({ id }: { id: string }) => {
    const user = await db.queryRow`SELECT * FROM users WHERE id = ${id}`;
    return user;
  }
);

// Pub/Sub — Encore provisions the topic
const signupTopic = new Topic<{ userId: string; email: string }>('user-signups', {
  deliveryGuarantee: 'at-least-once'
});

export const createUser = api(
  { method: 'POST', path: '/users', expose: true },
  async ({ email, name }: { email: string; name: string }) => {
    const user = await db.queryRow`INSERT INTO users (email, name) VALUES (${email}, ${name}) RETURNING *`;
    await signupTopic.publish({ userId: user.id, email });
    return user;
  }
);

// Subscription — auto-provisions consumer
new Subscription(signupTopic, 'send-welcome', {
  handler: async ({ userId, email }) => {
    await sendWelcomeEmail(email);
  }
});

// Cron job — auto-scheduled
new CronJob('cleanup', {
  title: 'Clean expired sessions',
  schedule: '0 * * * *',
  endpoint: cleanupSessions
});
Enter fullscreen mode Exit fullscreen mode

Auto-Generated API Docs

Encore automatically generates:

  • OpenAPI spec from your code
  • Interactive API explorer
  • Request/response examples
  • Service dependency graph

Quick Start

brew install encoredev/tap/encore
encore app create my-app --example=ts/hello-world
cd my-app && encore run
Enter fullscreen mode Exit fullscreen mode

Why Teams Choose Encore

A backend engineer shared: "We spent 3 weeks setting up Terraform, CI/CD, and monitoring for our last project. With Encore, we had a production-ready backend with databases, pub/sub, and tracing in 2 hours. The infrastructure-from-code approach is the future."


Building backends? Email spinov001@gmail.com or check my developer tools.

How do you provision infrastructure? Encore vs Pulumi vs Terraform?

Top comments (0)