API Documentation
Integrate PromptSearch API's AI-powered data analysis capabilities into your applications using our RESTful API.
Authentication
All API requests require authentication using an API token. Include your token in the Authorization header of every request.
Your API Token
You don't have an API token yet.
Sign in to generate your token.
Using Your Token
Authorization: Bearer YOUR_API_TOKEN
Security Notice
Keep your API token secure. Don't expose it in client-side code or public repositories. Anyone with your token can access your PromptSearch API account and data.
API Endpoints
PromptSearch API provides the following endpoints for programmatic access to your data analysis capabilities.
Base URL
https://yourdomain.com/api
Available Endpoints
1. Query Data
Ask questions about your uploaded data files using natural language.
Parameters
Name | Type | Required | Description |
---|---|---|---|
fileId |
string | Required | The unique identifier of the uploaded file |
question |
string | Required | Natural language question about your data |
apiToken |
string | Required | Your API authentication token |
2. Upload File
Upload CSV files for analysis. Requires form-data with Authorization header.
Parameters
Name | Type | Required | Description |
---|---|---|---|
file |
file | Required | CSV file to upload (max 10MB) |
displayName |
string | Optional | Display name for the file |
3. List Files
Retrieve a list of all uploaded files with metadata.
4. Delete File
Delete a specific uploaded file by its ID.
Code Examples
Here are practical examples showing how to use the PromptSearch API in different programming languages.
cURL Example
curl -X POST https://yourdomain.com/api/api-query \
-H "Content-Type: application/json" \
-d '{
"fileId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"question": "Which customer did I sell tanzanite to",
"apiToken": "your-api-token-here"
}'
Python Example
import requests
url = "https://yourdomain.com/api/api-query"
headers = {"Content-Type": "application/json"}
data = {
"fileId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"question": "Which customer did I sell tanzanite to",
"apiToken": "your-api-token-here"
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
print(result)
JavaScript Example
const query = async () => {
const response = await fetch('https://yourdomain.com/api/api-query', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
fileId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
question: 'Which customer did I sell tanzanite to',
apiToken: 'your-api-token-here'
})
});
const data = await response.json();
console.log(data);
};
Response Example
Success Response (200 OK)
{
"success": true,
"data": [
{
"customer_name": "John Smith",
"product": "Tanzanite Ring",
"sale_date": "2024-01-15",
"amount": 2500.00
}
],
"resultCount": 1,
"executionTime": 150
}
File Upload Example
# Using cURL to upload a file
curl -X POST https://yourdomain.com/api/upload \
-H "Authorization: Bearer your-api-token-here" \
-F "file=@your-data.csv" \
-F "displayName=My Sales Data"
Error Handling
PromptSearch API uses standard HTTP status codes to indicate the success or failure of requests.
HTTP Status Codes
Status Code | Meaning | Description |
---|---|---|
200 |
OK | Request successful |
400 |
Bad Request | Invalid request parameters |
401 |
Unauthorized | Invalid or missing API token |
404 |
Not Found | File or resource not found |
429 |
Too Many Requests | Rate limit exceeded |
500 |
Internal Server Error | Server error, try again later |
Error Response Format
Error Response
{
"success": false,
"error": "Invalid file ID",
"code": "INVALID_FILE_ID",
"timestamp": "2024-01-15T10:30:00Z"
}
Common Error Codes
Error Code | Description | Solution |
---|---|---|
INVALID_TOKEN |
API token is invalid or expired | Generate a new API token |
INVALID_FILE_ID |
File ID does not exist | Check your file ID or upload the file |
RATE_LIMIT_EXCEEDED |
Too many requests in a short time | Wait before making more requests |
FILE_TOO_LARGE |
Uploaded file exceeds size limit | Reduce file size to under 10MB |
Rate Limiting
Rate Limits
The API has the following rate limits:
- Query requests: 60 requests per minute
- File uploads: 10 uploads per minute
- Token generation: 5 requests per minute
Rate limit information is included in response headers.