ballerina/dataservice.http Ballerina library

0.1.0

Overview

The ballerina/dataservice.http package is the HTTP runtime of the data services that bal persist generates from a persist model. Generated HTTP services call it to build error responses and Location headers, so fixes reach them without regeneration.

Key Features

  • Status code records for each response of a data service, with the DataserviceError body
  • Mapping of persist and query errors to 400, 404, 409 and 500 responses
  • An authenticator that checks Basic, JWT and OAuth2 credentials and each operation's scopes before dispatch
  • Location headers for created records, and the runtime settings: port, listener, CORS, auth and page sizes

Quick start

The package is used by generated code, not imported by hand. To generate an HTTP data service:

  1. Add the persist entry with an HTTP data service to the package:

    Copy
    bal persist add --datastore h2 --dataservice http
  2. Annotate each entity to expose in persist/model.bal with @dataservice:Expose.

  3. Build and run the package. The service is served on port 9090 under /api:

    Copy
    bal run
    curl localhost:9090/api/employees

A failed request is answered with a status code and a JSON body that names the error category:

GET /api/employees/99  →  404  {"code": "NOT_FOUND", "message": "A record with the key '99' does not exist for the entity 'Employee'."}

For the details, see the specification.

Import

import ballerina/dataservice.http;Copy

Other versions

0.1.0

Metadata

Released date: about 18 hours ago

Version: 0.1.0

License: Apache-2.0


Security

No known vulnerabilities in libraries

Checked on 2026-11-20 via OSV.dev


Compatibility

Platform: any

Ballerina version: 2201.14.0

GraalVM compatible: Yes


Pull count

Total: 4

Current verison: 4


Weekly downloads


Source repository


Keywords

dataservice

persist

http

Type/Library

Area/Database

Name/Data Service HTTP


Contributors