TypeScript SDK
Install the official EasySQL JavaScript / TypeScript SDK, connect to your account, and run your first query in under 5 minutes. Works in Node.js, Bun, Deno, and modern browser runtimes.
Installation
npm install @clearsoft/easysql-sdk
# or
bun add @clearsoft/easysql-sdk
# or
pnpm add @clearsoft/easysql-sdkQuick start
The SDK exports a single factory function, createEasySQLClient. Pass the accessToken you got from POST /v1/auth/login.
import { createEasySQLClient } from '@clearsoft/easysql-sdk';
const api = createEasySQLClient({
baseUrl: 'https://api.easysql.net',
accessToken: 'your-access-token',
});Authentication
import { createEasySQLClient } from '@clearsoft/easysql-sdk';
// Login by email + password
const api = createEasySQLClient({
baseUrl: 'https://api.easysql.net',
});
const { data: token, error } = await api.login({
email: '[email protected]',
password: 'my-password',
});
if (error) throw new Error(`Login failed: ${error}`);
// Re-create the client with the new token
const authApi = createEasySQLClient({
baseUrl: 'https://api.easysql.net',
accessToken: token.access_token,
});
const { data: user } = await authApi.me();Running natural-language queries
// Ask a question
const { data: result } = await api.createQuery({
connector_id: 'conn_abc123',
question: 'How many users signed up this month?',
});
console.log(result?.sql); // Generated SQL query
console.log(result?.result); // Execution rows
// List recent query history (paginated)
const { data: history } = await api.listQueries({ page: 1, per_page: 10 });
// Fetch a specific query by id
const { data: query } = await api.getQuery({ query_id: result!.id });Managing database connectors
// Create a connector
const { data: connector } = await api.createConnector({
name: 'Production DB',
type: 'mysql',
config: {
host: 'db.example.com',
port: 3306,
database: 'myapp',
user: 'readonly',
password: 'secret',
},
});
// List, get, update, delete, sync, test
const { data: connectors } = await api.listConnectors();
const { data: conn } = await api.getConnector({ connector_id: 'abc-123' });
const { data: updated } = await api.updateConnector(
{ name: 'Staging DB' },
{ path: { connector_id: 'abc-123' } },
);
await api.deleteConnector({ connector_id: 'abc-123' });
await api.syncConnector({ connector_id: 'abc-123' });
const { data: test } = await api.testConnector({ type: 'mysql', config: { /* ... */ } });Dashboard & analytics
const { data: stats } = await api.dashboardStats();
// {
// active_connectors, queries_used_this_month, queries_limit,
// queries_per_day: [...], most_used_connectors: [...], fetched_at
// }Next steps
- Full method-by-method reference — the generated
createEasySQLClientfactory with every endpoint, parameter and return type. - SDK repository — source, tests, and release notes.