Quick Start

Quick Start

Welcome to CapybaraDB! The chillest AI-native database out there! This guide will help you get started quickly with our powerful API service. Whether you're inserting your first document or exploring advanced features, you'll find everything you need to Save Documents (No Need for Embedding!) in just a few simple steps.

Step 1: Install SDK

pip install capybaradb

Step 2: Sign Up

Start by signing up for CapybaraDB:

  1. Visit CapybaraDB Sign Up (opens in a new tab).
  2. After signing up, you'll be navigated to the developer console.

Step 3: Get the API Key and the Project ID

API Key

  1. In the sidebar, go to the API Key page.
  2. Click to create a new API key—you can optionally name the key.
  3. The key will only be displayed once. Store it securely.

Project ID

  1. Project ID can be found on the welcome page or collection page on the console.
  2. It's recommended to store project ID securely.

Setting the API Key and Project URL

For this quick start guide (non-production environment), directly assign your API key and project ID to variables:

CAPYBARA_API_KEY = "your_api_key"
CAPYBARA_PROJECT_ID = "your_project_id"
⚠️

Important: Only hardcode credentials for local development.

In production, use environment variables or secure server-side logic for API Key and Collection URL to prevent unauthorized access and keep information secure.

Step 4: Initialize SDK client

import { CapybaraDB, EmbText } from "capybaradb";
import dotenv from "dotenv";
 
const client = new CapybaraDB();
const db = client.db("your_db_name");
const collection = db.collection("your_collection_name");

Step 5: Save Documents (No Embedding Needed!)

Example: Insert a Document

# Define the document to be inserted
doc = {
    "name": "Alice",
    "age": "7",
    "background": EmbText("Through the Looking-Glass follows Alice as she steps into a fantastical world...")
}
 
# Make the POST request to insert the document
response = collection.insert(doc)
💡

EmbJSON - What Happens After Saving

When saving an EmbText data type, CapybaraDB performs additional processing:

  • The saved data will have an updated field called EmbText.chunks in addition to EmbText.text and EmbText.emb_model.
  • Each chunk is vectorized and indexed in the database, enabling efficient querying and similarity searches.

Step 6: Querying the Data

Query Request

Here's how to perform a query using Python:

query = "Alice in a fantastical world"
 
response = collection.query(query)

Example Response

Successful query response:

{
  "matches": [
    {
      "chunk": "Through the Looking-Glass follows Alice as she steps into a fantastical world...",
      "path": "background",
      "chunk_n": 0,
      "score": 0.703643203
      "document": {"_id": ObjectId("671bf91580bffb6387b4f3d2")},
    }
  ]
}

How can we improve this documentation?

Got question? Email us