SDK TypeScript
Vue d'ensemble
Intégrez Tiime dans vos applications TypeScript
Le SDK tiime-sdk permet d'intégrer l'API Tiime dans vos applications Node.js. Il fonctionne de manière autonome, sans le CLI.
Installation
npm install tiime-sdkExemple rapide
import { TiimeClient } from "tiime-sdk";
const client = new TiimeClient();
// Factures payees
const invoices = await client.invoices.list({ status: "paid" });
// Soldes bancaires
const balances = await client.bankAccounts.balance();
// Creer une facture
const created = await client.invoices.create({
emission_date: "2026-03-01",
client: { id: 100 },
lines: [{
description: "Prestation de conseil",
quantity: 5,
unit_amount: 800,
vat_type: { code: "normal" },
invoicing_unit: { id: 3, code: "day" },
}],
status: "draft",
});Authentification
Le SDK resout l'authentification automatiquement. Trois modes sont supportes :
export TIIME_EMAIL=vous@example.com
export TIIME_PASSWORD=votre-mot-de-passe
export TIIME_COMPANY_ID=12345const client = new TiimeClient(); // tout est resolu automatiquementconst client = new TiimeClient({
email: "vous@example.com",
password: "votre-mot-de-passe",
companyId: 12345,
});Si tiime-cli est installe, le SDK utilise ses tokens automatiquement :
tiime auth login && tiime company use --id 12345const client = new TiimeClient(); // utilise les tokens stockes par le CLIToken direct
Vous pouvez aussi passer un access token via TIIME_ACCESS_TOKEN ou l'option tokens: { access_token, expires_at }.
Ressources disponibles
| Ressource | Acces | Methodes | Description |
|---|---|---|---|
| Factures | client.invoices | 8 | CRUD + envoi + PDF + duplication |
| Devis | client.quotations | 5 | CRUD + envoi + PDF |
| Clients | client.clients | 4 | CRUD + recherche |
| Comptes bancaires | client.bankAccounts | 3 | Liste + details + soldes |
| Transactions | client.bankTransactions | 6 | Liste + pagination auto + imputation |
| Notes de frais | client.expenseReports | 3 | CRUD |
| Documents | client.documents | 5 | Liste + categories + upload + download |
| Labels | client.labels | 3 | Personnalises + standards + tags |
| Utilisateurs | client.users | 3 | Profil + infos legales + settings |
| Entreprise | client.company | 4 | Details + config + dashboard |
| Entreprises | client.listCompanies() | 1 | Liste des entreprises du compte |
Gestion des erreurs
import { TiimeClient, TiimeError } from "tiime-sdk";
try {
const invoice = await client.invoices.get(99999);
} catch (error) {
if (error instanceof TiimeError) {
console.error(`Erreur ${error.status}: ${error.message}`);
console.error(`Endpoint: ${error.endpoint}`);
}
}Retry automatique
Le SDK integre un retry avec backoff exponentiel sur les erreurs 429 (rate limit) et 5xx (erreurs serveur).