benji-sdk
v0.1.0
Published
Official TypeScript SDK for the Benji API - Your personal life operating system
Maintainers
Readme
Benji SDK
Official TypeScript SDK for the Benji API - Your personal life operating system.
Installation
npm install benji-sdk
# or
pnpm add benji-sdk
# or
yarn add benji-sdkQuick Start
import { configure, Todos, Habits } from "benji-sdk";
// Configure with your API key
configure({ apiKey: "your-api-key" });
// List today's todos
const { data } = await Todos.todosList({
body: { screen: "today" }
});
console.log(data.todos);Getting Your API Key
- Log in to Benji
- Go to Settings > API
- Generate a new API key
Available Modules
| Module | Description |
|--------|-------------|
| Todos | Create, list, update, and manage todos |
| Habits | Track daily habits |
| Mood | Log and retrieve mood entries |
| Journal | Create and manage journal entries |
| Hydration | Track water intake |
| Fasting | Manage fasting windows |
| Workouts | Log workouts and exercises |
| Projects | Organize todos into projects |
| Tags | Categorize items with tags |
| Trips | Plan and track travel |
| PainEvents | Log pain events for health tracking |
Examples
Todos
import { configure, Todos } from "benji-sdk";
configure({ apiKey: "your-api-key" });
// Create a todo
await Todos.todosCreate({
body: {
title: "Buy groceries",
priority: "high",
dueDate: "2024-12-25"
}
});
// List todos for today
const { data } = await Todos.todosList({
body: { screen: "today" }
});
// Mark as complete
await Todos.todosToggle({
body: { id: "todo-id" }
});
// Delete a todo
await Todos.todosDelete({
body: { id: "todo-id" }
});Habits
import { configure, Habits } from "benji-sdk";
configure({ apiKey: "your-api-key" });
// Create a habit
await Habits.habitsCreate({
body: {
name: "Drink 8 glasses of water",
emoji: "💧"
}
});
// List all habits
const { data } = await Habits.habitsList();
// Toggle habit completion for today
await Habits.habitsToggle({
body: { id: "habit-id" }
});Mood Tracking
import { configure, Mood } from "benji-sdk";
configure({ apiKey: "your-api-key" });
// Log your mood
await Mood.moodCreate({
body: {
level: 4, // 1-5 scale
notes: "Feeling great today!"
}
});
// Get mood logs
const { data } = await Mood.moodList();Journal
import { configure, Journal } from "benji-sdk";
configure({ apiKey: "your-api-key" });
// Create a journal entry
await Journal.journalCreate({
body: {
content: "Today was a productive day...",
title: "Daily Reflection"
}
});Custom Base URL
For self-hosted instances or development:
configure({
apiKey: "your-api-key",
baseUrl: "https://your-instance.com/api/rest"
});TypeScript Support
This SDK is written in TypeScript and provides full type definitions for all API endpoints, request bodies, and responses.
import type { TodosListResponse, HabitsCreateData } from "benji-sdk";Error Handling
import { Todos } from "benji-sdk";
try {
const { data, error, response } = await Todos.todosGet({
body: { id: "invalid-id" }
});
if (error) {
console.error("API Error:", error.message);
}
} catch (err) {
console.error("Network error:", err);
}License
MIT
