Welcome to the AI Chatbot API documentation. This API allows you to integrate our advanced AI chatbot into your applications with ease. By sending a simple POST request with your API key and the user's query, you can receive intelligent responses from our AI.
To get started, you'll need an API key. If you haven't obtained one yet, please sign up on our platform to receive your unique API key.
Send your requests to this endpoint:
https://api.aichatbotcreator.com/chatYour POST request should include a JSON body with the following structure:
{ "query": "Your user's question goes here", "api_key": "Your_API_Key_Here" }
Using fetch API in vanilla JavaScript
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>AI Chatbot Demo</title> </head> <body> <h1>AI Chatbot Demo</h1> <input type="text" id="userInput" placeholder="Ask a question..."> <button onclick="sendQuery()">Send</button> <div id="response"></div> <script> async function sendQuery() { const userInput = document.getElementById('userInput').value; const apiKey = 'Your_API_Key_Here'; try { const response = await fetch('https://api.aichatbotcreator.com/chat', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query: userInput, api_key: apiKey }) }); const data = await response.json(); document.getElementById('response').innerText = data.response; } catch (error) { console.error('Error:', error); document.getElementById('response').innerText = 'An error occurred'; } } </script> </body> </html>
The API will respond with a JSON object containing the AI's response:
{
"response": "The AI-generated response to the user's query"
}In case of an error, the API will return an appropriate HTTP status code along with a JSON object containing an error message:
{
"error": "Description of the error"
}Common error codes:
To ensure fair usage and maintain service quality, we implement rate limiting on our API. The current limits are:
If you exceed these limits, you'll receive a 429 Too Many Requests response. Please contact our support team if you need higher limits for your use case.
To test the API and see it in action, visit our interactive API testing page:
Go to API Testing Page