Skip to content

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.

License

Notifications You must be signed in to change notification settings

Azure/data-api-builder

Repository files navigation

Data API builder for Azure Databases

NuGet Package Nuget Downloads Documentation License: MIT

What's new?

Community

Join the Data API builder community! This sign up will help us maintain a list of interested developers to be part of our roadmap and to help us better understand the different ways DAB is being used. Sign up here.

About Data API builder

Data API builder (DAB) is an open-source, no-code tool that creates secure, full-featured REST and GraphQL endpoints for your database. It’s a CRUD data API engine that runs in a container—on Azure, any other cloud, or on-premises. DAB is built for developers with integrated tooling, telemetry, and other productivity features.

erDiagram
    DATA_API_BUILDER ||--|{ DATA_API : "Provides"
    DATA_API_BUILDER {
        container true "Microsoft Container Repository"
        open-source true "MIT license / any cloud or on-prem."
        objects true "Supports: Table / View / Stored Procedure"
        developer true "Swagger / Nitro (fka Banana Cake Pop)"
        otel true "Open Telemetry / Structured Logs / Health Endpoints"
        security true "EntraId / EasyAuth / OAuth / JWT / Anonymous"
        cache true "Level1 (in-memory) / Level2 (redis)"
        policy true "Item policy / Database policy / Claims policy"
        hot_reload true "Dynamically controllable log levels"
    }
    DATA_API ||--o{ DATASOURCE : "Queries"
    DATA_API {
        REST true "$select / $filter / $orderby"
        GraphQL true "relationships / multiple mutations"
    }
    DATASOURCE {
        MS_SQL Supported
        PostgreSQL Supported
        Cosmos_DB Supported
        MySQL Supported
        SQL_DW Supported
    }
    CLIENT ||--o{ DATA_API : "Consumes"
    CLIENT {
        Transport HTTP "HTTP / HTTPS"
        Syntax JSON "Standard payloads"
        Mobile Supported "No requirement"
        Web Supported "No requirement"
        Desktop Supported "No requirement"
        Language Any "No requirement"
        Framework None "Not required"
        Library None "Not required"
        ORM None "Not required"
        Driver None "Not required"
    }
Loading

Getting Started

Use the Getting Started tutorial to quickly explore the core tools and concepts. It gives you hands-on experience with how DAB makes you more efficient by removing boilerplate code.

1. Install the DAB CLI

The DAB CLI is a cross-platform .NET tool. Install the .NET SDK before running:

dotnet tool install microsoft.dataapibuilder -g

2. Create your initial configuration file

DAB requires a JSON configuration file. Edit manually or with the CLI. Use dab --help for syntax options.

dab init
  --database-type mssql
  --connection-string "@env('my-connection-string')"
  --host-mode development

3. Add your first table

DAB supports tables, views, and stored procedures. It works with SQL Server, Azure Cosmos DB, PostgreSQL, MySQL, and SQL Data Warehouse. Security is engine-level, but permissions are per entity.

dab add Actor
  --source "dbo.Actor"
  --permissions "anonymous:*"

4. Run Data API builder

In production, DAB runs in a container. In development, it’s self-hosted locally with hot reload, Swagger, and Nitro (fka Banana Cake Pop) support.

dab start

Note: Before you run dab start, make sure your connection string is stored in an environment variable called my-connection-string. This is required for @env('my-connection-string') in your config file to work. The easiest way is to create a .env file with name=value pairs—DAB will load these automatically at runtime.

5. Access your data source

By default, DAB enables both REST and GraphQL. REST supports $select, $filter, and $orderBy. GraphQL uses config-defined relationships.

GET http://localhost:5000/api/Actor

Walk-through video

Play Video

Demo source code: startrek

Overview

Category Features
Database Objects • NoSQL collections
• RDBMS tables, views, stored procedures
Data Sources • SQL Server & Azure SQL
• Azure Cosmos DB
• PostgreSQL
• MySQL
REST $select for projection
$filter for filtering
$orderBy for sorting
GraphQL • Relationship navigation
• Data aggregation
• Multiple mutations
Telemetry • Structured logs
• OpenTelemetry
• Application Insights
• Health endpoints
Advanced • Pagination
• Level 1 (in-memory) cache
• Level 2 (Redis) cache
Authentication • OAuth2/JWT
• EasyAuth
• Entra ID
Authorization • Role-based support
• Entity permissions
• Database policies
Developer • Cross-platform CLI
• Swagger (REST)
• Banana Cake Pop (GraphQL)
• Open Source
• Hot Reload

How does it work?

This diagram shows how DAB works. DAB dynamically creates endpoints from your config file. It translates HTTP requests to SQL, returns JSON, and auto-pages results.

sequenceDiagram
    actor Client

    box Data API builder (DAB)
        participant Endpoint
        participant QueryBuilder
    end

    participant Configuration as Configuration File

    box Data Source
        participant DB
    end

    Endpoint->>Endpoint: Start
    activate Endpoint
        Endpoint->>Configuration: Request
        Configuration-->>Endpoint: Configuration
        Endpoint->>DB: Request
        DB-->>Endpoint: Metadata
            Note over Endpoint, DB: Some configuration is validated against the metadata
        Endpoint-->>Endpoint: Configure
    deactivate Endpoint
    Client-->>Endpoint: HTTP Request
    activate Endpoint
        critical
        Endpoint-->>Endpoint: Authenticate
        Endpoint-->>Endpoint: Authorize
        end
        Endpoint->>QueryBuilder: Request
        QueryBuilder-->>Endpoint: SQL
        alt Cache
            Endpoint-->>Endpoint: Use Cache
        else Query
            Endpoint-->>DB: Request
            Note over Endpoint, DB: Query is automatically throttled and results paginated
            DB->>Endpoint: Results
            Note over Endpoint, DB: Results are automatically cached for use in next request
        end
        Endpoint->>Client: HTTP 200
    deactivate Endpoint
Loading

Because DAB is stateless, it can scale up or out using any container size. It builds a feature-rich API like you would from scratch—but now you don’t have to.

Additional Resources

References

How to Contribute

To contribute, see these documents:

License

Data API builder for Azure Databases is licensed under the MIT License. See LICENSE for details.

Third-Party Component Notice

Nitro (fka Banana Cake Pop by ChilliCream, Inc.) may optionally store work in its cloud service via your ChilliCream account. Microsoft is not affiliated with or endorsing this service. Use at your discretion.

Trademarks

This project may use trademarks or logos. Use of Microsoft trademarks must follow Microsoft’s Trademark & Brand Guidelines. Use of third-party marks is subject to their policies.