Skip to content
TIMEKEEPER
API DOCS

Recipes

End-to-end punch-in snippets using environment variables for the base URL and token, plus compact read commands for day and week automation.

Punch In Script#

bash curl
#!/usr/bin/env bash
set -euo pipefail

: "${NEXTAUTH_URL:?}"
: "${TIMEKEEPER_TOKEN:?}"

curl -sS -X POST "$NEXTAUTH_URL/api/checkin" \
  -H "Authorization: Bearer $TIMEKEEPER_TOKEN"

# later
curl -sS -X POST "$NEXTAUTH_URL/api/checkout" \
  -H "Authorization: Bearer $TIMEKEEPER_TOKEN"
node fetch
const baseUrl = process.env.NEXTAUTH_URL;
const token = process.env.TIMEKEEPER_TOKEN;

async function punch(path) {
  const response = await fetch(`${baseUrl}${path}`, {
    method: "POST",
    headers: { Authorization: `Bearer ${token}` },
  });
  if (!response.ok) throw new Error(await response.text());
  return response.json();
}

await punch("/api/checkin");
await punch("/api/checkout");
python requests
import os
import requests

base_url = os.environ["NEXTAUTH_URL"]
headers = {"Authorization": f"Bearer {os.environ['TIMEKEEPER_TOKEN']}"}

checkin = requests.post(f"{base_url}/api/checkin", headers=headers)
checkin.raise_for_status()

checkout = requests.post(f"{base_url}/api/checkout", headers=headers)
checkout.raise_for_status()
print(checkout.json())

Useful One-Liners#

Fetch this week's time entries for local aggregation.

curl week
curl -sS "$NEXTAUTH_URL/api/time-entries?from=$(date -d monday +%F)&to=$(date -d sunday +%F)" \
  -H "Authorization: Bearer $TIMEKEEPER_TOKEN"

Fetch today's day summary with comments and files.

curl day
curl -sS "$NEXTAUTH_URL/api/days/$(date +%F)" \
  -H "Authorization: Bearer $TIMEKEEPER_TOKEN"