Overview

Features of Orangepill RESTful API.

Idempotency

The HTTP idempotency-key request header field can be used to carry idempotency key in order to make non-idempotent HTTP methods such as POST or PATCH fault-tolerant

Client can make the same request repeatedly because of network error, timeout etc.. but the same operation will not be executed twice. If Client repeats the same request by sending the same Idempotency Key value in request headers, and the request will be responded with the same response as the original request.

Name of the request header is idempotency-key.

Usage of Idempotency is optional.

Security

x-api-key

The HTTP x-api-key request header field must be used to identify Realm.

Authorization

Add Authorization request header with x-api-key: base64encode(realm.key:username:password) value.

Ownership

Each created entity is flagged with owner: authenticated_user.id thus enabling automatic scope filtering and ownership.

Roles

User can have different roles in a realm.

Scopes

User is limited in it's scope to access data.

User scopes:

Cumulative Permissions

API scopes

When calling API you can apply following scopes on entities.

Soft delete

Entities are never physically deleted, hence soft delete mechanism is applied. When DELETE method is invoked on REST API interface, Orangepill middleware will flag the entity as deleted: true, and timestamped as deleted_at: Date.now(). Entities marked as deleted are filtered out from scopes all and own. To view deleted entities either disable scopes by adding ?scope=false to URL query or choose ?scope=deleted if exists for specific endpoint.

RESTful

Orangepill API is completely RESTful thus being interface for buidling frontend and backend apps.

find Find entities

Find entitites by query.

Parameters

REST endpoint

GET {serviceName}/all

Results

[
    {
        id: "akTRSKTKzGCg9EMz",
        ...
    },
    {
        id: "0YZQR0oqyjKILaRn",
        ...
    }
]

list List entities

List entities with pagination. It returns also the total number of rows.

Parameters

REST endpoint

GET {serviceName}

Results

{
    rows: [
        {
            id: "2bUwg4Driim3wRhg",
            ...,
        },
        {
            id: "Di5T8svHC9nT6MTj",
            ...,
        },
        {
            id: "YVdnh5oQCyEIRja0",
            ...,
        },
    ],
    total: 3,
    page: 1,
    pageSize: 10,
    totalPages: 1,
}

count Count entities

Get the number of entities by query.

Parameters

REST endpoint

GET {serviceName}/count

Results

15

get Get an entity by ID

Get an entity by ID.

Parameters

REST endpoint

GET {serviceName}/{id}

Results

{
    id: "YVdnh5oQCyEIRja0",
    ...,
}

Last updated