TypeScript and Python SDK
At a glance
The official Ontologie SDKs let you integrate the platform into your applications without directly manipulating the REST API. They provide full typing, automatic authentication handling, and intuitive methods for every feature.
Available packages
| Package | Language | Description |
|---|---|---|
@ontologie/client | TypeScript | HTTP client with full typing |
@ontologie/types-runtime | TypeScript | Shared types and schemas |
@ontologie/react | TypeScript | React hooks for frontend applications |
@ontologie/oauth | TypeScript | Utilities for the OAuth2 PKCE flow |
@ontologie/sdk-generator | TypeScript | SDK generator from OpenAPI specifications |
ontologie-sdk | Python | Python client with typing (dataclasses) |
Installation
TypeScript
npm install @ontologie/client @ontologie/types-runtime
Python
pip install ontologie-sdk
Authentication
The SDKs handle authentication automatically. Provide your API key and workspace ID:
TypeScript
import { OntologieClient } from '@ontologie/client';
const client = new OntologieClient({
apiKey: process.env.ONTOLOGIE_API_KEY,
workspaceId: process.env.ONTOLOGIE_WORKSPACE_ID,
});
Python
from ontologie_sdk import OntologieClient
client = OntologieClient(
api_key="votre_cle_api",
workspace_id="votre_workspace_id",
)
Usage examples
List entities
// TypeScript
const entities = await client.nodes.list({
limit: 50,
entityType: 'concept',
});
for (const entity of entities.data) {
console.log(entity.name, entity.entityType);
}
# Python
entities = client.nodes.list(limit=50, entity_type="concept")
for entity in entities.data:
print(entity.name, entity.entity_type)
Create an entity
// TypeScript
const node = await client.nodes.create({
name: 'Mon Entite',
entityType: 'concept',
properties: { description: 'Description de l\'entite' },
});
Execute a command
// TypeScript
const result = await client.commands.execute({
type: 'UPDATE_NODE',
payload: {
id: 'uuid-de-lentite',
name: 'Nouveau Nom',
},
expectedVersion: 3,
});
React hooks
The @ontologie/react package provides hooks for integrating Ontologie into your React applications:
import { useNodes, useNode } from '@ontologie/react';
function EntityList() {
const { data: nodes, isLoading } = useNodes({ entityType: 'concept' });
if (isLoading) return <p>Chargement...</p>;
return (
<ul>
{nodes.map(node => (
<li key={node.id}>{node.name}</li>
))}
</ul>
);
}
The hooks automatically handle caching, refreshing, and loading states.
Error handling
The SDKs throw typed exceptions to make diagnosis easier:
import { OntologieError, AuthenticationError, ValidationError } from '@ontologie/client';
try {
await client.nodes.create({ name: '', entityType: 'concept' });
} catch (error) {
if (error instanceof ValidationError) {
console.error('Champs invalides :', error.details);
} else if (error instanceof AuthenticationError) {
console.error('Cle API invalide');
}
}
Interactive documentation
The Client Portal provides interactive documentation with:
- Sandbox: test endpoints directly in your browser
- Language-specific examples: TypeScript and Python snippets for each endpoint
- Schemas: browsable request and response schemas
Access: portal.ontologie-growthsystemes.com
See also
- API Keys — Create and manage keys
- OAuth Authentication — OAuth2 PKCE flow
- Limits and quotas — Rate limits and pagination
- API Reference — Full OpenAPI documentation
Need help?
Contact us: Support and contact.