Camel API Quickstart Guide
Step-by-step guide to getting started with the Camel API, including iframe generation, data sources, knowledge base entries, and reference queries.
Camel API Quickstart Guide
This guide will walk you through the essential steps to get started with the Camel API, focusing on iframe generation, data sources, knowledge base entries, and reference queries.
Prerequisites
- Access to the Camel web console
- Basic understanding of REST APIs
- A database or data source to connect
Step 1: Generate an API Key
First, you’ll need an API key to authenticate your requests.
- Log in to the Camel web console
- Navigate to API keys section
- Click “Create New API Key”
- Copy and securely store your API key - you won’t be able to see it again!
Important: All API requests must include your API key in the Authorization header:
Step 2: Connect a Data Source
You can connect a data source either through the web console or via API.
Option A: Using the Web Console (Recommended for first-time setup)
- Navigate to the Data Sources section
- Click “Add Data Source”
- Select your database type (PostgreSQL, MySQL, Snowflake, etc.)
- Fill in the connection details
- Test the connection
- Save the data source
Option B: Using the API
You can use the unified endpoint to add any supported data source type via API.
Example for adding a PostgreSQL data source:
The response will include your source ID:
Step 3: Add Knowledge Base Entries (Recommended)
Knowledge base entries provide context about your data that helps Camel generate better responses.
You can add knowledge base entries either through the web console (recommended for first-time setup, just like adding data sources) or via the API.
Step 4: Add Reference Queries (Recommended)
Reference queries are pre-written SQL queries that can be used as examples or templates.
You can add reference queries through the web console (recommended for first-time setup, just like adding data sources) or via the API.
Step 5: Generate an Iframe
Now you’re ready to create an iframe that your users can interact with. The iframe provides a chat interface where users can ask questions about the connected data.
Understanding UIDs
The uid
(user identifier) is a crucial concept:
- It can be any string but should be unique for each of your users
- All iframes generated with the same
uid
share conversation history - Use your application’s user ID, email, or any unique identifier
- This allows users to continue conversations across different sessions
Creating an Iframe
Note: The
knowledge_base_entries
andreference_queries
parameters in this API call allow you to provide temporary knowledge base entries and reference queries that will only exist for the duration of the iframe session. They are not saved to your persistent knowledge base or reference query list. If you want to add permanent entries, use the web console or the dedicated API endpoints.
Parameters:
uid
: Unique identifier for the user (required)srcs
: Array of data source IDs (optional, defaults to all sources)ttl
: Time-to-live in seconds, 60-3600 (optional, default: 900)knowledge_base_entries
: Additional context (optional)reference_queries
: Example queries (optional)
Response:
Step 6: Embed the Iframe
Add the iframe to your application:
React Example
Best Practices
- UID Management: Use consistent UIDs for each user to maintain conversation history
- TTL Settings: Balance between security (shorter TTL) and user experience (longer TTL)
- Knowledge Base: Add comprehensive knowledge base entries to improve response quality
- Reference Queries: Include common queries your users might need
- Error Handling: Always implement proper error handling for API calls
- Security: Never expose your API key in client-side code
Next Steps
- Explore the full API documentation for advanced features
- Set up webhooks for real-time notifications
- Implement custom styling for the iframe
- Use the chat API directly for more control over the conversation flow
Troubleshooting
Common Issues
- 401 Unauthorized: Check your API key is correctly formatted in the Authorization header
- 404 Not Found: Verify the endpoint URL and source IDs
- Iframe not loading: Ensure the iframe URL hasn’t expired (check TTL)
- No data returned: Verify your data source connection and permissions
Support
For additional help:
- API Documentation: https://docs.camel.ai
- Support Email: [email protected]
- Community Forum: https://community.camel.ai