@incrm-app/sdk
v0.1.0
Published
TypeScript SDK for the InCRM API — auto-generated from OpenAPI spec
Downloads
58
Readme
@incrm-app/sdk
Auto-generated TypeScript SDK for the InCRM API, built from the OpenAPI specification.
Installation
npm install @incrm-app/sdkUsage
API Key Authentication
import { InCRMClient, listClients, createInvoice } from '@incrm-app/sdk'
const incrm = new InCRMClient({
baseUrl: 'https://api.incrm.app',
apiKey: 'your-api-key',
})
// List clients (paginated)
const { data } = await listClients({ query: { page: 1, perPage: 20 } })
console.log(data) // { success: true, data: [...], meta: { total, lastPage, ... } }
// Create an invoice
const { data: invoice } = await createInvoice({
body: {
clientId: 'client-id',
items: [{ description: 'Consulting', quantity: 1, unitPrice: 100 }],
},
})JWT Bearer Authentication
import { InCRMClient, listProducts } from '@incrm-app/sdk'
const incrm = new InCRMClient({
baseUrl: 'https://api.incrm.app',
accessToken: 'jwt-token-from-sign-in',
})
const { data } = await listProducts()Switching Auth at Runtime
// Switch to a new API key
incrm.setApiKey('new-api-key')
// Or switch to JWT
incrm.setAccessToken('new-jwt-token')Pagination
All list endpoints accept page and perPage query parameters.
Responses include a meta object with pagination details:
const { data } = await listClients({ query: { page: 2, perPage: 10 } })
// data.meta = { total, lastPage, currentPage, perPage, prev, next }Generated Files
| File | Contents |
|---|---|
| src/generated/types.gen.ts | Request/response TypeScript interfaces |
| src/generated/sdk.gen.ts | Typed SDK functions for every endpoint |
| src/generated/client.gen.ts | Shared HTTP client instance |
| src/client.ts | InCRMClient wrapper with auth helpers |
Do not edit files in
src/generated/— they are overwritten on each generation run.
