Multi-Language
Multi-Language Setup

Quickstart & Setup Across Languages — OQENS SDK

Initialize OQENS in TypeScript, JavaScript, Python, Go, Rust, or cURL.

Choose your programming environment below to connect to your OQENS database project in seconds.

TypeScript & JavaScript

npm install @oqens/db
pnpm add @oqens/db
yarn add @oqens/db
bun add @oqens/db
index.ts
import { createClient } from '@oqens/db'

const db = createClient({
  apiKey: 'oq_live_xxxxxxxxxxxxxxxxxxxxxxxx',
  projectSlug: 'production-app'
})

const { rows, duration_ms } = await db.query('SELECT NOW() as server_time;')
console.log(`Connected in ${duration_ms}ms:`, rows[0])

Python

Works with native requests or httpx with zero specialized dependencies:

main.py
import requests

API_KEY = "oq_live_xxxxxxxxxxxxxxxxxxxxxxxx"
PROJECT_SLUG = "production-app"
BASE_URL = "https://db.echo.oqens.me"

res = requests.post(
    f"{BASE_URL}/api/dbaas/v2/projects/{PROJECT_SLUG}/query",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    },
    json={"query": "SELECT NOW() as server_time, version();"}
)

data = res.json()
print("Latency:", data["duration_ms"], "ms")
print("Data:", data["rows"])

cURL / Bash

Terminal
curl -X POST https://db.echo.oqens.me/api/dbaas/v2/projects/production-app/query \
  -H "Authorization: Bearer oq_live_xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{"query": "SELECT NOW() as server_time;"}'

Go

main.go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    url := "https://db.echo.oqens.me/api/dbaas/v2/projects/production-app/query"
    payload, _ := json.Marshal(map[string]string{"query": "SELECT NOW();"})
    
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
    req.Header.Set("Authorization", "Bearer oq_live_xxxxxxxxxxxxxxxxxxxxxxxx")
    req.Header.Set("Content-Type", "application/json")
    
    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()
    
    fmt.Println("Status:", resp.Status)
}

Rust

main.rs
use reqwest::header::{AUTHORIZATION, CONTENT_TYPE};
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    let res = client
        .post("https://db.echo.oqens.me/api/dbaas/v2/projects/production-app/query")
        .header(AUTHORIZATION, "Bearer oq_live_xxxxxxxxxxxxxxxxxxxxxxxx")
        .header(CONTENT_TYPE, "application/json")
        .json(&json!({ "query": "SELECT NOW();" }))
        .send()
        .await?;

    println!("Response: {:?}", res.text().await?);
    Ok(())
}
Copied