Dowell DataCube API Documentation Template {% load tz from django.utils.timezone %} Dowell DataCube API Docs

Dowell DataCube API

Manage your databases, collections & documents – all via REST.

Health Check πŸ”—

Verify that the API server is up and responding.

GET /health_check/
cURL
Python
JavaScript
curl -X GET
  "/health_check/}" \
  -H "Content-Type: application/json"

Response Example

{
    "success": true,
    "message": "Server is up"
}

Create Database πŸ”—

Create a new logical database and its initial collections/fields.

POST /api/create_database/

Request Body

{
    "db_name": "new_database",
    "collections": [
        {
            "name": "users",
            "fields": [
                {"name": "username", "type": "string"},
                {"name": "age", "type": "number"}
            ]
        }
    ]
}
cURL
Python
JavaScript
curl -X POST
  "/api/create_database/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022db_name\u0022: \u0022new_database\u0022,\u000A    \u0022collections\u0022: [\u000A        {\u000A            \u0022name\u0022: \u0022users\u0022,\u000A            \u0022fields\u0022: [\u000A                {\u0022name\u0022: \u0022username\u0022, \u0022type\u0022: \u0022string\u0022},\u000A                {\u0022name\u0022: \u0022age\u0022, \u0022type\u0022: \u0022number\u0022}\u000A            ]\u000A        }\u000A    ]\u000A}\u000A'

Response Example

{
    "success": true,
    "message": "Database 'new_database' and collections created successfully.",
    "database": {
        "id": "507f1f77bcf86cd799439011",
        "name": "new_database"
    },
    "collections": [
        {
            "name": "users",
            "id": "607e1c72e13c2a3f4a9b1234",
            "fields": [
                {"name": "username", "type": "string"},
                {"name": "age", "type": "number"}
            ]
        }
    ]
}

Add Collections πŸ”—

Add new collections (with field definitions) to an existing database.

POST /api/add_collection/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "collections": [
        {
            "name": "orders",
            "fields": [
                {"name": "order_id", "type": "string"},
                {"name": "total", "type": "number"}
            ]
        }
    ]
}
cURL
Python
JavaScript
curl -X POST
  "/api/add_collection/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022collections\u0022: [\u000A        {\u000A            \u0022name\u0022: \u0022orders\u0022,\u000A            \u0022fields\u0022: [\u000A                {\u0022name\u0022: \u0022order_id\u0022, \u0022type\u0022: \u0022string\u0022},\u000A                {\u0022name\u0022: \u0022total\u0022, \u0022type\u0022: \u0022number\u0022}\u000A            ]\u000A        }\u000A    ]\u000A}\u000A'

Response Example

{
    "success": true,
    "message": "Collections 'orders' created successfully.",
    "collections": [
        {
            "name": "orders",
            "id": "607e1e33a1b2c4d5e6f78901",
            "fields": [
                {"name": "order_id", "type": "string"},
                {"name": "total", "type": "number"}
            ]
        }
    ],
    "database": {
        "total_collections": 2,
        "total_fields": 4
    }
}

List Databases πŸ”—

Page through all databases with optional Mongo-style filter and collection count.

POST /api/list_databases/

Request Body

{
    "page": 1,
    "page_size": 10,
    "filter": {
        "number_of_collections": { "$gte": 2 },
        "database_name": { "$regex": "^prod_" }
    }
}
cURL
Python
JavaScript
curl -X POST
  "/api/list_databases/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022page\u0022: 1,\u000A    \u0022page_size\u0022: 10,\u000A    \u0022filter\u0022: {\u000A        \u0022number_of_collections\u0022: { \u0022$gte\u0022: 2 },\u000A        \u0022database_name\u0022: { \u0022$regex\u0022: \u0022^prod_\u0022 }\u000A    }\u000A}\u000A'

Response Example

{
    "success": true,
    "data": [
        {"id": "507f1f77bcf86cd799439011", "database_name": "prod_users", "num_collections": 5},
        {"id": "507f1f77bcf86cd799439012", "database_name": "prod_orders", "num_collections": 3}
    ],
    "pagination": {
        "page": 1,
        "page_size": 10,
        "total": 2,
        "total_pages": 1
    }
}

List Collections πŸ”—

Retrieve all collections in a database with document counts.

GET /api/list_collections/ ? database_id=507f1f77bcf86cd799439011

Request Parameters

{'database_id': '507f1f77bcf86cd799439011'}
cURL
Python
JavaScript
curl -X GET
  "/api/list_collections/?database_id=507f1f77bcf86cd799439011}" \
  -H "Content-Type: application/json"

Response Example

{
    "success": true,
    "collections": [
        {"name": "users", "num_documents": 42},
        {"name": "orders", "num_documents": 128}
    ]
}

Get Database Metadata πŸ”—

Fetch metadata for a database including collections and fields.

GET /api/get_metadata/ ? database_id=507f1f77bcf86cd799439011

Request Parameters

{'database_id': '507f1f77bcf86cd799439011'}
cURL
Python
JavaScript
curl -X GET
  "/api/get_metadata/?database_id=507f1f77bcf86cd799439011}" \
  -H "Content-Type: application/json"

