Skip to main content

Basic Operations

Configuration

You can configure your ekoDB instance via the /api/config endpoint. This endpoint supports PUT requests and allows you to update the configuration of use_typed_values and soon more configurations.

PUT https://{EKODB_API_URL}/api/config
Content-Type: application/json
Authorization: Bearer {YOUR_TOKEN}

{
"use_typed_values": true, // true by default
}

Typed Values

By default, ekoDB returns values as typed values: {"value_name": {"type": "string", "value": "value"}}.

Example of typed values:

{
"name": {"type": "String", "value": "John Doe"},
"age": {"type": "Integer", "value": 30},
"email": {"type": "String", "value": "john@example.com"},
"phone": {"type": "String", "value": "012-123-4567"},
"address": {
"street_number": {"type": "Integer", "value": 123},
"street": {"type": "String", "value": "Main St"},
"city": {"type": "String", "value": "City"},
"state": {"type": "String", "value": "State"},
"zip": {"type": "Integer", "value": 12345},
"longitude": {"type": "Float", "value": -122.4194},
"latitude": {"type": "Float", "value": 47.6062}
},
"is_active": {"type": "Boolean", "value": true},
"keywords": {"type": "Array", "value": ["keyword1", "keyword2"]},
"created_at": {"type": "DateTime", "value": "2023-01-01T00:00:00Z"}
}

You can disable typed values in the configuration to have ekoDB return values as the key-value pairing.

  • Note: Typed values are enabled by default but the rest of this documentation will assume that you are using non-typed values for simplicity sake.

Example of non-typed values:

{
"name": "John Doe",
"age": 30,
"email": "john@example.com",
"phone": "012-123-4567",
"address": {
"street_number": 123,
"street": "Main St",
"city": "City",
"state": "State",
"zip": 12345,
"longitude": -122.4194,
"latitude": 47.6062
},
"is_active": true,
"keywords": ["keyword1", "keyword2"],
"created_at": "2023-01-01T00:00:00Z"
}

Available Typed Values:

  • "String"
  • "Integer"
  • "Float"
  • "Number" (alias for Integer and Float, use Integer or Float for better performance)
  • "Boolean"
  • "Object"
  • "Array"
  • "Binary"
  • "Bytes"
  • "DateTime" (RFC3339 string)
  • "Null"

Records or key-value pairs

Storing data using as records or key-value pairs is similar to using any NoSQL database or key-value store. Collections of records or documents are similar to tables with rows like a SQL database. Every insert returns a generated id that you can use to fetch, update, or delete the record or document. If you would rather use in-memory key-value pairs, you can use the key-value pairs endpoint instead, where you can leverage your own keys to store and retrieve data. You can also link records or documents to each other using relationships via storing the id of the other record or document in the current record or document. You can also link records or documents to key-value pairs and commit the changes to the database.

Insert Record

Insert a single record into a collection:

POST https://{EKODB_API_URL}/api/insert/{collection}
Content-Type: application/json
Authorization: Bearer {YOUR_TOKEN}

{
"name": "John Doe", // String
"age": 30, // Integer
"email": "john@example.com", // String
"phone": "012-123-4567", // String
"address": {
"street_number": 123, // Integer
"street": "Main St", // String
"city": "City", // String
"state": "State", // String
"zip": 12345, // Integer
"longitude": -122.4194, // Float
"latitude": 47.6062 // Float
}, // Object
"is_active": true, // Boolean
"keywords": ["keyword1", "keyword2"], // Array
"created_at": "2023-01-01T00:00:00Z" // DateTime RFC3339
}

# Response
{
"id": "{ID}"
}

Read Record

Retrieve a record by its ID:

GET https://{EKODB_API_URL}/api/find/{collection}/{id}
Content-Type: application/json
Authorization: Bearer {YOUR_TOKEN}

# Response
{
"id": "{ID}",
"name": "John Doe",
"age": 30,
"email": "john@example.com",
"phone": "012-123-4567",
"address": {
"street_number": 123,
"street": "Main St",
"city": "City",
"state": "State",
"zip": 12345,
"longitude": -122.4194,
"latitude": 47.6062
},
"is_active": true,
"keywords": ["keyword1", "keyword2"],
"created_at": "2023-01-01T00:00:00Z"
}

