Quickstart¶
This gets you from zero to a working query in 2 minutes. You only need Python and a Deep Lake API token.
Prerequisites¶
Get your API token from deeplake.ai under your workspace settings.
Setup¶
import requests
API_URL = "https://api.deeplake.ai"
TOKEN = "YOUR_TOKEN"
WORKSPACE = "YOUR_WORKSPACE"
headers = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json",
}
1. Check the connection¶
2. Create a table¶
Tables must be schema-qualified with your workspace name and use the USING deeplake engine:
TABLE = "my_first_table"
res = requests.post(
f"{API_URL}/workspaces/{WORKSPACE}/tables/query",
headers=headers,
json={
"query": f"""
CREATE TABLE IF NOT EXISTS "{WORKSPACE}"."{TABLE}" (
id SERIAL PRIMARY KEY,
title TEXT,
content TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
) USING deeplake
"""
},
)
print(res.status_code) # 200
3. Insert some rows¶
rows = [
("Getting started", "Deep Lake unifies tables, files, and search."),
("Vector search", "Use the <#> operator for similarity queries."),
("Hybrid search", "Combine BM25 and vector for best results."),
]
for title, content in rows:
requests.post(
f"{API_URL}/workspaces/{WORKSPACE}/tables/query",
headers=headers,
json={
"query": f"""
INSERT INTO "{WORKSPACE}"."{TABLE}" (title, content)
VALUES ('{title}', '{content}')
"""
},
)
Eventual consistency
After INSERT, data may take a few seconds to become visible in SELECT queries. This is normal behavior for Deep Lake tables.
4. Query your data¶
res = requests.post(
f"{API_URL}/workspaces/{WORKSPACE}/tables/query",
headers=headers,
json={"query": f'SELECT * FROM "{WORKSPACE}"."{TABLE}" ORDER BY id'},
)
print(res.json())
That's it. You have a table with data you can query with SQL.
What's next¶
- Core Concepts — understand Files, Tables, and Indexes
- Hello World example — slightly richer version with cleanup
- Tables fundamentals — all CRUD operations
- Search — vector, BM25, hybrid, and multi-vector search