Votre premier appel API
Utilisez un script Node.js local ou votre serveur. Fournissez KARDILO_CLIENT_ID et KARDILO_CLIENT_SECRET depuis votre gestionnaire de secrets avant de lancer cet exemple. Le jeton reste en mémoire ; seule la réponse contenant les extensions est affichée.
const clientId = process.env.KARDILO_CLIENT_ID;
const clientSecret = process.env.KARDILO_CLIENT_SECRET;
if (!clientId || !clientSecret) throw new Error('Missing partner credentials');
const auth = await fetch('https://dev-0fzltgk7uli3w300.us.auth0.com/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
audience: 'https://kardilo.com/api/v1/mcp',
}),
});
if (!auth.ok) throw new Error(`Token exchange: HTTP ${auth.status}`);
const { access_token: token } = await auth.json();
if (typeof token !== 'string' || !token) throw new Error('Missing access token');
const result = await fetch('https://kardilo.com/api/v1/catalog/sets', {
headers: { Authorization: `Bearer ${token}` },
});
if (!result.ok) throw new Error(`Catalogue: HTTP ${result.status}`);
console.log(JSON.stringify(await result.json(), null, 2));
Résultat attendu
Un statut HTTP 200 et un tableau data contenant les extensions. Choisissez un id ou un code retourné, puis demandez ses cartes. Utilisez l’id d’une carte retournée pour ses détails.
Vous avez déjà un jeton dans KARDILO_ACCESS_TOKEN ?
curl --fail-with-body --silent --show-error \
'https://kardilo.com/api/v1/catalog/sets' \
-H "Authorization: Bearer ${KARDILO_ACCESS_TOKEN}"
Un statut 401 signifie que le jeton a été refusé. Consultez l’authentification avant de réessayer. Une session de collectionneur ne donne pas accès à ce catalogue.