Guide

LLM instructions

Give this page to your coding assistant when you want it to add I Need A Database to an app.

Prompt to give your LLM

Paste this into your coding assistant, then provide your actual project id and API key as private secrets in your app environment.

copy this prompt
Use I Need A Database as the app's JSON database.

Read this implementation guide first:
https://ineedadatabase.com/docs/llms

Important facts:
- Base URL: https://ineedadatabase.com
- API prefix: /api/v1
- Project id placeholder: proj_123
- API key placeholder: inadb_...
- Store the API key only as a server-side secret. Do not expose it in browser code.
- Do not call the API directly from frontend JavaScript. Proxy through a server route, serverless function, worker, or backend service.
- Use collections, not tables.
- Store JSON documents as sent. Do not invent schemas, migrations, joins, or foreign keys.
- When creating documents, send document fields directly. Do not wrap them in { "data": ... }.
- List responses are objects: { "items": [...], "next_cursor": null }. They are not bare arrays.

Task:
1. Add server-side helpers for creating, reading, updating, deleting, filtering, and paginating documents.
2. Read INEEDADATABASE_PROJECT_ID and INEEDADATABASE_API_KEY from environment variables.
3. Use Authorization: Bearer <api key> and Content-Type: application/json.
4. Create collections if needed before writing documents.
5. Model relationships with id fields such as user_id, project_id, or order_id inside documents.
6. Use query parameters for filters, sort, limit, and cursor pagination.
7. Keep the integration small and conventional. If something requires auth by end user, field-level permissions, joins, or direct browser access, explain that this is not supported yet and keep the API calls on the server.

Integration facts

  • Product name: I Need A Database.
  • Use case: a simple hosted HTTP + JSON database for apps that need to store and retrieve JSON quickly.
  • Base URL: https://ineedadatabase.com.
  • API prefix: /api/v1.
  • Public API style: REST over HTTP with JSON request and response bodies.
  • Runtime style: call the API from server-side code, not directly from browser JavaScript.
  • Terminology: projects contain collections; collections contain JSON documents.
  • Full API reference: /docs/api.

Data model

I Need A Database does not require schemas. A document is any JSON object posted to a collection. The JSON request body is stored as-is as the document data.

create request
POST /api/v1/projects/proj_123/collections/recipes/documents
Content-Type: application/json

{
  "title": "Pasta",
  "servings": 4,
  "tags": ["dinner", "quick"]
}
document response
{
  "id": "A1b2C3d4",
  "created_at": "2026-05-08T12:00:00Z",
  "updated_at": "2026-05-08T12:00:00Z",
  "revision": "rev_E5f6G7h8",
  "data": {
    "title": "Pasta",
    "servings": 4,
    "tags": ["dinner", "quick"]
  }
}

Response shapes

Single-document endpoints return one document object. List endpoints return an envelope with items and next_cursor.

list response
{
  "items": [
    {
      "id": "A1b2C3d4",
      "created_at": "2026-05-08T12:00:00Z",
      "updated_at": "2026-05-08T12:00:00Z",
      "revision": "rev_E5f6G7h8",
      "data": {
        "title": "Pasta",
        "servings": 4
      }
    }
  ],
  "next_cursor": null
}
client parsing rule
const payload = await response.json();
const documents = payload.items;
const nextCursor = payload.next_cursor;

Authentication

Use a bearer API key from the project dashboard. Store it as a server-side secret, for example INEEDADATABASE_API_KEY. Store the project id separately, for example INEEDADATABASE_PROJECT_ID.

headers
Authorization: Bearer inadb_...
Content-Type: application/json
server-side proxy pattern
export async function GET() {
  const baseUrl = "https://ineedadatabase.com";
  const projectId = process.env.INEEDADATABASE_PROJECT_ID;
  const apiKey = process.env.INEEDADATABASE_API_KEY;

  const response = await fetch(
    `${baseUrl}/api/v1/projects/${projectId}/collections/recipes/documents`,
    {
      headers: {
        Authorization: `Bearer ${apiKey}`
      }
    }
  );

  return Response.json(await response.json(), { status: response.status });
}

Endpoints

GET/api/v1/projects
List projects for the signed-in dashboard session.
POST/api/v1/projects
Create a project for the signed-in dashboard session. Body: { "name": "My app" }.
GET/api/v1/projects/:projectId
Read one project summary for the signed-in dashboard session.
DELETE/api/v1/projects/:projectId
Delete one project for the signed-in dashboard session.
GET/api/v1/projects/:projectId/collections
List collections.
POST/api/v1/projects/:projectId/collections
Create a collection. Body: { "name": "recipes" }.
GET/api/v1/projects/:projectId/collections/:collection/documents
List documents. Supports filters, sort, limit, and cursor.
POST/api/v1/projects/:projectId/collections/:collection/documents
Create a document from the JSON body.
GET/api/v1/projects/:projectId/collections/:collection/documents/:documentId
Read one document by id.
PUT/api/v1/projects/:projectId/collections/:collection/documents/:documentId
Replace one document body. Use If-Match with the current revision when overwrites must be guarded.
PATCH/api/v1/projects/:projectId/collections/:collection/documents/:documentId
Apply a JSON merge patch. Use If-Match with the current revision for optimistic concurrency.
DELETE/api/v1/projects/:projectId/collections/:collection/documents/:documentId
Delete one document by id.

Filtering, sorting, and pagination

Use query parameters on the document list endpoint. Multiple filters are combined with AND. Repeated query parameters are treated as multiple filters, not an OR query.

examples
GET /api/v1/projects/proj_123/collections/recipes/documents?servings=4
GET /api/v1/projects/proj_123/collections/recipes/documents?rating_gte=4
GET /api/v1/projects/proj_123/collections/recipes/documents?title_contains=pasta
GET /api/v1/projects/proj_123/collections/recipes/documents?tags_contains=quick
GET /api/v1/projects/proj_123/collections/orders/[email protected]
GET /api/v1/projects/proj_123/collections/recipes/documents?sort=-created_at&limit=50
GET /api/v1/projects/proj_123/collections/recipes/documents?limit=50&cursor=abc123
  • Equals: ?field=value.
  • Numeric comparisons: ?field_gt=10, ?field_gte=10, ?field_lt=10, ?field_lte=10.
  • Text or array contains: ?field_contains=value.
  • Nested object paths: [email protected].
  • Sort ascending with ?sort=field and descending with ?sort=-field.
  • Paginate with ?limit=50, then pass returned next_cursor as ?cursor=....

Relationships

Model relationships by storing reference ids inside JSON documents, such as user_id, order_id, or project_id. Query documents by those fields when you need related records.

related documents
POST /api/v1/projects/proj_123/collections/tasks/documents

{
  "title": "Send invoice",
  "user_id": "user_123",
  "status": "open"
}

GET /api/v1/projects/proj_123/collections/tasks/documents?user_id=user_123

Current limits

  • Free tier projects: 2 per account.
  • Free tier storage: 500KB per project.
  • Paid storage direction: 100MB per project.
  • Default list limit: 50 documents.
  • Maximum list limit: 500 documents.
  • Maximum request body: 1024KB.
  • Maximum JSON string value: 100KB.
  • Maximum filters per request: 20.

Not implemented yet

  • No browser-safe end-user API key flow or direct browser CORS support.
  • No /me owner-scoped routes yet.
  • No field-level permissions.
  • No joins, foreign keys, or relational query planner.
  • No required schema or migrations.
  • No GraphQL API.
  • No configurable CORS, rate limiting, audit logs, or backups yet.