Changebase exposes a REST API for developing integrations. The API accepts both JSON encoded and form-encoded bodies. Response are JSON encoded.

Authentication

Changebase's API uses API keys to authenticate requests. API keys are associated with a database and all requests are scoped to that database.

Authentication can be performed via the Api-Key header or via HTTP Basic Auth, with the token as the username.

All API requests must be made over HTTPS. Requests made over HTTP will fail.

Request Parameters

All resources follow a standard query format, described below. This format allows for filtering, ordering, limiting, and including subresources.

Filtering

Filtering resources can be performed by including a query parameter based on the attribute being used to filter. For example, an event can be filtered based on the lsn. The table below shows all of the possible filters for the lsn attribute.

URL PathQuery ParamsJSON RequestEquivelent SQLResponse
/events``{}SELECT * FROM events[{…}, {…}]
/eventswhere[lsn]=1, where[lsn][eq]=1{ "where": { "lsn": 1 } }, { "where": { "lsn": { "eq": 1 } } }SELECT * FROM events WHERE lsn = 1[{…}]
/eventswhere[lsn][neq]=1{ "where": { "lsn": { "neq": 1 } } }SELECT * FROM events WHERE lsn != 1[{…}]
/eventswhere[lsn][gt]=1{ "where": { "lsn": { "gt": 1 } } }SELECT * FROM events WHERE lsn > 1[{…}]
/eventswhere[lsn][gte]=1{ "where": { "lsn": { "gte": 1 } } }SELECT * FROM events WHERE lsn >= 1[{…}]
/eventswhere[lsn][lt]=1{ "where": { "lsn": { "lt": 1 } } }SELECT * FROM events WHERE lsn < 1[{…}]
/eventswhere[lsn][lte]=1{ "where": { "lsn": { "lte": 1 } } }SELECT * FROM events WHERE lsn <= 1[{…}]
/eventswhere[lsn][lt]=1{ "where": { "lsn": { "lt": 1 } } }SELECT * FROM events WHERE lsn < 1[{…}]
/eventswhere[lsn][in][]=1&where[lsn][in][]=2{ "where": { "lsn": { "in": [ 1, 2 ] } } }SELECT * FROM events WHERE lsn IN (1,2)[{…}]
/eventswhere[lsn][not_in][]=1&where[lsn][not_in][]=2{ "where": { "lsn": { "not_in": [ 1, 2 ] } } }SELECT * FROM events WHERE lsn NOT IN (1,2)[{…}]
/eventswhere[lsn][like]=hello*{ "where": { "lsn": { "like": "hello*" } } }SELECT * FROM events WHERE lsn LIKE 'hello*'[{…}]
/eventswhere[lsn][ilike]=hello*{ "where": { "lsn": { "ilike": "hello*" } } }SELECT * FROM events WHERE lsn ILIKE 'hello*'[{…}]
/eventswhere[transaction][lsn]=1{ "where": { "transaction": { "lsn": 1 } } }SELECT * FROM events e LEFT JOIN transactions t ON e.transaction_id = t.id WHERE t.lsn = 1[{…}]

Ordering

URL PathQuery ParamsJSON RequestEquivelent SQLResponse
/eventsorder[id]=asc{ "order": { "id": "asc" } }SELECT * FROM events ORDER BY id ASC[{…}, {…}]
/eventsorder[id]=asc&order[lsn]=asc{ "order": [ { "id": "asc" }, { "id": "desc" } ] }SELECT * FROM events ORDER BY id ASC, lsn ASC[{…}, {…}]
/eventsorder[id][asc]=nulls_first{ "order": { "id": { "asc": "nulls_first" } } }SELECT * FROM events ORDER BY id ASC NULLS FIRST[{…}, {…}]
/eventsorder[id][asc]=nulls_last{ "order": { "id": { "asc": "nulls_last" } } }SELECT * FROM events ORDER BY id ASC NULLS LAST[{…}, {…}]
/eventsorder[id]=desc{ "order": { "id": "desc" } }SELECT * FROM events ORDER BY id ASC[{…}, {…}]
/eventsorder[id]=desc{ "order": { "id": "desc" } }SELECT * FROM events ORDER BY id ASC[{…}, {…}]
/eventsorder[id][desc]=nulls_first{ "order": { "id": { "desc": "nulls_first" } } }SELECT * FROM events ORDER BY id DESC NULLS FIRST[{…}, {…}]
/eventsorder[id][desc]=nulls_last{ "order": { "id": { "desc": "nulls_last" } } }SELECT * FROM events ORDER BY id DESC NULLS LAST[{…}, {…}]

Limiting

URL PathQuery ParamsJSON RequestEquivelent SQLResponse
/eventslimit=100{ "limit": 100 }SELECT * FROM events LIMIT 100[{…}, {…}]

Including subresources

URL PathQuery ParamsJSON RequestEquivelent SQLResponse
/eventsinclude=transaction{ "include": "transaction" }SELECT * FROM events e LEFT JOIN transactions t ON t.id = e.transaction_id[{ transaction: {…}, …}, …]
/eventsinclude[]=transaction&include[]=database{ "include": ["transaction", "database"] }SELECT * FROM events e LEFT JOIN transactions t ON t.id = e.transaction_id LEFT JOIN databases d ON d.id = e.database_id[{ transaction: {…}, database: {…}, …}, …]
/eventsinclude[database]=account{ "include": { "transaction": "database" } }SELECT * FROM events e LEFT JOIN databases d ON d.id = e.database_id LEFT JOIN accounts a ON a.id = d.account_id[{ database: { account: {…}, …}, …}, …]

Grouping

URL PathQuery ParamsJSON RequestEquivelent SQLResponse
/events/calculateselect[count]=*&group_by=type{ "select": { "count": "*" }, "group_by": "type" }SELECT events.type, COUNT(events.*) FROM events GROUP BY events.type{ "insert": 401, "update": 3023, …}