API

This guide walks you through creating your first API with dblayer — from connecting your database to organizing endpoints in workspaces and publishing them.

📺 Video Guide

Prefer learning visually? Watch our step-by-step video tutorial on setting up your first dblayer API (MOCK VIODE, REAL VIDEO IS IN PROGRESS):


1. Create a Connection

The first step is to add a database connection — this is how dblayer links to your database.

Currently, dblayer supports only PostgreSQL databases.

A typical PostgreSQL connection string looks like this:

postgres://username:password@host:port/database

If you don’t already have a PostgreSQL database, here are some free hosting providers you can use:

Note: These are not affiliate links — but if you know someone who knows someone who might sponsor us… we’re listening. 😊


2. Set Up a Workspace

A Workspace acts like a project folder for your API endpoints. Each workspace is linked to a single database connection.

Workspace Highlights:

  • Unique slug for easy identification.
  • All endpoints inside share the same database connection.
  • Keeps your projects organized and manageable.

3. Create an Endpoint

Once your workspace is ready, you can create endpoints to expose SQL queries as REST APIs.

Endpoint Capabilities:

  • Each endpoint has a unique slug and custom API path.
  • Supports HTTP methods like GET and POST.
  • Accepts query parameters for dynamic queries.

Required Fields:

FieldDescription
NameA readable, descriptive name for your endpoint.
API MethodChoose supported HTTP methods (GET or POST).
SQL QueryThe SQL statement that will run when the endpoint is called.

Once created, your endpoint is instantly live and can be tested immediately.


4. Edit & Publish an Endpoint

After creating an endpoint, you’ll be redirected to the Editor. The editor includes multiple subpages where you can:

  • Modify your SQL query.
  • Adjust parameters.
  • Test responses before publishing.

When you’re ready, click the Publish button in the top-right corner to make your API live.


5. Next Steps

With your first API running, you can:

  • Build dashboards or internal tools using your API.

Need help?

Join our Discord Community.