@elqnt/api-client
v1.0.5
Published
Shared API client infrastructure for Eloquent platform
Readme
@elqnt/api-client
HTTP client infrastructure for the Eloquent platform. Provides browser and server-side clients with automatic token management.
Installation
npm install @elqnt/api-clientQuick Start
Browser
import { browserApiRequest } from "@elqnt/api-client/browser";
const response = await browserApiRequest<User>("/api/v1/users/me", {
baseUrl: "https://api.example.com",
orgId: "org_123",
});
if (response.data) {
console.log("User:", response.data);
}Server (SSR)
import { createServerClient } from "@elqnt/api-client/server";
const client = createServerClient({
gatewayUrl: process.env.API_GATEWAY_URL!,
jwtSecret: process.env.JWT_SECRET!,
});
const users = await client.get<User[]>("/api/v1/users", { orgId: "org_123" });Entry Points
| Import | Use Case |
|--------|----------|
| @elqnt/api-client | Types and utilities |
| @elqnt/api-client/browser | Client-side API calls |
| @elqnt/api-client/server | SSR and server actions |
Key Functions
Browser
browserApiRequest<T>(endpoint, options)- Make HTTP requestcreateBrowserClient(options)- Create reusable clientclearGatewayTokenCache()- Clear cached token on logout
Server
serverApiRequest<T>(endpoint, options)- Server-side requestcreateServerClient(config)- Create reusable server clientgenerateServerToken(config)- Generate JWT directly
Documentation
Full API reference: https://docs.eloquent.ai/packages/api-client
Changelog
See CHANGELOG.md
License
Private - Eloquent Platform
