### Install Mixin Example Source: https://developers.fibery.com/guides/http-api/databases This snippet demonstrates how to install a mixin using the Fibery command. It specifies the command, arguments, and types involved in the operation. ```javascript const command = 'fibery.app/install-mixins'; const args = { }; const types = { 'Cricket/Player': [ 'fibery/rank-mixin' ] }; const data = await response.json(); ``` -------------------------------- ### Create Database Example Source: https://developers.fibery.com/guides/http-api/databases A comprehensive JavaScript example demonstrating the creation of a database with specified fields and mixins. ```javascript const response = // ... rest of the code is truncated in the source ``` -------------------------------- ### Install Mixins Request Example Source: https://developers.fibery.com/guides/http-api/databases This JSON payload demonstrates how to install mixins for specific entity types. It specifies the command, arguments, and the types of entities and mixins involved. ```json { "command": "fibery.app/install-mixins", "args": { "types": { "Cricket/Player": [ "fibery/rank-mixin" ] } } } ``` -------------------------------- ### Install Mixins Response Example Source: https://developers.fibery.com/guides/http-api/databases This is a successful response to an install mixins request, indicating that the operation completed without errors. ```json { "success": true } ``` -------------------------------- ### Database Command Parameter Examples Source: https://developers.fibery.com/guides/http-api/databases Illustrates example values for database command parameters. Shows how to specify a database name and trigger deletion of entities or related fields. ```markdown | Parameter (required in bold) | Example | |---|---| | **name** | Cricket/Umpire | | delete-entities? | true | | delete-related-fields? | true | ``` -------------------------------- ### Create Database and Install Mixins with JavaScript Source: https://developers.fibery.com/guides/http-api/databases Use this JavaScript snippet to create a new database with specified fields and install the rank mixin. Ensure you replace 'YOUR_ACCOUNT' and 'YOUR_TOKEN' with your actual account details and API token. ```javascript const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', { method: 'POST', headers: { 'Authorization': 'Token YOUR_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'fibery.schema/batch', args: { commands: [ { command: 'schema.type/create', args: { 'fibery/name': 'Cricket/Player', 'fibery/meta': { 'fibery/domain?': true, 'fibery/secured?': true, 'ui/color': '#F7D130' }, 'fibery/fields': [ { 'fibery/name': 'Cricket/name', 'fibery/type': 'fibery/text', 'fibery/meta': { 'fibery/secured?': false, 'ui/title?': true } }, { 'fibery/name': 'fibery/id', 'fibery/type': 'fibery/uuid', 'fibery/meta': { 'fibery/secured?': false, 'fibery/id?': true, 'fibery/readonly?': true } }, { 'fibery/name': 'fibery/public-id', 'fibery/type': 'fibery/text', 'fibery/meta': { 'fibery/secured?': false, 'fibery/public-id?': true, 'fibery/readonly?': true } }, { 'fibery/name': 'fibery/creation-date', 'fibery/type': 'fibery/date-time', 'fibery/meta': { 'fibery/secured?': false, 'fibery/creation-date?': true, 'fibery/readonly?': true, 'fibery/default-value': '$now' } }, { 'fibery/name': 'fibery/modification-date', 'fibery/type': 'fibery/date-time', 'fibery/meta': { 'fibery/modification-date?': true, 'fibery/required?': true, 'fibery/readonly?': true, 'fibery/default-value': '$now', 'fibery/secured?': false } }, { 'fibery/name': 'user/salary', 'fibery/type': 'fibery/int', 'fibery/meta': { 'fibery/secured?': true } } ] } }, { command: 'fibery.app/install-mixins', args: { types: { 'Cricket/Player': ['fibery/rank-mixin'] } } } ] } }) }); const data = await response.json(); ``` -------------------------------- ### Create Database and Install Mixins with cURL Source: https://developers.fibery.com/guides/http-api/databases This cURL command demonstrates how to create a new database with specified fields and install the rank mixin. Replace 'YOUR_ACCOUNT' and 'YOUR_TOKEN' with your actual account details and API token. ```curl curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \ -H "Authorization: Token YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d @- << EOF { "command": "fibery.schema/batch", "args": { "commands": [ { "command": "schema.type/create", "args": { "fibery/name": "Cricket/Player", "fibery/meta": { "fibery/domain?": true, "fibery/secured?": true, "ui/color": "#F7D130" }, "fibery/fields": [ { "fibery/name": "Cricket/name", "fibery/type": "fibery/text", "fibery/meta": { "fibery/secured?": false, "ui/title?": true } }, { "fibery/name": "fibery/id", "fibery/type": "fibery/uuid", "fibery/meta": { "fibery/secured?": false, "fibery/id?": true, "fibery/readonly?": true } }, { "fibery/name": "fibery/public-id", "fibery/type": "fibery/text", "fibery/meta": { "fibery/secured?": false, "fibery/public-id?": true, "fibery/readonly?": true } }, { "fibery/name": "fibery/creation-date", "fibery/type": "fibery/date-time", "fibery/meta": { "fibery/secured?": false, "fibery/creation-date?": true, "fibery/readonly?": true, "fibery/default-value": "$now" } }, { "fibery/name": "fibery/modification-date", "fibery/type": "fibery/date-time", "fibery/meta": { "fibery/modification-date?": true, "fibery/required?": true, "fibery/readonly?": true, "fibery/default-value": "$now", "fibery/secured?": false } }, { "fibery/name": "user/salary", "fibery/type": "fibery/int", "fibery/meta": { "fibery/secured?": true } } ] } }, { "command": "fibery.app/install-mixins", "args": { "types": { "Cricket/Player": ["fibery/rank-mixin"] } } } ] } } EOF ``` -------------------------------- ### Create Database Example Source: https://developers.fibery.com/guides/http-api/databases Demonstrates how to create a new database with specified parameters. Ensure the 'fibery/name' parameter is correctly formatted. ```javascript const result = await fibery.databases.create({ "fibery/name": "CRM/Lead", "fibery/id": "fd5d9550-3779-427c-8745-ff427a723777", "meta/fibery/domain?": true, "meta/fibery/secured?": true, "meta/ui/color?": "#F7D130", "meta/fibery/fields": [ { "fibery/name": "Name", "fibery/type": "Text", "fibery/is-required": true }, { "fibery/name": "Email", "fibery/type": "Email" }, { "fibery/name": "Phone", "fibery/type": "Phone" }, { "fibery/name": "Company", "fibery/type": "Relation", "fibery/relation-database": "CRM/Company" }, { "fibery/name": "Status", "fibery/type": "Select", "fibery/select-options": [ "New", "Contacted", "Qualified", "Disqualified" ] } ] }); console.log(result); ``` -------------------------------- ### Install Mixins for Database Entities Source: https://developers.fibery.com/guides/http-api/databases Installs mixins to enable prioritization of database entities. ```javascript fibery.app/install-mixins ``` -------------------------------- ### Rename Database Example Source: https://developers.fibery.com/guides/http-api/databases Shows how to rename an existing database. This operation requires the current name and the new name for the database. ```javascript const result = await fibery.databases.rename({ "fibery/name": "CRM/Lead", "fibery/new-name": "CRM/Prospect" }); console.log(result); ``` -------------------------------- ### Example API Request Source: https://developers.fibery.com/guides/http-api/databases This snippet shows an example of how to make a POST request to the Fibery API to retrieve data. It includes the endpoint, headers, and a sample request body. ```APIDOC ## POST https://YOUR_ACCOUNT.fibery.io/api/commands ### Description This endpoint is used to execute commands within the Fibery system, such as retrieving data. ### Method POST ### Endpoint https://YOUR_ACCOUNT.fibery.io/api/commands ### Parameters #### Headers - **Authorization** (string) - Required - Your API token. - **Content-Type** (string) - Required - Set to 'application/json'. #### Request Body - **command** (string) - Required - The command to execute. Example: `"query"`. - **data** (object) - Required - The data payload for the command. ### Request Example ```json { "command": "query", "data": { "model": "llmstxt/fibery_llms-full_txt", "query": "" } } ``` ### Response #### Success Response (200) - **data** (object) - The result of the command execution. #### Response Example ```json { "data": { "result": "[Your query result here]" } } ``` ``` -------------------------------- ### Example Database Creation Response Source: https://developers.fibery.com/guides/http-api/databases This snippet shows a successful response when creating a database. It confirms the creation and provides details about the new database. ```json { "data": { "id": "25:1", "name": "Cricket", "description": null, "icon": null, "color": null, "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z", "creator": { "id": "1:user", "display_name": "John Doe" }, "entity_count": 0 }, "warnings": [] } ``` -------------------------------- ### Database Metadata Example Source: https://developers.fibery.com/guides/http-api/databases Retrieves metadata for a database, including UI color and field information. This is useful for understanding database configurations. ```javascript _jsxs(_components.tr, { children: [_jsxs(_components.td, { children: ["meta.", _jsx(_components.code, { children: "ui/color?" })] }), _jsx(_components.td, { "data-numeric": "true", children: "#000000" }), _jsx(_components.td, { children: "HEX color to use in Entity badges" }), _jsx(_components.td, { "data-numeric": "true", children: "#F7D130" })] }), _jsxs(_components.tr, { children: [_jsxs(_components.td, { children: ["meta.", _jsx(_components.strong, { children: _jsx(_components.code, { children: "fibery/fields" }) })] }), _jsx(_components.td, {}), _jsxs(_components.td, { children: ["Array of ", _jsx(_components.a, { href: "/guides/http-api/fields", children: "Fields" }), " including 5 primitive ones above"] }), _jsx(_components.td, {})] })] }) ``` -------------------------------- ### Rename Database Example Source: https://developers.fibery.com/guides/http-api/databases Use this command to rename a database. Ensure 'from-name' and 'to-name' parameters are correctly formatted with the space and database name. ```javascript const response = await fetch("https://YOUR_ACCOUNT.fibery.io/api/commands", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ "command": "rename-db", "from-name": "Cricket/Referee", "to-name": "Cricket/Umpire", }), }); const result = await response.json(); console.log(result); ``` -------------------------------- ### Get database details Source: https://developers.fibery.com/guides/http-api/databases Fetch detailed information about a specific database, including its name, description, and fields. ```javascript const fibery = require("fibery"); fibery.databases.get("my-database"); ``` -------------------------------- ### Create Database Example Source: https://developers.fibery.com/guides/http-api/databases Illustrates how to create a new database with a specified name and space using the Fibery API. The database name should follow the format 'space/name'. ```javascript const response = await fetch("https://YOUR_ACCOUNT.fibery.io/api/commands", { method: "POST", headers: { "Authorization": "Token YOUR_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ command: "create-database", space: "YOUR_SPACE", name: "YOUR_DATABASE_NAME" }) }); const result = await response.json(); console.log(result); ``` -------------------------------- ### Get Schema with Description Source: https://developers.fibery.com/guides/http-api/schema Fetches the Fibery schema, including database descriptions. This is useful for understanding the structure of your workspace. ```javascript const response = await fetch("https://YOUR_ACCOUNT.fibery.io/api/commands", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ name: "get-schema", arguments: { "with-description?": true, }, }), }); const data = await response.json(); ``` -------------------------------- ### Fetch entities with cURL Source: https://developers.fibery.com/guides/http-api/databases Demonstrates fetching entities using cURL. This example shows a POST request to retrieve entities, which can be useful for filtering or specific queries. ```shell curl -X POST \ "/api/v1/databases/users/entities" \ -H "Content-Type: application/json" \ -d '{ "Name": "John Doe", "Email": "john.doe@example.com" }' ``` -------------------------------- ### Install Mixins for Database Entities Source: https://developers.fibery.com/guides/http-api/databases Execute the 'fibery/install-mixins' command to enable prioritization of database entities. This is crucial for managing and organizing data within your database. ```javascript const response = await fetch("https://YOUR_ACCOUNT.fibery.io/api/commands", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "token YOUR_API_TOKEN" }, body: JSON.stringify({ "command": "fibery/install-mixins", "space": "YOUR_SPACE", "mixins": ["fibery/rank"], "types": ["My Database"] }) }); const result = await response.json(); ``` -------------------------------- ### Create Database Entity Source: https://developers.fibery.com/guides/http-api/databases Example of creating a new entity in a Fibery database. This snippet demonstrates the structure for defining entity fields and their types. ```json { "fibery/name": "fibery/id", "fibery/type": "fibery/uuid", "fibery/meta": { "fibery/secured?": false, "fibery/id?": true, "fibery/readonly?": true } } ``` -------------------------------- ### Create a New Entity Source: https://developers.fibery.com/guides/http-api/databases Example of creating a new entity within a Fibery database. Specify the entity type and the fields to populate. ```javascript const url = "https://YOUR_ACCOUNT.fibery.io/api/commands"; const token = "YOUR_TOKEN"; fetch(url, { method: 'POST', headers: { 'Authorization': 'Token YOUR_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'fibery.schema/batch', args: { "commands": [ { "type": "create-entity", "entity": [ "Document", [ [ "Name", "My New Document" ] ] ] } ] } }) }).then(response => response.json()).then(data => console.log(data)); ``` -------------------------------- ### Fetch Data from a Database Source: https://developers.fibery.com/guides/http-api/databases Example of fetching data from a Fibery database using the HTTP API. Requires your account URL and a valid token. ```javascript const url = "https://YOUR_ACCOUNT.fibery.io/api/query"; const token = "YOUR_TOKEN"; fetch(url, { method: 'POST', headers: { 'Authorization': `Token ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "query": "{ allDocuments { id name } }" }) }).then(response => response.json()).then(data => console.log(data)); ``` -------------------------------- ### API Request with Token Authentication Source: https://developers.fibery.com/guides/getting-started/authentication Example of an API request using an API token for authentication. Ensure you replace 'YOUR_TOKEN' with your actual token. ```javascript const token = "YOUR_TOKEN"; fetch("https://api.fibery.com/graphql", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ command: 'fibery.entity/query', args: { query: { 'q/from': 'fibery/user', 'q/select': ['fibery/id', 'user/name'], 'q/where': { 'fibery/id': 1 } } } }) }); ``` -------------------------------- ### Database Field Types Example Source: https://developers.fibery.com/guides/http-api/databases Illustrates various field types within a Fibery database schema, including security, naming, and date/time fields. ```javascript "fibery/secured?": false, "fibery/public-id?": true, "fibery/readonly?": true, "fibery/name": "fibery/creation-date", "fibery/type": "fibery/date-time", "fibery/meta": { "fibery/secured?": false } ``` -------------------------------- ### Delete Database Example Source: https://developers.fibery.com/guides/http-api/databases Demonstrates how to delete a database using the Fibery HTTP API. Ensure you have the correct account, token, and database name. ```javascript const response = await fetch("https://YOUR_ACCOUNT.fibery.io/api/commands", { method: "POST", headers: { "Authorization": "Token YOUR_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ command: "delete-database", space: "YOUR_SPACE", name: "YOUR_DATABASE_NAME" }) }); const result = await response.json(); console.log(result); ``` -------------------------------- ### Example Entity Structure Source: https://developers.fibery.com/guides/http-api/databases Illustrates the structure of an entity within a Fibery database, including common fields like name, type, and meta information. ```json { "fibery/name": "Cricket/name", "fibery/type": "fibery/text", "fibery/meta": { "fibery/secured?": false, "ui/title?": true } }, { "fibery/name": "fibery/id", "fibery/type": "fibery/text" } ``` -------------------------------- ### Define Database Fields Source: https://developers.fibery.com/guides/http-api/databases Example of defining fields for a Fibery database, including creation date, read-only status, default values, and meta-information. ```javascript _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/creation-date?'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#569CD6" }, children: " true" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/readonly?'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#569CD6" }, children: " true" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/default-value'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " '$now'" })] }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " }" }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " }," }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " {" }) }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/name'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/modification-date'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/type'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/date-time'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/meta'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " {" }) }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " 'fibery/modification-date?'" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#9CDCFE" }, children: ":" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#569CD6" }, children: " true" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "," })] }), "\n"] }) ``` -------------------------------- ### Define Creation and Modification Date Fields Source: https://developers.fibery.com/guides/http-api/databases Example of defining 'creation-date' and 'modification-date' fields with specific properties like type, meta, and read-only status. ```json { "fibery/name": "fibery/creation-date", "fibery/type": "fibery/date-time", "fibery/meta": {}, "fibery/secured?": false, "fibery/creation-date?": true, "fibery/readonly?": true, "fibery/default-value": "$now" } }, { "fibery/name": "fibery/modification-date", "fibery/type": "fibery/date-time", "fibery/meta": {}, "fibery/modification-date?": true, "fibery/required?": true, "fibery/readonly?": true, "fibery/default-value": "$now", "fibery/secured?": false } } ``` -------------------------------- ### Define Database Schema Source: https://developers.fibery.com/guides/http-api/databases Example of defining a database schema with various field types and metadata. Use this to structure your data within Fibery. ```json { "fibery/name": "user/salary", "fibery/type": "fibery/int", "fibery/meta": { "fibery/secured?": false } }, { "fibery/name": "user/salary", "fibery/type": "fibery/int", "fibery/meta": { "fibery/secured?": true } } ``` -------------------------------- ### Database schema example Source: https://developers.fibery.com/guides/http-api/databases This snippet shows a JSON representation of a database schema, including field definitions like 'fibery/uuid', 'fibery/meta', 'fibery/name', 'fibery/public-id', and 'fibery/type'. ```json { "fibery/uuid": "some-uuid", "fibery/meta": { "fibery/id?": false, "fibery/readonly?": true }, "fibery/name": "fibery/public-id", "fibery/type": "fibery/text" } ``` -------------------------------- ### Create a new database entity Source: https://developers.fibery.com/guides/http-api/databases Example of creating a new entity in a Fibery database. This snippet defines the structure and values for a new record. ```json { "fibery/name": "fibery/modification-date", "fibery/type": "fibery/date-time", "fibery/meta": { "fibery/modification-date?": true, "fibery/required?": true, "fibery/readonly?": true, "fibery/default-value": "$now", "fibery/secured?": false } } ``` -------------------------------- ### Fibery API Query Example Source: https://developers.fibery.com/guides/getting-started/authentication This snippet demonstrates how to construct a query to retrieve user data from Fibery. Ensure your account name and token are correctly substituted. ```javascript children: " \"args\": {\n }\n }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"query\": {\n }\n }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"q/from\": \"fibery/user\"," }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"q/select\": [\"fibery/id\", \"user/name\"]," }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"q/where\": [\"=\", [\"fibery/id\"], \"$my-id\"]," }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " \"q/limit\": 1" }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " }" }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " }" }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: " }'" }) }), "\n" ] }) }) }) ``` -------------------------------- ### JSON Response Example Source: https://developers.fibery.com/guides/http-api/databases This is an example of a successful JSON response from the Fibery API, indicating a 'success' status and a 'result'. ```json { "success": true, "result": "ok" } ``` -------------------------------- ### JSON Response Example Source: https://developers.fibery.com/guides/http-api/databases This is an example of a successful JSON response from the Fibery API, indicating the status of an operation and any returned data. ```json { "success": true, "result": "ok" } ``` -------------------------------- ### Fetch a single record by ID Source: https://developers.fibery.com/guides/http-api/databases To get a specific record, append its ID to the table name in the GET request URL. This is useful when you know the exact entity you need. ```javascript const url = new URL("/api/entities/users/123", "https://YOUR_ACCOUNT.fibery.io"); const response = await fetch(url, { method: "GET", headers: { Authorization: "Token YOUR_TOKEN", }, }); const user = await response.json(); ``` -------------------------------- ### Fibery Schema Definition Example Source: https://developers.fibery.com/guides/http-api/schema Example of a Fibery schema definition, showcasing various field types and configurations like meta, primitive, domain, UI color, and mixins. ```json { "fibery/meta": { "children": " //...other Fields" } }, "fibery/primitive?": false, "fibery/domain?": true, "ui/color": "#068cba", "app/mixins": { "fibery/rank-mixin": true, "assignments/assignments-mixin": true, "Files/Files-mixin": true } } ``` -------------------------------- ### Execute a Command with Arguments Source: https://developers.fibery.com/guides/http-api/databases Demonstrates how to execute a Fibery command, such as 'fibery.schema/batch', with specific arguments. Ensure correct command and argument structure. ```javascript const url = "https://YOUR_ACCOUNT.fibery.io/api/commands"; const token = "YOUR_TOKEN"; fetch(url, { method: 'POST', headers: { 'Authorization': 'Token YOUR_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'fibery.schema/batch', args: { "commands": [ { "type": "update-entity", "entity": [ "Document", "a1b2c3d4-e5f6-7890-1234-567890abcdef", [ [ "Name", "New Document Name" ] ] ] } ] } }) }).then(response => response.json()).then(data => console.log(data)); ``` -------------------------------- ### Rename Type Example Source: https://developers.fibery.com/guides/http-api/databases This example demonstrates how to rename a type within Fibery using the API. It utilizes a POST request to the /api/commands endpoint with a JSON payload specifying the command and arguments. ```APIDOC ## POST /api/commands ### Description Executes a batch of commands against the Fibery API. This example shows how to rename a type. ### Method POST ### Endpoint https://YOUR_ACCOUNT.fibery.io/api/commands ### Parameters #### Headers - **Authorization** (string) - Required - Your API token. - **Content-Type** (string) - Required - application/json #### Request Body - **command** (string) - Required - The command to execute, e.g., "fibery.schema/batch". - **args** (object) - Required - Arguments for the batch command. - **commands** (array) - Required - An array of commands to execute. - **command** (string) - Required - The specific command, e.g., "schema.type/rename". - **args** (object) - Required - Arguments for the rename command. - **from-name** (string) - Required - The current name of the type. - **to-name** (string) - Required - The new name for the type. ### Request Example ```json { "command": "fibery.schema/batch", "args": { "commands": [ { "command": "schema.type/rename", "args": { "from-name": "Cricket/Referee", "to-name": "NewCricketRefereeName" } } ] } } ``` ### Response #### Success Response (200) (Response structure not detailed in source, but typically includes status and results of commands) #### Response Example (Response example not detailed in source) ``` -------------------------------- ### Create a Database with Mandatory Fields Source: https://developers.fibery.com/guides/http-api/databases Use the 'schema.type/create' command to create a new database with essential primitive fields. Ensure the Space exists before execution. ```javascript const response = await fetch("https://YOUR_ACCOUNT.fibery.io/api/commands", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "token YOUR_API_TOKEN" }, body: JSON.stringify({ "command": "schema.type/create", "space": "YOUR_SPACE", "name": "My Database", "fields": [ {"name": "fibery/id", "type": "fibery/id"}, {"name": "fibery/public-id", "type": "fibery/public-id"}, {"name": "fibery/creation-date", "type": "fibery/creation-date"}, {"name": "fibery/modification-date", "type": "fibery/modification-date"}, {"name": "My Field", "type": "text"} ] }) }); const result = await response.json(); ``` -------------------------------- ### Fibery Schema Query Response Source: https://developers.fibery.com/guides/http-api/schema Example JSON response when successfully querying the Fibery API schema. ```json { "success": true, "result": {"fibery/id": ``` -------------------------------- ### Example Schema Definition Source: https://developers.fibery.com/guides/http-api/schema This snippet shows a basic schema definition with several properties and mixins. It demonstrates how to define fields like 'fibery/domain', 'ui/color', and various mixins such as 'fibery/rank-mixin'. ```json { "fibery/domain": true, "ui/color": "#068cba", "app/mixins": { "fibery/rank-mixin": true, "assignments/assignments-mixin": true, "Files/Files-mixin": true, "workflow/workflow": true, "comments/comments-mixin": true } } ``` -------------------------------- ### Delete an Entity Source: https://developers.fibery.com/guides/http-api/databases Example for deleting an entity from a Fibery database. Requires the entity's type and unique ID. ```javascript const url = "https://YOUR_ACCOUNT.fibery.io/api/commands"; const token = "YOUR_TOKEN"; fetch(url, { method: 'POST', headers: { 'Authorization': 'Token YOUR_TOKEN', 'Content-Type': 'application/json' }, body: JSON.stringify({ command: 'fibery.schema/batch', args: { "commands": [ { "type": "delete-entity", "entity": [ "Document", "a1b2c3d4-e5f6-7890-1234-567890abcdef" ] } ] } }) }).then(response => response.json()).then(data => console.log(data)); ``` -------------------------------- ### Get database schema Source: https://developers.fibery.com/guides/http-api/databases Retrieve the schema definition for a specific database. This includes field names, types, and configurations. ```javascript const fibery = require("fibery"); fibery.databases.get("my-database").schema(); ``` -------------------------------- ### Database Command Parameter Details Source: https://developers.fibery.com/guides/http-api/databases Provides detailed descriptions and examples for database command parameters. Explains how parameters like 'name', 'delete-entities?', and 'delete-related-fields?' affect database operations. ```markdown | Parameter (required in bold) | Default | Description | |---|---|---| | **name** | | Database name in `${space}/${name}` format | | delete-entities? | false | Delete all Entities of this Database? See the behavior in the table below. | | delete-related-fields? | false | Delete all related Fields like `Criket/Favourite Umpire` in `Cricket/Player`? See the behavior in the table below. | ``` -------------------------------- ### Define a Database Schema Source: https://developers.fibery.com/guides/http-api/databases Example of defining a database schema with various field types and configurations. This snippet shows how to set up fields like name, type, and meta-information. ```json { "fibery/name": "Cricket", "fibery/type": "fibery/table", "fibery/description": "Cricket database", "fibery/domain?": true, "fibery/secured?": true, "ui/color": "#F7D130" } ``` -------------------------------- ### JavaScript Fetch API Example Source: https://developers.fibery.com/guides/getting-started/authentication Demonstrates how to make a POST request to the Fibery API using the fetch API in JavaScript. This snippet shows how to construct the request body with specific parameters like 'fibery/id' and 'q/limit'. ```javascript const data = await response.json(); ``` -------------------------------- ### Batch Operations in Fibery API Source: https://developers.fibery.com/guides/http-api/databases Execute multiple commands in a single API request for efficiency. This example demonstrates renaming a type. ```javascript body: JSON.stringify({ command: 'fibery.schema/batch', args: { commands: [ { command: 'schema.type/rename', args: { 'from-name': 'Cricket/Referee', 'to-name': 'Cricket/Umpire' } } ] } }) ``` -------------------------------- ### List all databases Source: https://developers.fibery.com/guides/http-api/databases Fetch a list of all databases accessible to your account. This is useful for discovering available databases and their IDs. ```javascript const fibery = require("fibery"); const client = new fibery.Client({ token: "YOUR_TOKEN", }); client.databases.list().then((databases) => { databases.forEach((db) => { console.log(db.name); }); }); ``` -------------------------------- ### Database Permissions Matrix Source: https://developers.fibery.com/guides/http-api/databases Illustrates how permissions apply based on the 'secured?' parameter for different fields. ```markdown Project: /llmstxt/fibery_llms-full_txt Content: Here’s how permissions apply depending on \", \jsx(_components.code, { children: \"secured?\" }), \" parameter:\"\ }), \"\\n\", _jsxs(\"table\", {\n class: \"matrix-table\",\n children: [ _jsxs(\"thead\", {\n children: [ _jsxs(\"tr\", {\n children: [ _jsx(\"th\", {}), _jsx(\"th\", {}), _jsx(\"th\", {\n colSpan: 2,\n children: _jsxs(_components.strong, {\n children: [ \"Task \", _jsx(_components.code, {\n children: \"secured?\"\n }) ]\n })\n }) ]\n }), _jsxs(\"tr\", {\n children: [ _jsx(\"th\", {}), _jsx(\"th\", {}), _jsx(\"th\", {\n align: \"center\",\n children: \"❌\"\n }), _jsx(\"th\", {\n align: \"center\",\n children: \"✅\"\n }) ]\n }) ]\n }), _jsxs(\"tbody\", {\n children: [ _jsxs(\"tr\", {\n children: [ _jsx(\"th\", {\n rowSpan: 2,\n children: _jsxs(_components.strong, {\n children: [ \"Effort \", _jsx(_components.code, {\n children: \"secured?\"\n }) ]\n })\n }), _jsx(\"td\", {\n align: \"center\",\n children: \"❌\"\n }), _jsx(\"td\", {\n children: \"Everyone has access to all fields\"\n }), _jsxs(\"td\", {\n children: [ \"Everyone has access to Effort, but not to other \", _jsx(_components.code, {\n children: \"secured?\"\n }), \" fields\" ]\n }) ]\n }), _jsxs(\"tr\", {\n children: [ _jsx(\"td\", {\n align: \"center\",\n children: \"✅\"\n }), _jsx(\"td\", {\n children: \"Everyone has access to all fields\"\n }), _jsx(\"td\", {\n children: \"Everyone has access to Task’s non-secured Fields like Id, but permissions are applied to Effort\"\n }) ]\n }) ]\n }) ]\n }), \"\\n\" ] }) ``` -------------------------------- ### Database Field Metadata Example Source: https://developers.fibery.com/guides/http-api/databases This snippet shows the metadata associated with a database field, including its type, name, and security properties. ```clojure { "fibery/readonly?": true, "fibery/name": "fibery/public-id", "fibery/type": "fibery/text", "fibery/meta": { "fibery/secured?": false, "fibery/public-id?": true, "fibery/readonly?": true } } ```