Developer Reference

NafijRahaman DB API & SDK Documentation

Base Endpoint URL:https://db.nafij.me/api/v1

1. Vercel Quick Setup

Add storage to any Vercel project in 2 minutes

  1. Log in to the NafijDB Dashboard and create a database project.
  2. Copy your generated project API key (e.g. nrdb_live_xxxxxxxxx).
  3. Add the environment variable in your Vercel Project Settings:
NAFIJ_DB_KEY=nrdb_live_xxxxxxxxxxxxxxxxxxxxxxxx

2. JavaScript / TypeScript SDK

Lightweight client for Next.js, Node.js, and Edge runtimes

Package Installation
npm install @nafij/db
SDK Usage Example
import { NafijDB } from "@nafij/db";

// Automatically uses process.env.NAFIJ_DB_KEY
const db = new NafijDB();

// --- 1. QUICK STORAGE ---
await db.quick.set("theme", "dark");
const theme = await db.quick.get("theme");
await db.quick.delete("theme");

// --- 2. COLLECTION API ---
const users = db.collection("users");

// Insert document
const user = await users.insert({
  name: "Nafij",
  email: "hello@example.com"
});

// Query documents
const result = await users.find({ limit: 50 });

// Find by ID
const doc = await users.findOne(user.id);

// Update document
await users.update(user.id, { name: "Nafij Rahaman" });

// Delete document
await users.delete(user.id);

3. Public Health & Info Endpoints

Public endpoints for status checking

GET/api/v1/info

Returns service version and platform status.

GET/api/v1/health

Pings MongoDB cluster and reports health status.

4. Quick Storage REST API

High-speed key-value JSON operations

GET/api/v1/quick/:key

Retrieve a stored JSON value by key name. Requires Authorization: Bearer <NAFIJ_DB_KEY>

PUT/api/v1/quick/:key

Store or overwrite a JSON value. Body: { "value": { ... } } or raw JSON object.

DELETE/api/v1/quick/:key

Deletes the key-value record from Quick Storage.

5. Collection & Document API

Full MongoDB document CRUD endpoints

GET/api/v1/data/:collection

Query documents. Supports query parameters: ?page=1&limit=50&sort=createdAt&order=desc

POST/api/v1/data/:collection

Insert a new document into the specified collection.

PATCH/api/v1/data/:collection/:id

Partially update an existing document by its ID.

DELETE/api/v1/data/:collection/:id

Delete a document by ID.

6. Standard Error Format & Rate Limits

Deterministic response schema

{
  "success": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Invalid or revoked API key."
  }
}

Default rate limit quota is 300 requests per minute per API key token. Responses include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers.