AI Chatbot API Documentation

Introduction

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.

API Endpoint

POST Request URL

Send your requests to this endpoint:

https://api.aichatbotcreator.com/chat

Request Format

Your POST request should include a JSON body with the following structure:

{
  "query": "Your user's question goes here",
  "api_key": "Your_API_Key_Here"
}

Implementation Examples

HTML/JavaScript Example

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>

Response Format

The API will respond with a JSON object containing the AI's response:

{
  "response": "The AI-generated response to the user's query"
}

Error Handling

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:

Rate Limiting

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.

Best Practices

Testing the API

To test the API and see it in action, visit our interactive API testing page:

Go to API Testing Page