Skip to main content

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

PackageLanguageDescription
@ontologie/clientTypeScriptHTTP client with full typing
@ontologie/types-runtimeTypeScriptShared types and schemas
@ontologie/reactTypeScriptReact hooks for frontend applications
@ontologie/oauthTypeScriptUtilities for the OAuth2 PKCE flow
@ontologie/sdk-generatorTypeScriptSDK generator from OpenAPI specifications
ontologie-sdkPythonPython 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

Need help?

Contact us: Support and contact.