@reminix/sdk
v0.5.0
Published
Reminix TypeScript SDK
Maintainers
Readme
@reminix/sdk
Reminix TypeScript SDK
Installation
npm install @reminix/sdk
# or
pnpm add @reminix/sdk
# or
yarn add @reminix/sdkQuick Start
import { Client } from '@reminix/sdk';
const client = new Client({
apiKey: 'your-api-key',
});
const project = await client.project.get();
console.log(`Project: ${project.name} (${project.id})`);Usage
Basic Client Usage
import { Client } from '@reminix/sdk';
const client = new Client({
apiKey: 'your-api-key',
baseURL: 'https://api.reminix.com/v1', // Optional, defaults to this
timeout: 30000, // Optional, defaults to 30000ms
});Project Operations
import { Client } from '@reminix/sdk';
const client = new Client({
apiKey: 'your-api-key',
});
// Get current project
const project = await client.project.get();
console.log(`Project ID: ${project.id}`);
console.log(`Project Name: ${project.name}`);
console.log(`Organization ID: ${project.organizationId}`);
console.log(`Slug: ${project.slug}`);
console.log(`Created: ${project.createdAt}`);
console.log(`Updated: ${project.updatedAt}`);Pagination
For endpoints that return paginated data, use the pagination utilities:
import { Client, PaginatedResponse, paginateAll, collectAll } from '@reminix/sdk';
const client = new Client({
apiKey: 'your-api-key',
});
// Helper function to fetch a page of events
async function fetchEvents(cursor?: string): Promise<PaginatedResponse<Event>> {
const response = await client.request<{
data: Event[];
nextCursor?: string;
hasMore: boolean;
}>('GET', '/events', {
headers: cursor ? { cursor } : undefined,
});
return {
data: response.data,
nextCursor: response.nextCursor,
hasMore: response.hasMore,
};
}
// Option 1: Iterate through all pages (async generator)
for await (const event of paginateAll(fetchEvents)) {
console.log(`Event: ${event.id}`);
}
// Option 2: Collect all items into an array
const allEvents = await collectAll(fetchEvents);
console.log(`Total events: ${allEvents.length}`);Error Handling
import { Client, AuthenticationError, APIError, NetworkError } from '@reminix/sdk';
const client = new Client({
apiKey: 'your-api-key',
});
try {
const project = await client.project.get();
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Authentication failed:', error.message);
console.error('Status code:', error.status);
} else if (error instanceof APIError) {
console.error('API error:', error.message);
console.error('Status:', error.status, error.reason);
} else if (error instanceof NetworkError) {
console.error('Network error:', error.message);
}
}Configuration
import { Client } from '@reminix/sdk';
// Custom base URL
const client = new Client({
apiKey: 'your-api-key',
baseURL: 'https://custom-api.example.com/v1',
});
// Custom timeout
const client = new Client({
apiKey: 'your-api-key',
timeout: 60000, // 60 seconds
});
// Custom headers
const client = new Client({
apiKey: 'your-api-key',
headers: {
'X-Custom-Header': 'value',
},
});Making Direct Requests
You can also make direct requests using the client:
const client = new Client({
apiKey: 'your-api-key',
});
// GET request
const data = await client.request('GET', '/endpoint');
// POST request
const result = await client.request('POST', '/endpoint', {
body: { key: 'value' },
});
// With custom headers
const response = await client.request('GET', '/endpoint', {
headers: {
'X-Custom-Header': 'value',
},
});Type Safety
The SDK provides full TypeScript type safety. All responses are typed based on the OpenAPI specification:
import { Client } from '@reminix/sdk';
import type { paths } from '@reminix/sdk';
// Response types are automatically inferred
const project = await client.project.get();
// project is typed as GetProjectResponse
// You can also use the generated types directly
type Project = paths['/project']['get']['responses']['200']['content']['application/json'];License
MIT