Query Records

Retrieve multiple records by query:

POST https://{EKODB_API_URL}/api/find/{collection}
Content-Type: application/json
Authorization: Bearer {YOUR_TOKEN}

{
"filter": {
// Condition
"type": "Condition",
"content": {
"field": "phone",
"operator": "Eq",
"value": "012-123-4567"
}

// Logical Or
"type": "Logical",
"content": {
"operator": "Or",
"expressions": [
{
"type": "Condition",
"content": {
"field": "phone",
"operator": "Eq",
"value": "012-123-4567"
}
},
{
"type": "Condition",
"content": {
"field": "email",
"operator": "Eq",
"value": "john@example.com"
}
}
]
}

// Logical And
"type": "Logical",
"content": {
"operator": "And",
"expressions": [
{
"type": "Condition",
"content": {
"field": "phone.value",
"operator": "Eq",
"value": "012-123-4567"
}
},
{
"type": "Condition",
"content": {
"field": "email",
"operator": "Eq",
"value": "john@example.com"
}
}
]
}

// List of operators
// Eq, Ne, Gt, Lt, Gte, Lte, In, NotIn, Contains, StartsWith, EndsWith
}
sort: { createdAt: "desc" || "asc" }, // Sort by createdAt in descending or ascending order
limit: 10, // Number of records to return
skip: 0 // Number of records to skip
}

# Response
[
{
"id": "xyz123abc",
"name": "John Doe",
"age": 30,
"email": "john@example.com",
"phone": "012-123-4567",
"address": {
"street_number": 123,
"street": "Main St",
"city": "City",
"state": "State",
"zip": 12345,
"longitude": -122.4194,
"latitude": 47.6062
},
"is_active": true,
"keywords": ["keyword1", "keyword2"],
"created_at": "2023-01-01T00:00:00Z"
},
// ...more
]

Update Record

Update an existing record by its ID:

PUT https://{EKODB_API_URL}/api/update/{collection}/{id}
Content-Type: application/json
Authorization: Bearer {YOUR_TOKEN}

{
"name": "Jane Doe",
"age": 31
}

# Response
{
"id": "{ID}"
}

Search Records

Search for records by search query options:

# Search supports both POST and GET
# - GET calls should be on the query parameters with the same data as POST
# - POST calls should be on the body with the same data as GET

# GET - Note: see body below for an explanation of each parameter
GET https://{EKODB_API_URL}/api/search/{collection}?query=search&language=english&case_sensitive=false&fuzzy=true&min_score=0.5&fields=source&weights=field_name:0-1&stemming=true&boost_exact=true&max_edit_distance=0&bypass_ripple=true
Authorization: Bearer {YOUR_TOKEN}

# POST
POST https://{EKODB_API_URL}/api/search/{collection}
Content-Type: application/json
Authorization: Bearer {YOUR_TOKEN}

{
"query": "your desired query",
"language": "english || arabic || danish || dutch || finnish || french || german || greek || hungarian || italian || norwegian || portuguese || romanian || russian || spanish || swedish || tamil || turkish",
"case_sensitive": false,
"fuzzy": true,
"min_score": 0.5,
"fields": "field1,field2,field3",
"weights": "field1:0-1,field2:0-1,field3:0-1", // as a float between 0 and 1
"stemming": true, // enable stemming - stemming is the process of reducing words to their base form (e.g. "running" -> "run")
"boost_exact": true, // boost exact matches
"max_edit_distance": 0, // maximum edit distance - maximum edit distance is the maximum number of edits (insertions, deletions, or substitutions) allowed between the query and the document
"bypass_ripple": true // bypass ripple - ripple is how you can pass data between nodes (e.g. from one node to another or to bypass nodes)
}

# Response
{
"results": [
{
"id": "123",
"name": "John Doe",
"age": 30
}
],
"total": 1,
"execution_time_ms": 0
}

Delete Record

Delete a record by its ID:

DELETE https://{EKODB_API_URL}/api/delete/{collection}/{id}
Authorization: Bearer {YOUR_TOKEN}