Skip to content

Quick Start

This guide will help you make your first API calls to BitMarks in just a few minutes.

  • A BitMarks account (sign up at app.bitmarks.sh)
  • Basic familiarity with REST APIs
  • A tool for making HTTP requests (curl, Postman, or your favorite HTTP client)
  1. First, verify the API is operational:

    Terminal window
    curl https://app.bitmarks.sh/api/v1/health

    Expected Response:

    {
    "name": "@bitmarks.sh/api",
    "version": "2.0.0-alpha",
    "environment": "production",
    "status": "healthy",
    "timestamp": "2025-01-15T12:00:00.000Z"
    }
  2. BitMarks uses OAuth 2.0 via WorkOS AuthKit. To authenticate:

    Terminal window
    # Initiate login flow
    curl -X POST https://app.bitmarks.sh/api/v1/auth/login \
    -H "Content-Type: application/json" \
    -d '{"returnTo": "/"}'

    Response:

    {
    "authorizationUrl": "https://authkit.workos.com/..."
    }

    Redirect the user to the authorizationUrl. After authentication, they’ll be redirected back with a session cookie set.

  3. After the OAuth callback, verify your session:

    Terminal window
    curl https://app.bitmarks.sh/api/v1/auth/session \
    -b "bitmarks_session=YOUR_SESSION_COOKIE"

    Response:

    {
    "authenticated": true,
    "user": {
    "user_id": "user_01ABC123",
    "email": "you@example.com",
    "name": "Your Name",
    "email_verified": true
    }
    }
  4. See your current sync status:

    Terminal window
    curl https://app.bitmarks.sh/api/v1/sync/status \
    -b "bitmarks_session=YOUR_SESSION_COOKIE"

    Response:

    {
    "user_id": "user_01ABC123",
    "last_sync": 1735430400000,
    "pending_changes": 0,
    "conflict_count": 0,
    "total_bookmarks": 150
    }
  5. Fetch all bookmarks (or changes since a timestamp):

    Terminal window
    curl -X POST https://app.bitmarks.sh/api/v1/sync/pull \
    -H "Content-Type: application/json" \
    -b "bitmarks_session=YOUR_SESSION_COOKIE" \
    -d '{"since": 0, "limit": 100}'

    Response:

    {
    "changes": [
    {
    "id": "sync_abc123",
    "entity_type": "bookmark",
    "entity_id": "bm_xyz",
    "operation": "create",
    "encrypted_data": "eyJhbGciOi...",
    "data_hash": "a1b2c3d4...",
    "timestamp": 1735430400000
    }
    ],
    "last_sync_timestamp": 1735430400000,
    "has_more": false
    }
import { encryptObject, decryptObject } from '@bitmarks.sh/core';
// Your encryption key (derived from password)
const key = await deriveKey(password, salt);
// Encrypt a bookmark
const bookmark = {
id: 'bm_' + crypto.randomUUID(),
title: 'Example Bookmark',
url: 'https://example.com',
source: 'bookmarks',
dateAdded: new Date().toISOString()
};
const encrypted = await encryptObject(bookmark, key);
// { nonce: '...', ciphertext: '...', tag: '...' }
// Decrypt received data
const decrypted = await decryptObject(encrypted, key);
// { id: 'bm_...', title: 'Example Bookmark', ... }

Now that you’ve made your first API calls:

Your session cookie may be expired. Call /auth/refresh to get a new access token, or re-authenticate.

When calling from a browser, ensure you’re:

  1. Using credentials: 'include' in fetch
  2. Calling from an allowed origin

If you’re a new user, you won’t have any bookmarks yet. Try importing some first via the browser extension or the import endpoint.