API Documentation - joinruach/JoinRuach GitHub Wiki

API Documentation


Overview

The Ruach Studios API provides programmatic access to content, user data, and platform features. Built with tRPC for end-to-end type safety and Next.js API routes for RESTful endpoints.

Base URL: https://api.ruachstudios.com


Authentication

All API requests require authentication using JWT tokens.

Getting an API Key

  1. Create an account at ruachstudios.com
  2. Navigate to Settings → API Keys
  3. Generate a new API key
  4. Store it securely (never commit to version control)

Authentication Header

Authorization: Bearer YOUR_API_KEY_HERE

tRPC Endpoints

Setup

Install the tRPC client:

npm install @trpc/client @trpc/server

Initialize the client:

import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '@/server/routers/_app';

const client = createTRPCProxyClient<AppRouter>({
  links: [
    httpBatchLink({
      url: 'https://api.ruachstudios.com/trpc',
      headers() {
        return {
          authorization: `Bearer ${process.env.API_KEY}`,
        };
      },
    }),
  ],
});

Queries

Get Content

Fetch content by ID.

const content = await client.content.getById.query({ id: '123' });

console.log(content);
// Output: { id: '123', title: 'Sample Content', body: '...' }

Parameters:

  • id (string, required) — Content ID

Response:

{
  id: string;
  title: string;
  body: string;
  createdAt: Date;
  updatedAt: Date;
  author: {
    id: string;
    name: string;
  };
}

List Content

Fetch a paginated list of content.

const contentList = await client.content.list.query({
  page: 1,
  limit: 10,
});

console.log(contentList);
// Output: { items: [...], total: 100, page: 1, limit: 10 }

Parameters:

  • page (number, optional) — Page number (default: 1)
  • limit (number, optional) — Items per page (default: 10, max: 100)

Response:

{
  items: Content[];
  total: number;
  page: number;
  limit: number;
}

Mutations

Create Content

Create new content.

const newContent = await client.content.create.mutate({
  title: 'My New Post',
  body: 'Content goes here...',
});

console.log(newContent);
// Output: { id: '456', title: 'My New Post', ... }

Parameters:

  • title (string, required) — Content title
  • body (string, required) — Content body

Response:

{
  id: string;
  title: string;
  body: string;
  createdAt: Date;
}

Update Content

Update existing content.

const updatedContent = await client.content.update.mutate({
  id: '123',
  title: 'Updated Title',
});

console.log(updatedContent);
// Output: { id: '123', title: 'Updated Title', ... }

Parameters:

  • id (string, required) — Content ID
  • title (string, optional) — New title
  • body (string, optional) — New body

Response:

{
  id: string;
  title: string;
  body: string;
  updatedAt: Date;
}

Delete Content

Delete content by ID.

await client.content.delete.mutate({ id: '123' });

console.log('Content deleted');

Parameters:

  • id (string, required) — Content ID

Response:

{
  success: boolean;
}

REST API (Alternative)

For non-TypeScript environments, use the REST API.

Get Content

GET /api/content/:id

Example:

curl -X GET https://api.ruachstudios.com/api/content/123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "id": "123",
  "title": "Sample Content",
  "body": "...",
  "createdAt": "2024-01-01T00:00:00Z",
  "updatedAt": "2024-01-01T00:00:00Z"
}

List Content

GET /api/content?page=1&limit=10

Example:

curl -X GET "https://api.ruachstudios.com/api/content?page=1&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "items": [...],
  "total": 100,
  "page": 1,
  "limit": 10
}

Create Content

POST /api/content

Example:

curl -X POST https://api.ruachstudios.com/api/content \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "My New Post", "body": "Content here..."}'

Response:

{
  "id": "456",
  "title": "My New Post",
  "body": "Content here...",
  "createdAt": "2024-01-01T00:00:00Z"
}

Update Content

PUT /api/content/:id

Example:

curl -X PUT https://api.ruachstudios.com/api/content/123 \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Updated Title"}'

Response:

{
  "id": "123",
  "title": "Updated Title",
  "body": "...",
  "updatedAt": "2024-01-01T12:00:00Z"
}

Delete Content

DELETE /api/content/:id

Example:

curl -X DELETE https://api.ruachstudios.com/api/content/123 \
  -H "Authorization: Bearer YOUR_API_KEY"

Response:

{
  "success": true
}

Rate Limits

Standard Plan:

  • 1,000 requests per hour
  • 10,000 requests per day

Pro Plan (Future):

  • 10,000 requests per hour
  • 100,000 requests per day

Exceeding Limits:

{
  "error": "Rate limit exceeded",
  "retryAfter": 3600
}

Error Handling

Error Format

{
  "error": {
    "code": "NOT_FOUND",
    "message": "Content not found",
    "statusCode": 404
  }
}

Common Error Codes

Code HTTP Status Description
UNAUTHORIZED 401 Invalid or missing API key
FORBIDDEN 403 Insufficient permissions
NOT_FOUND 404 Resource does not exist
BAD_REQUEST 400 Invalid request parameters
INTERNAL_SERVER_ERROR 500 Server error
RATE_LIMIT_EXCEEDED 429 Too many requests

Webhooks (Coming Soon)

Subscribe to events:

  • content.created
  • content.updated
  • content.deleted

SDK Libraries

TypeScript/JavaScript

npm install @ruachstudios/sdk

Python

pip install ruachstudios

Go

go get github.com/ruachstudios/sdk-go

Support

Need help with the API?


"Trust in the Lord with all your heart, and do not lean on your own understanding." — Proverbs 3:5

⚠️ **GitHub.com Fallback** ⚠️