Response Example

{
    "success": true,
    "data": {
        "_id": "507f1f77bcf86cd799439011",
        "database_name": "example_db",
        "number_of_collections": 2,
        "number_of_fields": 5,
        "collections": [
            {
                "name": "users",
                "fields": [
                    {"name": "username", "type": "string"},
                    {"name": "email", "type": "string"}
                ]
            },
            {
                "name": "orders",
                "fields": [
                    {"name": "order_id", "type": "string"},
                    {"name": "total", "type": "number"}
                ]
            }
        ]
    }
}

Drop Database πŸ”—

Delete a database and all collections after confirmation.

DELETE /api/drop_database/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "confirmation": "example_db"
}
cURL
Python
JavaScript
curl -X DELETE
  "/api/drop_database/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022confirmation\u0022: \u0022example_db\u0022\u000A}\u000A'

Response Example

{
    "success": true,
    "message": "Database 'example_db' and its metadata dropped successfully"
}

Drop Collections πŸ”—

Remove one or more collections from a database.

DELETE /api/drop_collections/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "collection_names": ["users", "orders"]
}
cURL
Python
JavaScript
curl -X DELETE
  "/api/drop_collections/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022collection_names\u0022: [\u0022users\u0022, \u0022orders\u0022]\u000A}\u000A'

Response Example

{
    "success": true,
    "dropped_collections": ["users", "orders"],
    "failed_collections": []
}

CRUD Documents πŸ”—

Create, read, update, and delete documents in a collection.

POST /api/crud/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "collection_name": "users",
    "data": [
        {"username": "alice", "age": 28},
        {"username": "bob", "age": 34}
    ]
}
cURL
Python
JavaScript
curl -X POST
  "/api/crud/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022collection_name\u0022: \u0022users\u0022,\u000A    \u0022data\u0022: [\u000A        {\u0022username\u0022: \u0022alice\u0022, \u0022age\u0022: 28},\u000A        {\u0022username\u0022: \u0022bob\u0022, \u0022age\u0022: 34}\u000A    ]\u000A}\u000A'

Response Example

{
    "success": true,
    "inserted_ids": ["60c72b2f9b1d8b1a2d3e4567", "60c72b2f9b1d8b1a2d3e4568"]
}
GET /api/crud/ ? database_id=507f1f77bcf86cd799439011 & collection_name=users & filters={"age": {"$gt": 30}} & page=1 & page_size=50

Request Parameters

{'database_id': '507f1f77bcf86cd799439011', 'collection_name': 'users', 'filters': '{"age": {"$gt": 30}}', 'page': '1', 'page_size': '50'}
cURL
Python
JavaScript
curl -X GET
  "/api/crud/?database_id=507f1f77bcf86cd799439011&collection_name=users&filters={"age": {"$gt": 30}}&page=1&page_size=50}" \
  -H "Content-Type: application/json"

Response Example

{
    "success": true,
    "data": [
        {"_id": "60c72b2f9b1d8b1a2d3e4568", "username": "bob", "age": 34}
    ],
    "pagination": {
        "page": 1,
        "page_size": 50,
        "total": 1,
        "total_pages": 1
    }
}
PUT /api/crud/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "collection_name": "users",
    "filters": {"username": "alice"},
    "update_data": {"age": 29}
}
cURL
Python
JavaScript
curl -X PUT
  "/api/crud/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022collection_name\u0022: \u0022users\u0022,\u000A    \u0022filters\u0022: {\u0022username\u0022: \u0022alice\u0022},\u000A    \u0022update_data\u0022: {\u0022age\u0022: 29}\u000A}\u000A'

Response Example

{
    "success": true,
    "modified_count": 1
}
DELETE /api/crud/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "collection_name": "users",
    "filters": {"age": {"$lt": 20}},
    "soft_delete": false
}
cURL
Python
JavaScript
curl -X DELETE
  "/api/crud/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022collection_name\u0022: \u0022users\u0022,\u000A    \u0022filters\u0022: {\u0022age\u0022: {\u0022$lt\u0022: 20}},\u000A    \u0022soft_delete\u0022: false\u000A}\u000A'

Response Example

{
    "success": true,
    "count": 2
}

Import JSON Data πŸ”—

Bulk import JSON via file or raw payload. Auto-creates collection if needed.

POST /api/import_data/

Request Body

{
    "database_id": "507f1f77bcf86cd799439011",
    "collection_name": "events",  # optional
    "json_file": 
}
cURL
Python
JavaScript
curl -X POST
  "/api/import_data/}" \
  -H "Content-Type: application/json" \
  -d '\u000A{\u000A    \u0022database_id\u0022: \u0022507f1f77bcf86cd799439011\u0022,\u000A    \u0022collection_name\u0022: \u0022events\u0022,  # optional\u000A    \u0022json_file\u0022: \u003Cuploaded JSON file\u003E\u000A}\u000A'

Response Example

{
    "success": true,
    "collection": "events",
    "inserted_count": 125
}