REST API

Documentation complète de l'API REST AskIA pour créer des intégrations personnalisées.

L'API est accessible à askiabot.com/api

Authentification

Pour l'instant, l'API widget publique ne nécessite pas d'authentification. Les endpoints protégés nécessiteront un token JWT (bientôt disponible).

Endpoints Disponibles

POST/api/widget/chat

Envoyer un message au bot

Envoyez un message à un bot et recevez une réponse générée par IA.

Corps de la Requête

ParameterTypeDescription
botIdrequired
stringL'identifiant unique du bot
messagerequired
stringLe message de l'utilisateur
conversationId
stringID de conversation pour maintenir le contexte

Exemple de Requête

fetch('askiabot.com/api/widget/chat', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    botId: 'YOUR_BOT_ID',
    message: 'What are your pricing plans?',
    conversationId: 'optional-conversation-id'
  })
})
  .then(res => res.json())
  .then(data => console.log(data))

Réponse

{
  "reply": "We offer three pricing plans: Free, Pro ($29/month), and Enterprise (custom pricing)...",
  "conversationId": "conv_abc123",
  "messageId": "msg_xyz789"
}
GET/api/bots/:id

Obtenir les informations du bot

Récupérez les métadonnées et la configuration du bot.

Paramètres URL

ParameterTypeDescription
idrequired
stringL'identifiant du bot

Exemple de Requête

fetch('askiabot.com/api/bots/YOUR_BOT_ID')
  .then(res => res.json())
  .then(data => console.log(data))

Réponse

{
  "id": "bot_abc123",
  "name": "Customer Support Assistant",
  "description": "Helps customers with product questions",
  "category": "support",
  "language": "en",
  "createdAt": "2025-01-15T10:00:00Z"
}
GET/api/bots/:id/branding

Obtenir le branding du bot

Récupérez les paramètres de personnalisation visuelle du bot.

Réponse

{
  "primaryColor": "#6366f1",
  "backgroundColor": "#ffffff",
  "textColor": "#1f2937",
  "logoUrl": "https://example.com/logo.png",
  "position": "bottom-right",
  "theme": "light"
}

Codes d'Erreur

ParameterTypeDescription
400
Bad RequestParamètres manquants ou invalides
404
Not FoundBot introuvable
429
Too Many RequestsLimite de débit dépassée
500
Internal Server ErrorErreur serveur
L'API est en bêta. Les endpoints peuvent évoluer. Consultez cette documentation régulièrement pour les mises à jour.

Limites de Débit

Les limites suivantes s'appliquent à l'API publique :

  • Plan gratuit : 100 requêtes/heure
  • Plan Pro : 1 000 requêtes/heure
  • Plan Enterprise : Personnalisé