Guide
Get Entities
Overview
The general shape of an entity query is:
{
"q/from": <database name> // "fibery/user", "Kanban/Story"
"q/select": <select>
"q/where": <where>
"q/offset": <integer>
"q/order-by": <order-by>
"q/limit": <integer> | "q/no-limit"
}
The clauses are directly analogous to SQL's from, select, where, offset, order by and limit.
q/from, q/select and q/limit are required.
This section describes a comprehensive example. See the sections below for a more detailed explanation:
select Fields
filter Entities
order Entities
Get info about cricket players born since 1986 ordered by height and age:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': [
'fibery/id',
'fibery/public-id',
'Cricket/name',
'Cricket/Full Name',
'Cricket/Born',
'Cricket/Shirt Number',
'Cricket/Height',
'Cricket/Retired?',
{ 'Cricket/Batting Hand': ['enum/name'] },
{ 'Cricket/Current Team': ['Cricket/name'] },
{ 'user/Former Teams': { 'q/select': ['Cricket/name'], 'q/limit': 'q/no-limit' } },
{ '# of former teams': [ 'q/count', ['user/Former Teams', 'fibery/id'] ] }
],
'q/where': ['>=', ['Cricket/Born'], '$birthday' ],
'q/order-by': [
[['Cricket/Height'], 'q/desc'],
[['Cricket/Born'], 'q/asc']
],
'q/limit': 3
}, { '$birthday': '1986-01-01' });
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": [
"fibery/id",
"fibery/public-id",
"Cricket/name",
"Cricket/Full Name",
"Cricket/Born",
"Cricket/Shirt Number",
"Cricket/Height",
"Cricket/Retired?",
{ "Cricket/Batting Hand": ["enum/name"] },
{ "Cricket/Current Team": ["Cricket/name"] },
{ "user/Former Teams": { "q/select": ["Cricket/name"], "q/limit": "q/no-limit" } },
{ "# of former teams": [ "q/count", ["user/Former Teams", "fibery/id"] ] }
],
"q/where": [">=", ["Cricket/Born"], "$birthday" ],
"q/order-by": [
[["Cricket/Height"], "q/desc"],
[["Cricket/Born"], "q/asc"]
],
"q/limit": 3
},
"params": {
"$birthday": "1986-01-01"
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"# of former teams": 6,
"Cricket/Height": "1.79",
"user/Former Teams": [
{ "Cricket/name": "Royal Challengers Bangalore" },
{ "Cricket/name": "Yorkshire" },
{ "Cricket/name": "Kolkata Knight Riders" },
{ "Cricket/name": "Kings XI Punjab" },
{ "Cricket/name": "Derbyshire" },
{ "Cricket/name": "Nottinghamshire" }
],
"Cricket/Born": "1988-01-25",
"fibery/id": "21e578b0-9752-11e9-81b9-4363f716f666",
"Cricket/Shirt Number": 15,
"Cricket/Full Name": "Cheteshwar Arvind Pujara",
"fibery/public-id": "3",
"Cricket/Retired?": false,
"Cricket/Current Team": {
"Cricket/name": "Saurashtra"
},
"Cricket/Batting Hand": {
"enum/name": "Right"
},
"Cricket/name": "Cheteshwar Pujara"
},
{
"# of former teams": 1,
"Cricket/Height": "1.75",
"user/Former Teams": [
{ "Cricket/name": "Delhi" }
],
"Cricket/Born": "1988-11-05",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"Cricket/Shirt Number": 18,
"Cricket/Full Name": "Virat 'Chikoo' Kohli",
"fibery/public-id": "1",
"Cricket/Retired?": false,
"Cricket/Current Team": {
"Cricket/name": "Delhi"
},
"Cricket/Batting Hand": {
"enum/name": "Right"
},
"Cricket/name": "Virat Kohli"
},
{
"# of former teams": 4,
"Cricket/Height": "1.75",
"user/Former Teams": [
{ "Cricket/name": "Northern Districts" },
{ "Cricket/name": "Gloucestershire" },
{ "Cricket/name": "Yorkshire" },
{ "Cricket/name": "Barbados Tridents" }
],
"Cricket/Born": "1990-08-08",
"fibery/id": "216c2a00-9752-11e9-81b9-4363f716f666",
"Cricket/Shirt Number": 22,
"Cricket/Full Name": "Kane Stuart Williamson",
"fibery/public-id": "2",
"Cricket/Retired?": false,
"Cricket/Current Team": {
"Cricket/name": "Sunrisers Hyderabad"
},
"Cricket/Batting Hand": {
"enum/name": "Right"
},
"Cricket/name": "Kane Williamson"
}
]
}
Command parameters
Parameter (required in bold) | Description |
|---|
query.q/from | Database name in format space/name, such as Cricket/Player or fibery/user. Note that the case matters. |
query.q/select | Array of primitive Fields, entity Field objects, objects with entity collection Fields subqueries and entity collection Field aggregates. |
query.q/where | Filter expression represented as an array. |
query.q/order-by | Array of sorting expressions — sorting by multiple Fields is supported. |
query.q/limit | How many Entities to get. Pass q/no-limit to get all entities. In entity collection Fields subqueries only q/no-limit is supported . |
query.q/offset | How many Entities to skip — useful for pagination. |
params
| Object of parameters for filter expressions in { "$param": value } format. |
Cricket/Player Type used as an example
Field name | Field type |
|---|
fibery/id
| fibery/uuid
|
fibery/public-id
| fibery/text
|
Cricket/name
| fibery/text
|
Cricket/Full Name
| fibery/text
|
Cricket/Born
| fibery/date
|
Cricket/Shirt Number
| fibery/int
|
Cricket/Height
| fibery/decimal
|
Cricket/Retired?
| fibery/bool
|
Cricket/Batting Hand
| single-select |
Cricket/Current Team
| entity Field |
user/Former Teams
| entity collection Field |
Select Fields
In this example we demonstrate the select form known as "vector select". It's general form is:
<vec-select> = [ <field-name> | <vec-dereference> | <vec-subselect> ]
<field-name> is used for primitive fields (strings, numbers, booleans and the like). For example, to select id and name (both are text fields):
q/select: ["fibery/id", "fibery/name"]
<field-name> won't work for fields that point to other entities, because it's not clear what to include as the value. So the query must specify which fields from the referenced entity to include, and that's what the <vec-dereference> form does. Here, to add the id of the user in created-by, we add the {thisField: [targetFields] selector:
q/select: [
"fibery/id",
"fibery/name",
{"fibery/created-by": ["fibery/id"]}
]
In the example above, fibery/created-by points to at most one user. When we have a field that point to many entities, that is a collection field, we should have a way to filter them. The dereference form is not sufficient and the <vec-subselect> form must be used. The subselect expression is a full query of its own (a subquery). Here we add to each result also a collection of assignees, where for each assignee we select only one field, id:
q/select: [
"fibery/id",
"fibery/name",
{"fibery/created-by": ["fibery/id"]},
{"user/assignees": {
"q/select": ["fibery/id"],
"q/limit": "q/no-limit"
}}
]
Note that in some cases empty collections are returned as nulls.
In the example below we query entities from the Cricket/Player database and select:
a primitive Field Cricket/Full Name of primitive type fibery/text
a single-select Cricket/Batting Hand
a related entity Cricket/Current Team
an entity collection Field user/Former Teams
an aggregate (the oldest former team year of foundation).
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': [
'Cricket/Full Name',
{ 'Cricket/Batting Hand': [
'fibery/id',
'enum/name'
] },
{ 'Cricket/Current Team': [
'fibery/id',
'Cricket/name'
] },
{ 'user/Former Teams': {
'q/select': [
'Cricket/name',
'Cricket/Year Founded'
],
'q/limit': 'q/no-limit'
} },
{ 'oldest former team founded': [ 'q/min', ['user/Former Teams', 'Cricket/Year Founded'] ] }
],
'q/limit': 2
});
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": [
"Cricket/Full Name",
{ "Cricket/Batting Hand": [
"fibery/id",
"enum/name"
] },
{ "Cricket/Current Team": [
"fibery/id",
"Cricket/name"
] },
{ "user/Former Teams": {
"q/select": [
"Cricket/name",
"Cricket/Year Founded"
],
"q/limit": "q/no-limit" }
},
{ "oldest former team founded": [ "q/min", ["user/Former Teams", "Cricket/Year Founded"] ] }
],
"q/limit": 2
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/Current Team": {
"Cricket/name": "Delhi",
"fibery/id": "d328b7b0-97fa-11e9-81b9-4363f716f666"
},
"Cricket/Batting Hand": {
"enum/name": "Right",
"fibery/id": "b0ed1370-9747-11e9-9f03-fd937c4ecf3b"
},
"Cricket/Full Name": "Virat 'Chikoo' Kohli",
"user/Former Teams": [
{
"Cricket/name": "Delhi",
"Cricket/Year Founded": 1934
}
],
"oldest former team founded": 1934
},
{
"Cricket/Current Team": {
"Cricket/name": "Sunrisers Hyderabad",
"fibery/id": "2456d780-97fa-11e9-81b9-4363f716f666"
},
"Cricket/Batting Hand": {
"enum/name": "Right",
"fibery/id": "b0ed1370-9747-11e9-9f03-fd937c4ecf3b"
},
"Cricket/Full Name": "Kane Stuart Williamson",
"user/Former Teams": [
{
"Cricket/name": "Northern Districts",
"Cricket/Year Founded": 1955
},
{
"Cricket/name": "Gloucestershire",
"Cricket/Year Founded": 1870
},
{
"Cricket/name": "Yorkshire",
"Cricket/Year Founded": 1863
},
{
"Cricket/name": "Barbados Tridents",
"Cricket/Year Founded": 2013
}
],
"oldest former team founded": 1863
}
]
}
Select aggregates
select-func is a Lisp-style function call
<select-func> = [<func>, <field-path>, ...]
<func> = "q/count" | "q/min" | "q/max" | ...
Available entity collection Field aggregates
q/count
q/sum
q/avg
q/min
q/max
It doesn't matter if a Field is populated manually or via a Formula/Lookup — the query stays exactly the same.
Select count
Count is the only aggregate which can be used on the top level:
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": ["q/count", ["fibery/id"]]
}
}
}
'
Result (cURL):
{
"success": true,
"result": 42
}
Select rich text Field
Take a look how rich text Fields work in Fibery, if you haven't yet.
To select a rich text Field we should:
Get fibery/secret of the corresponding collaborative document.
Get the document via api/documents endpoint using this fibery/secret.
Supported document formats:
Cricket/Player Type used as an example
Field name | Field type |
|---|
Cricket/Bio
| rich text (Collaboration~Documents/Document) |
Get the related collaborative document's fibery/secret:
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": [
"Cricket/name",
{ "Cricket/Bio": [ "Collaboration~Documents/secret" ] }
],
"q/limit": 2
}
}
}
'
Grab the secrets (cURL):
{
"success": true,
"result": [
{
"Cricket/name": "Virat Kohli",
"Cricket/Bio": {
"Collaboration~Documents/secret": "b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb"
}
},
{
"Cricket/name": "Kane Williamson",
"Cricket/Bio": {
"Collaboration~Documents/secret": "b33a25d3-99ba-11e9-8c59-09d0cb6f3aeb"
}
}
]
}
Get the documents one-by-one:
curl -X GET https://YOUR_ACCOUNT.fibery.io/api/documents/b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb?format=html \
-H 'Authorization: Token YOUR_TOKEN' \
curl -X GET https://YOUR_ACCOUNT.fibery.io/api/documents/b33a25d3-99ba-11e9-8c59-09d0cb6f3aeb?format=html \
-H 'Authorization: Token YOUR_TOKEN' \
Result:
{
"secret": "b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb",
"content": "<p>Virat Kohli (born 5 November 1988) is an Indian <a href=\"https://en.wikipedia.org/wiki/Cricket\">cricketer</a> who currently captains the India national team.\nHe plays for Royal Challengers Bangalore in the Indian Premier League.</p>"
}
{
"secret": "b33a25d3-99ba-11e9-8c59-09d0cb6f3aeb",
"content": "<p><strong>Kane Stuart Williamson</strong> (born 8 August 1990) is a New Zealand international <a href=\"https://en.wikipedia.org/wiki/Cricket\" title=\"Cricket\">cricketer</a> who is currently the <a href=\"https://en.wikipedia.org/wiki/Captain_(cricket)\" title=\"Captain (cricket)\">captain</a> of the <a href=\"https://en.wikipedia.org/wiki/New_Zealand_national_cricket_team\" title=\"New Zealand national cricket team\">New Zealand national team</a>.</p><p>He is a right-handed batsman and an occasional <a href=\"https://en.wikipedia.org/wiki/Off_spin\" title=\"Off spin\">off spin</a> bowler and is considered to be one of the best batsmen in the world.</p>"
}
Get multiple documents in a single batch request:
curl --location --request POST 'https://YOUR_ACCOUNT.fibery.io/api/documents/commands' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"command": "get-documents",
"args": [
{
"secret": "b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb"
},
{
"secret": "b33a25d3-99ba-11e9-8c59-09d0cb6f3aeb"
}
]
}'
Result:
[
{
"secret": "b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb",
"content": "..."
},
{
"secret": "b33a25d3-99ba-11e9-8c59-09d0cb6f3aeb",
"content": "..."
}
]
Filter Entities
Filters (where) go into the q/where clause of the query.
The general form is inspired by Lisp: it's a list where the first element is an operator and the remaining elements are the values to check using the operator:
<where> = [<operator> <operand> <operand> ...]
<operator> = ">", ">=", "<", "<=", ...
<operand> = <fieldexpr> | <subquery-vec>
In these examples we filter by:
a primitive Field (height)
two primitive Fields (birth date and retirement status)
a single-select (batting hand)
an entity Field (current team)
an entity collection Field (former teams)
We don't compare Entity's Field to a value directly, but use a $param instead.
Cricket/Player Type used as an example
Field name | Field type |
|---|
Cricket/Height
| fibery/decimal
|
Cricket/Youth Career
| fibery/date-range
|
Cricket/Retired?
| fibery/bool
|
Cricket/Batting Hand
| single-select |
Cricket/Current Team
| entity Field |
user/Former Teams
| entity collection Field |
Operators
=
!=
<
<=
>
>=
q/contains
q/not-contains
q/in
q/not-in
q/and
q/or
Get players taller than 1.75 meters — primitive Field:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': ['Cricket/name', 'Cricket/Height'],
'q/where': ['>', ['Cricket/Height'], '$height' ],
'q/limit': 2
}, { '$height': '1.75' });
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": ["Cricket/name", "Cricket/Height"],
"q/where": [">", ["Cricket/Height"], "$height" ],
"q/limit": 2
},
"params": {
"$height": "1.75"
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/name": "Cheteshwar Pujara",
"Cricket/Height": "1.79"
}
]
}
Filters can be nested and combined using q/and and q/or. Here we are querying players who started their youth career before 2004 and haven't retired yet:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': ['Cricket/name', 'Cricket/Youth Career', 'Cricket/Retired?'],
'q/where': [
'q/and',
['<', ['q/start', ['Cricket/Youth Career']], '$date'],
['=', ['Cricket/Retired?'], '$retired?']
],
'q/limit': 2
}, {
'$date': '2004-01-01',
'$retired?': false
});
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": ["Cricket/name", "Cricket/Youth Career", "Cricket/Retired?"],
"q/where": [
"q/and",
["<", ["q/start", ["Cricket/Youth Career"]], "$date"],
["=", ["Cricket/Retired?"], "$retired?"]
],
"q/limit": 2
},
"params": {
"$date": "2004-01-01",
"$retired?": false
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/name": "Virat Kohli",
"Cricket/Youth Career": {
"start": "2002-10-01",
"end": "2008-07-01"
},
"Cricket/Retired?": false
}
]
}
Get right-handed players — single-select:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': ['Cricket/name', { 'Cricket/Batting Hand': ['enum/name'] }],
'q/where': ['=', ['Cricket/Batting Hand', 'enum/name'], '$hand' ],
'q/limit': 2
}, { '$hand': 'Right' });
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": ["Cricket/name", { "Cricket/Batting Hand": ["enum/name"] } ],
"q/where": ["=", ["Cricket/Batting Hand", "enum/name"], "$hand" ],
"q/limit": 2
},
"params": {
"$hand": "Right"
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/name": "Virat Kohli",
"Cricket/Batting Hand": {
"enum/name": "Right"
}
},
{
"Cricket/name": "Kane Williamson",
"Cricket/Batting Hand": {
"enum/name": "Right"
}
}
]
}
Get players whose current team was founded before 2000 — entity Field:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': ['Cricket/name', { 'Cricket/Current Team': ['Cricket/name'] }],
'q/where': ['<', ['Cricket/Current Team', 'Cricket/Year Founded'], '$year' ],
'q/limit': 2
}, { '$year': 2000 });
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": ["Cricket/name", { "Cricket/Current Team": ["Cricket/name"] } ],
"q/where": ["<", ["Cricket/Current Team", "Cricket/Year Founded"], "$year" ],
"q/limit": 2
},
"params": {
"$year": 2000
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/name": "Virat Kohli",
"Cricket/Current Team": {
"Cricket/name": "Delhi"
}
},
{
"Cricket/name": "Cheteshwar Pujara",
"Cricket/Current Team": {
"Cricket/name": "Saurashtra"
}
}
]
}
Get players who previously played for Yorkshire or Derbyshire — entity collection Field:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': ['Cricket/name', { 'user/Former Teams': { 'q/select': ['Cricket/name'], 'q/limit': 'q/no-limit' } } ],
'q/where': ['q/in', ['user/Former Teams', 'Cricket/name'], '$teams' ],
'q/limit': 2
}, { '$teams': ['Yorkshire', 'Derbyshire'] });
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": ["Cricket/name", { "user/Former Teams": { "q/select": ["Cricket/name"], "q/limit": "q/no-limit" } } ],
"q/where": ["q/in", ["user/Former Teams", "Cricket/name"], "$teams" ],
"q/limit": 2
},
"params": {
"$teams": ["Yorkshire", "Derbyshire"]
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/name": "Kane Williamson",
"user/Former Teams": [
{ "Cricket/name": "Northern Districts" },
{ "Cricket/name": "Gloucestershire" },
{ "Cricket/name": "Yorkshire" },
{ "Cricket/name": "Barbados Tridents" }
]
},
{
"Cricket/name": "Cheteshwar Pujara",
"user/Former Teams": [
{ "Cricket/name": "Royal Challengers Bangalore" },
{ "Cricket/name": "Yorkshire" },
{ "Cricket/name": "Kolkata Knight Riders" },
{ "Cricket/name": "Kings XI Punjab" },
{ "Cricket/name": "Derbyshire" },
{ "Cricket/name": "Nottinghamshire" }
]
}
]
}
Order Entities
<order-by> = [[<field-path>, "q/asc" | "q/desc"], ...];
Sort Entities by multiple primitive and entity Fields.
The default sorting is by creation date and UUID:
[ [["fibery/creation-date"], "q/asc"], [["fibery/id"], "q/asc"] ]
Sorting by fibery/id guarantees that Entities order won't change on different executions of the same query.
Cricket/Player Type used as an example
Field name | Field type |
|---|
Cricket/Height
| fibery/decimal
|
Cricket/Current Team
| entity Field |
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const players = await fibery.entity.query({
'q/from': 'Cricket/Player',
'q/select': [
'Cricket/name',
'Cricket/Height',
{ 'Cricket/Current Team': ['Cricket/name'] }
],
'q/order-by': [
[['Cricket/Height'], 'q/desc'],
[['Cricket/Current Team', 'Cricket/name'], 'q/asc']
],
'q/limit': 3
});
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": [
"Cricket/name",
"Cricket/Height",
{ "Cricket/Current Team": ["Cricket/name"] }
],
"q/order-by": [
[["Cricket/Height"], "q/desc"],
[["Cricket/Current Team", "Cricket/name"], "q/asc"]
],
"q/limit": 3
}
}
}
'
Result (cURL):
{
"success": true,
"result": [
{
"Cricket/Current Team": {
"Cricket/name": "Saurashtra"
},
"Cricket/Height": "1.79",
"Cricket/name": "Cheteshwar Pujara"
},
{
"Cricket/Current Team": {
"Cricket/name": "Royal Challengers Bangalore"
},
"Cricket/Height": "1.75",
"Cricket/name": "Virat Kohli"
},
{
"Cricket/Current Team": {
"Cricket/name": "Sunrisers Hyderabad"
},
"Cricket/Height": "1.75",
"Cricket/name": "Kane Williamson"
}
]
}
Create Entity
Create Entities with primitive, single-select and entity Fields.
Setting fibery/id is optional and might be useful for working with Entity right after creation.
To set a single-select or an entity Field we'll need the target Entity's fibery/id. We can get fibery/id either via API (check Getting Entities)or by opening the relevant Entity on UI and exploring the command response in browser's Network tab.
Note that the target related Entity should already exist.
Setting entity collection Fields on Entity creation is not supported. Instead we suggest updating entity collection Fields after the Entity is created.
Setting a rich text Field on creation is not possible either. Update rich text Field once the Entity is created instead.
Cricket/Player Type used as an example
Field name | Field type |
|---|
fibery/id
| fibery/uuid
|
fibery/public-id
| fibery/text
|
Cricket/name
| fibery/text
|
Cricket/Full Name
| fibery/text
|
Cricket/Born
| fibery/date
|
Cricket/Youth Career
| fibery/date-range
|
Cricket/Shirt Number
| fibery/int
|
Cricket/Height
| fibery/decimal
|
Cricket/Retired?
| fibery/bool
|
Cricket/Batting Hand
| single-select |
Cricket/Current Team
| entity Field |
user/Former Teams
| entity collection Field |
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.entity.createBatch([
{
'type': 'Cricket/Player',
'entity': {
'fibery/id': 'd17390c4-98c8-11e9-a2a3-2a2ae2dbcce4',
'Cricket/name': 'Curtly Ambrose',
'Cricket/Full Name': 'Curtly Elconn Lynwall Ambrose',
'Cricket/Born': '1963-09-21',
'Cricket/Youth Career': {
'start': '1985-01-01',
'end': '1986-01-01'
},
'Cricket/Shirt Number': 1,
'Cricket/Height': '2.01',
'Cricket/Retired?': true,
'Cricket/Batting Hand': { 'fibery/id': 'b0ed3a80-9747-11e9-9f03-fd937c4ecf3b' }
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/create",
"args": {
"type": "Cricket/Player",
"entity": {
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"Cricket/name": "Curtly Ambrose",
"Cricket/Full Name": "Curtly Elconn Lynwall Ambrose",
"Cricket/Born": "1963-09-21",
"Cricket/Youth Career": {
"start": "1985-01-01",
"end": "1986-01-01"
},
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": true,
"Cricket/Batting Hand": { "fibery/id": "b0ed3a80-9747-11e9-9f03-fd937c4ecf3b" }
}
}
}
'
Result with all primitive Fields, single-selects and entity Fields:
{
"success": true,
"result": {
"Cricket/Height": "2.01",
"fibery/modification-date": "2019-06-27T10:44:53.860Z",
"Cricket/Born": "1963-09-21",
"fibery/id": "98fd77a0-98c8-11e9-8af8-976831879f29",
"fibery/creation-date": "2019-06-27T10:44:53.860Z",
"Cricket/Shirt Number": 1,
"Cricket/Full Name": "Curtly Elconn Lynwall Ambrose",
"fibery/public-id": "6",
"Cricket/Retired?": true,
"Cricket/Current Team": null,
"Cricket/Batting Hand": {
"fibery/id": "b0ed3a80-9747-11e9-9f03-fd937c4ecf3b"
},
"Cricket/Youth Career": {
"start": "1985-01-01",
"end": "1986-01-01"
},
"Cricket/name": "Curtly Ambrose"
}
}
Update Entity
Update primitive, single-select and entity Fields this way. For updating entity collection Fields check out the section below.
To update a single-select or an entity Field, we'll need the target Entity's fibery/id. We can get fibery/id either via API or by opening the relevant Entity on UI and exploring the command response in browser's Network tab. Note that the target Entity should already exist.
Cricket/Player Type used as an example
Field name | Field type |
|---|
fibery/id
| fibery/uuid
|
fibery/public-id
| fibery/text
|
Cricket/name
| fibery/text
|
Cricket/Full Name
| fibery/text
|
Cricket/Born
| fibery/date
|
Cricket/Youth Career
| fibery/date-range
|
Cricket/Shirt Number
| fibery/int
|
Cricket/Height
| fibery/decimal
|
Cricket/Retired?
| fibery/bool
|
Cricket/Batting Hand
| single-select |
Cricket/Current Team
| entity Field |
user/Former Teams
| entity collection Field |
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.entity.updateBatch([
{
'type': 'Cricket/Player',
'entity': {
'fibery/id': '20f9b920-9752-11e9-81b9-4363f716f666',
'Cricket/Full Name': 'Virat \"Chikoo\" Kohli',
'Cricket/Current Team': { 'fibery/id': 'd328b7b0-97fa-11e9-81b9-4363f716f666' }
}
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/update",
"args": {
"type": "Cricket/Player",
"entity": {
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"Cricket/Full Name": "Virat \"Chikoo\" Kohli",
"Cricket/Current Team": { "fibery/id": "d328b7b0-97fa-11e9-81b9-4363f716f666" }
}
}
}
'
Result with all primitive Fields, single-select and entity Fields:
{
"success": true,
"result": {
"Cricket/Height": "1.75",
"fibery/modification-date": "2019-06-27T12:17:02.842Z",
"Cricket/Born": "1988-11-05",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"fibery/creation-date": "2019-06-25T14:04:20.988Z",
"Cricket/Shirt Number": 18,
"Cricket/Full Name": "Virat \"Chikoo\" Kohli",
"fibery/public-id": "1",
"Cricket/Retired?": false,
"Cricket/Current Team": {
"fibery/id": "d328b7b0-97fa-11e9-81b9-4363f716f666"
},
"Cricket/Batting Hand": {
"fibery/id": "b0ed1370-9747-11e9-9f03-fd937c4ecf3b"
},
"Cricket/Youth Career": {
"start": "2002-10-01",
"end": "2008-07-01"
},
"Cricket/name": "Virat Kohli"
}
}
Update entity collection Field
Add already existing Entities to an entity collection Field by providing their fibery/id. Remove Entities from the collection in a similar way.
Get fibery/id either via API or by opening the relevant Entity on UI and exploring the command response in browser's Network tab.
Cricket/Player Type used as an example
Field name | Field type |
|---|
fibery/id
| fibery/uuid
|
user/Former Teams
| entity collection Field |
Add
Add two existing Teams to Player's "Former Teams" entity collection Field (if team already exists in the collection then team will be ignored during addition):
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.entity.addToEntityCollectionFieldBatch([
{
'type': 'Cricket/Player',
'field': 'user/Former Teams',
'entity': { 'fibery/id': '216c2a00-9752-11e9-81b9-4363f716f666' },
'items': [
{ 'fibery/id': '0a3ae1c0-97fa-11e9-81b9-4363f716f666' },
{ 'fibery/id': '17af8db0-97fa-11e9-81b9-4363f716f666' }
]
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/add-collection-items",
"args": {
"type": "Cricket/Player",
"field": "user/Former Teams",
"entity": {
"216c2a00-9752-11e9-81b9-4363f716f666": [
"0a3ae1c0-97fa-11e9-81b9-4363f716f666",
"17af8db0-97fa-11e9-81b9-4363f716f666"
]
}
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Remove
Remove two Teams from Player's "Former Teams" entity collection Field (if team doesn't exist in the collection then team will be ignored during removing):
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.entity.removeFromEntityCollectionFieldBatch([
{
'type': 'Cricket/Player',
'field': 'user/Former Teams',
'entity': { 'fibery/id': '216c2a00-9752-11e9-81b9-4363f716f666' },
'items': [
{ 'fibery/id': '0a3ae1c0-97fa-11e9-81b9-4363f716f666' },
{ 'fibery/id': '17af8db0-97fa-11e9-81b9-4363f716f666' }
]
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/remove-collection-items",
"args": {
"type": "Cricket/Player",
"field": "user/Former Teams",
"entity": {
"216c2a00-9752-11e9-81b9-4363f716f666": [
"0a3ae1c0-97fa-11e9-81b9-4363f716f666",
"17af8db0-97fa-11e9-81b9-4363f716f666"
]
}
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Set
Replace two Teams from Player's "Former Teams" entity collection Field with new team.
Replace means deletion of any existing collection items and adding new items.
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/set-collection-items",
"args": {
"type": "Cricket/Player",
"field": "user/Former Teams",
"entity": {
"216c2a00-9752-11e9-81b9-4363f716f666": [
"02007d5e-b3d9-44c3-83de-6b562870f120"
]
}
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Reset
Resets "Former Teams" entity collection Field with new team.
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/reset-collection-items",
"args": {
"type": "Cricket/Player",
"field": "user/Former Teams",
"entity": "216c2a00-9752-11e9-81b9-4363f716f666"
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}
Update rich text Field
To update a rich text Field we should:
Get fibery/secret of the corresponding collaborative document.
Update the document via api/documents endpoint using this fibery/secret.
Supported document formats:
Cricket/Player Type used as an example
Field name | Field type |
|---|
Cricket/Bio
| rich text (Collaboration~Documents/Document) |
Get collaborative document's fibery/secret:
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/query",
"args": {
"query": {
"q/from": "Cricket/Player",
"q/select": [
"fibery/id",
{ "Cricket/Bio": [ "Collaboration~Documents/secret" ] }
],
"q/where": ["=", ["fibery/id"], "$id"],
"q/limit": 1
},
"params": { "$id": "20f9b920-9752-11e9-81b9-4363f716f666" }
}
}
'
Grab the secret:
{
"success": true,
"result": [
{
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"Cricket/Bio": {
"Collaboration~Documents/secret": "b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb"
}
}
]
}
Update the document:
curl -X PUT https://YOUR_ACCOUNT.fibery.io/api/documents/b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb?format=md \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'{
"content": "Virat Kohli (born 5 November 1988) is an Indian [cricketer](https://en.wikipedia.org/wiki/Cricket) who currently captains the India national team.\nHe plays for Royal Challengers Bangalore in the Indian Premier League."
}'
Update multiple documents in a single batch request:
curl -X POST 'https://YOUR_ACCOUNT.fibery.io/api/documents/commands?format=md' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d \
'{
"command": "create-or-update-documents",
"args": [
{
"secret": "b33a25d1-99ba-11e9-8c59-09d0cb6f3aeb",
"content": "my md content 1"
},
{
"secret": "b33a25d3-99ba-11e9-8c59-09d0cb6f3aeb",
"content": "my md content 2"
}
]
}'
Status code 200 means that the update has been successful.
Add comment
Once you install the Comments extension on a Type, you are free to add comments to the Type's Entities – both via UI and API.
Here at Fibery, we don't throw abstractions around so comments are assembled from the pre-existing basic building blocks:
Comment (comments/comment) is a Type with Fields like Author (fibery/created-by) and Creation Date (fibery/creation-date).
The Comments extension connects a parent Type with Comment Type via a one-to-many relation.
Each individual comment is an Entity of Comment Type.
The content of a comment is stored in a collaborative document just like rich-text Fields.
So here is how you add comment:
Create an Entity of the Comment Type.
Connect this comment to a proper parent Entity.
Set the comment's content.
Generate two UUIDs – for the comment ID and the document secret ID:
a88626cb-2f08-4821-9d5f-3edb9b624c26
9f18d395-05da-44dc-9f21-602b2e744b14
Create an Entity of the auxiliary Comment Type and link it to the parent Entity:
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
const PARENT_ENTITY_ID = '216c2a00-9752-11e9-81b9-4363f716f666';
const COMMENT_AUTHOR_ID = 'fe1db100-3779-11e9-9162-04d77e8d50cb';
const COMMENT_ID = 'a88626cb-2f08-4821-9d5f-3edb9b624c26'; // newly generated
const DOCUMENT_SECRET_ID = '9f18d395-05da-44dc-9f21-602b2e744b14'; // newly generated
const comment = await fibery.entity.create({
'type': 'comments/comment',
'entity': {
'fibery/id': COMMENT_ID,
'comment/document-secret': DOCUMENT_SECRET_ID,
'fibery/created-by': { 'fibery/id': COMMENT_AUTHOR_ID }
}
});
await fibery.entity.addToEntityCollectionField({
'type': 'Cricket/Player',
'field': 'comments/comments',
'entity': { 'fibery/id': PARENT_ENTITY_ID },
'items': [
{ 'fibery/id': COMMENT_ID }
]
});
cURL
curl -X POST https://YO UR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command":"fibery.command/batch",
"args":{
"commands":[
{
"command":"fibery.entity/create",
"args":{
"type":"comments/comment",
"entity":{
"fibery/id":"a88626cb-2f08-4821-9d5f-3edb9b624c26",
"comment/document-secret":"9f18d395-05da-44dc-9f21-602b2e744b14",
"fibery/created-by": { "fibery/id": "fe1db100-3779-11e9-9162-04d77e8d50cb" }
}
}
},
{
"command":"fibery.entity/add-collection-items",
"args":{
"type":"Cricket/Player",
"entity":{
"fibery/id":"20f9b920-9752-11e9-81b9-4363f716f666"
},
"field":"comments/comments",
"items":[
{
"fibery/id": "a88626cb-2f08-4821-9d5f-3edb9b624c26"
}
]
}
}
]
}
}
'
Make sure the result looks good:
{
"success": true,
"result": [
{
"success": true,
"result": {
"comment/document-secret": "9f18d395-05da-44dc-9f21-602b2e744b14",
"fibery/id": "a88626cb-2f08-4821-9d5f-3edb9b624c26",
"fibery/public-id": "139",
"fibery/creation-date": "2021-05-05T17:37:21.933Z",
"comment/content": null,
"fibery/created-by": {
"fibery/id": "fe1db100-3779-11e9-9162-04d77e8d50cb"
}
}
},
{
"success": true,
"result": null
}
]
}
Set the comment's content:
JavaScript
const content = 'He is the [G.O.A.T.](https://en.wikipedia.org/wiki/Greatest_of_All_Time) batsman!';
await fibery.document.update('9f18d395-05da-44dc-9f21-602b2e744b14', content, 'md');
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/documents/commands?format=md \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'{
"command": "create-or-update-documents",
"args": [
{
"secret": "9f18d395-05da-44dc-9f21-602b2e744b14",
"content": "He is the [G.O.A.T.](https://en.wikipedia.org/wiki/Greatest_of_All_Time) batsman!"
}
]
}'
Create or Update Entity
Creates Entity (or Entities) if no existing duplicate is found (based on the Conflict Field); otherwise, it either skips creating or updates the existing duplicate, depending on the Conflict Action.
Setting the fibery/id Field for Entities is mandatory to apply the Conflict Action when a duplicate is found.
The Conflict Field can be of type: fibery/text, fibery/int, or fibery/date
Conflict Action | Description |
skip-create
| do not create Entity if a Duplicate was found |
update-latest
| updates the Duplicate found with all fields from the Entity to be created, excluding platform fields (fibery/id, fibery/public-id, fibery/rank, fibery/creation-date). If more than one Duplicate is found, the Duplicate with the latest fibery/creation-date is selected for updating. |
If a batch of Entities is passed to the command and it contains Duplicates, the following action is taken:
Duplicate matching rules:
The result is an array of created Entities or resolved Conflicts, in the order of the Entities. The array contents are determined as follows:
Created: If an Entity was created, the array contains the new Entity's information with create action.
Skipped: If an Entity was not created because skip-create was applied to a found Duplicate, the array contains a resolved Conflict with skip-create action.
Updated: If an Entity was used to update a found Duplicate due to update-latest, the array contains a resolved Conflict with update-latest action.
Batch Duplicate handling: If an Entity was ignored due to a Duplicate found within the same batch of Entities, the array contains a resolved Conflict with prefer-duplicate-found-in-the-batch action. This action uses the Duplicate entity (D) and resolves it by applying the specified Conflict Action later:
If no Conflict is found for D, the array contains the created Entity D info with create action.
If a Conflict is found for D and resolved with skip-create, the array contains a resolved Conflict with skip-create action.
If a Conflict is found for D and resolved with update-latest, the array contains a resolved Conflict with update-latest action.
Case 1 (cURL)
Batch of Entities contain duplicates
There are no existing duplicates in the DB
Conflict Action is skip-create
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity.batch/create-or-update",
"args": {
"type": "Cricket/Player",
"entities": [
{
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 1 (does not exist in the DB)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
{
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"Cricket/Name": "Virat Kohli", <------------------------------------ Entity 2 (does not exist in the DB)
"Cricket/Shirt Number": 18,
"Cricket/Height": "1.75",
"Cricket/Retired?": false
},
{
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 3 (dDuplicate of Entity 1)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
}
],
"conflict-field": "Cricket/Name",
"conflict-action": "skip-create"
}
}
'
Result:
{
"success": true,
"result": [
{
"action": "create",
"created": {
"Cricket/Height": "2.01",
"fibery/modification-date": "2025-09-02T14:32:25.905Z",
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:32:25.905Z",
"Cricket/Name": "Curtly Ambrose",
"fibery/public-id": "3",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 1,
"Cricket/Description": {"fibery/id": "01990ad7-e855-701f-ae77-6c146f6b9ee7"},
"fibery/rank": 5674304923033269
}
},
{
"action": "create",
"created": {
"Cricket/Height": "1.75",
"fibery/modification-date": "2025-09-02T14:32:25.905Z",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:32:25.905Z",
"Cricket/Name": "Virat Kohli",
"fibery/public-id": "2",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 18,
"Cricket/Description": {"fibery/id": "01990ad7-e855-701d-a776-0d933166aa86"},
"fibery/rank": 5674304922933269
}
},
{
"action": "prefer-duplicate-found-in-the-batch",
"entity": {
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
},
"duplicate": {
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
}
}
]
}
Case 2 (cURL)
Batch of Entities contains duplicates
There are existing duplicates in the DB
Conflict Action is skip-create
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity.batch/create-or-update",
"args": {
"type": "Cricket/Player",
"entities": [
{
"fibery/id": "a1185326-afc5-4467-a8f7-825b090a97e1",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 1 (already exists in the DB)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
{
"fibery/id": "abe35d9b-4286-49f9-9ecb-0a777dcf98da",
"Cricket/Name": "Virat Kohli", <------------------------------------ Entity 2 (already exists in the DB)
"Cricket/Shirt Number": 18,
"Cricket/Height": "1.75",
"Cricket/Retired?": false
},
{
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 3 (duplicate of Entity 1)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
}
],
"conflict-field": "Cricket/Name",
"conflict-action": "skip-create"
}
}
'
Result:
{
"success": true,
"result": [
{
"action": "skip-create",
"entity": {
"fibery/id": "a1185326-afc5-4467-a8f7-825b090a97e1",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
"duplicate": {
"Cricket/Height": "2.01",
"fibery/modification-date": "2025-09-02T14:32:25.905Z",
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:32:25.905Z",
"Cricket/Name": "Curtly Ambrose",
"fibery/public-id": "3",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 1,
"Cricket/Description": {"fibery/id": "01990ad7-e855-701f-ae77-6c146f6b9ee7"},
"fibery/rank": 5674304923033269
}
},
{
"action": "skip-create",
"entity": {
"fibery/id": "abe35d9b-4286-49f9-9ecb-0a777dcf98da",
"Cricket/Name": "Virat Kohli",
"Cricket/Shirt Number": 18,
"Cricket/Height": "1.75",
"Cricket/Retired?": false
},
"duplicate": {
"Cricket/Height": "1.75",
"fibery/modification-date": "2025-09-02T14:32:25.905Z",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:32:25.905Z",
"Cricket/Name": "Virat Kohli",
"fibery/public-id": "2",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 18,
"Cricket/Description": {"fibery/id": "01990ad7-e855-701d-a776-0d933166aa86"},
"fibery/rank": 5674304922933269
}
},
{
"action": "prefer-duplicate-found-in-the-batch",
"entity": {
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
},
"duplicate": {
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
}
}
]
}
Case 3 (cURL)
Batch of Entities contains duplicates
There are no existing duplicates in the DB
Conflict Action is update-latest
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity.batch/create-or-update",
"args": {
"type": "Cricket/Player",
"entities": [
{
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 1 (duplicate of Entity 3)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
{
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"Cricket/Name": "Virat Kohli", <---------------------------------- Entity 2 (does not exist in the DB)
"Cricket/Shirt Number": 18,
"Cricket/Height": "1.75",
"Cricket/Retired?": false
},
{
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 3 (does not exist in the DB)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
}
],
"conflict-field": "Cricket/Name",
"conflict-action": "update-latest"
}
}
'
Result:
{
"success": true,
"result": [
{
"action": "prefer-duplicate-found-in-the-batch",
"entity": {
"fibery/id": "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
"duplicate": {
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
}
},
{
"action": "create",
"created": {
"Cricket/Height": "1.75",
"fibery/modification-date": "2025-09-02T14:39:58.586Z",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:39:58.586Z",
"Cricket/Name": "Virat Kohli",
"fibery/public-id": "4",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 18,
"Cricket/Description": {"fibery/id": "01990ade-d091-7022-b1c4-7efe12ccd84b"},
"fibery/rank": 7072311628808326
}
},
{
"action": "create",
"created": {
"Cricket/Height": "2.10",
"fibery/modification-date": "2025-09-02T14:39:58.586Z",
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:39:58.586Z",
"Cricket/Name": "Curtly Ambrose",
"fibery/public-id": "5",
"Cricket/Retired?": true,
"Cricket/Shirt Number": 1,
"Cricket/Description": {"fibery/id": "01990ade-d091-7024-9fd1-e03f62f5860e"},
"fibery/rank": 7072311628908326
}
}
]
}
Case 4 (cURL)
Batch of Entities contains duplicates
There are existing duplicates in the DB
Conflict Action is update-latest
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity.batch/create-or-update",
"args": {
"type": "Cricket/Player",
"entities": [
{
"fibery/id": "a1185326-afc5-4467-a8f7-825b090a97e1",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 1 (duplicate of Entity 3)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
{
"fibery/id": "abe35d9b-4286-49f9-9ecb-0a777dcf98da",
"Cricket/Name": "Virat Kohli", <--------------------------------- Entity 2 (already exists in the Db)
"Cricket/Shirt Number": 18,
"Cricket/Height": "1.75",
"Cricket/Retired?": false
},
{
"fibery/id": "c79d09ba-1c2d-40f4-aa3b-cf7bc79ff7a8",
"Cricket/Name": "Curtly Ambrose", <--------------------------------- Entity 3 (already exists in the DB)
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.10",
"Cricket/Retired?": true
}
],
"conflict-field": "Cricket/Name",
"conflict-action": "update-latest"
}
}
'
Result:
{
"success": true,
"result": [
{
"action": "prefer-duplicate-found-in-the-batch",
"entity": {
"fibery/id": "a1185326-afc5-4467-a8f7-825b090a97e1",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.01",
"Cricket/Retired?": false
},
"duplicate": {
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.15",
"Cricket/Retired?": true
}
},
{
"action": "update-latest",
"entity": {
"fibery/id": "abe35d9b-4286-49f9-9ecb-0a777dcf98da",
"Cricket/Name": "Virat Kohli",
"Cricket/Shirt Number": 18,
"Cricket/Height": "1.75",
"Cricket/Retired?": false
},
"duplicate": {
"Cricket/Height": "1.75",
"fibery/modification-date": "2025-09-02T14:39:58.586Z",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:39:58.586Z",
"Cricket/Name": "Virat Kohli",
"fibery/public-id": "4",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 18,
"Cricket/Description": {"fibery/id": "01990ade-d091-7022-b1c4-7efe12ccd84b"},
"fibery/rank": 7072311628808326
},
"updated": {
"Cricket/Height": "1.75",
"fibery/id": "20f9b920-9752-11e9-81b9-4363f716f666",
"Cricket/Name": "Virat Kohli",
"Cricket/Retired?": false,
"Cricket/Shirt Number": 18
}
},
{
"action": "update-latest",
"entity": {
"fibery/id": "c79d09ba-1c2d-40f4-aa3b-cf7bc79ff7a8",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Shirt Number": 1,
"Cricket/Height": "2.15",
"Cricket/Retired?": true
},
"duplicate": {
"Cricket/Height": "2.10",
"fibery/modification-date": "2025-09-02T14:39:58.586Z",
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"fibery/created-by": {"fibery/id": "4044090b-7165-4791-ac15-20fb12ae0b64"},
"fibery/creation-date": "2025-09-02T14:39:58.586Z",
"Cricket/Name": "Curtly Ambrose",
"fibery/public-id": "5",
"Cricket/Retired?": true,
"Cricket/Shirt Number": 1,
"Cricket/Description": {"fibery/id": "01990ade-d091-7024-9fd1-e03f62f5860e"},
"fibery/rank": 7072311628908326
},
"updated": {
"Cricket/Height": "2.15",
"fibery/id": "79580f9d-fd30-439e-8040-6922d9f0455d",
"Cricket/Name": "Curtly Ambrose",
"Cricket/Retired?": true,
"Cricket/Shirt Number": 1
}
}
]
}
Delete Entity
Delete Entity by providing its Type and fibery/id.
JavaScript
const Fibery = require('fibery-unofficial');
const fibery = new Fibery({host: "YOUR_ACCOUNT.fibery.io", token: YOUR_TOKEN});
await fibery.entity.deleteBatch([
{
'type': 'Cricket/Player',
'entity': { 'fibery/id': 'b4f2e9b0-9907-11e9-acf1-fd0d502cdd20' }
}
]);
cURL
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d \
'
{
"command": "fibery.entity/delete",
"args": {
"type": "Cricket/Player",
"entity": { "fibery/id": "93648510-9907-11e9-acf1-fd0d502cdd20" }
}
}
'
Result (cURL):
{
"success": true,
"result": "ok"
}