API Documentation
Complete guide to using the FishGPT Chat API endpoint
Overview
The FishGPT Chat API is a powerful endpoint that provides AI-powered fishing advice by combining multiple data sources including YouTube videos, Amazon products, Tackle.net products, and weather data.
Endpoint: POST /api/chat
Response: Streaming (Server-Sent Events)
Max Duration: 200 seconds
Request Format
Request Body (JSON)
{
"question": "string", // Required: The fishing question
"enabledTools": { // Optional: Control which tools to use
"weather": boolean, // Default: false
"shop": boolean, // Default: true (Amazon products)
"youtube": boolean, // Default: true
"tackle": boolean // Default: false (Tackle.net products)
},
"imageUrl": "string" // Optional: Base64 or URL for image analysis
}Parameters
question
string • Required
The fishing-related question you want answered. The API will reject non-fishing questions.
enabledTools
object • Optional
Controls which external data sources to use. If not provided, defaults to shop, youtube, and tackle enabled.
- weather: Fetch weather data for mentioned locations
- shop: Search for relevant Amazon fishing products
- youtube: Find related fishing tutorial videos
- tackle: Search Tackle.net for fishing gear
imageUrl
string • Optional
Base64-encoded image or image URL for visual analysis. Use this to get advice about specific fish, gear, or fishing locations shown in photos.
Response Format
The API returns a streaming response with two types of events: progress updates and the final structured response.
Progress Updates
Real-time progress updates are sent as Server-Sent Events (SSE) in the format: data: {JSON}
{
"progress": {
"type": "youtube_search" | "amazon_search" | "weather_search" | "ai_processing" | "image_generation",
"message": "string",
"status": "started" | "completed" | "error",
"timestamp": number,
"chat_id": "string" // Only present in final completion
}
}Final Response (Streamed)
The AI response is streamed as structured JSON:
{
"chat_id": "string", // Unique ID for this conversation
"question": "string", // The original question (formatted)
"answer": "string", // Markdown-formatted answer (250-700 words)
"category": "string", // Category classification
"geo_data": { // Location data (if mentioned)
"location_name": "string", // Full location name with context
"latitude": number, // Latitude coordinate
"longitude": number, // Longitude coordinate
"location_type": "lake" | "river" | "ocean" | "pond" | "stream" | "bay" | "creek" | "reservoir" | "general" | null
}
}
// The complete response stored in database also includes:
{
"youtube_videos": Array, // YouTube video recommendations
"amazon_products": Array, // Amazon products with affiliate tags
"tackle_products": Array, // Tackle.net products
"conversation": Array // Full conversation history
}Note: All amazon_products URLs include affiliate tags automatically. See the Amazon Affiliate Links section below for details.
Example Usage
Basic Request
fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
question: 'What are the best lures for bass fishing in summer?'
})
})
.then(response => {
const reader = response.body.getReader();
const decoder = new TextDecoder();
function readStream() {
reader.read().then(({ done, value }) => {
if (done) {
console.log('Stream complete');
return;
}
const chunk = decoder.decode(value);
console.log('Received:', chunk);
readStream();
});
}
readStream();
});Request with Custom Tools
fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
question: 'What tackle should I use for trout fishing in Lake Tahoe?',
enabledTools: {
weather: false, // Enable weather data
shop: true, // Enable Amazon products
youtube: true, // Enable YouTube videos
tackle: false // Enable Tackle.net products
}
})
});Request with Image Analysis
// Convert image to base64
const imageInput = document.querySelector('input[type="file"]');
const file = imageInput.files[0];
const reader = new FileReader();
reader.onload = async (e) => {
const base64Image = e.target.result;
const response = await fetch('/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
question: 'What species is this fish and how should I catch it?',
imageUrl: base64Image
})
});
};
reader.readAsDataURL(file);How It Works
1Question Processing
The API generates search queries from your question and validates it's fishing-related.
2Parallel Data Fetching
Simultaneously searches YouTube, Amazon, Tackle.net, and weather APIs (based on enabled tools). Progress updates are sent in real-time. Amazon product URLs are automatically tagged with affiliate parameters for commission tracking.
3AI Analysis
OpenAI GPT-5-nano analyzes all data sources and your question (and image if provided) to generate a comprehensive fishing guide response.
4Response Streaming
The answer is streamed back token-by-token for faster perceived response times.
5Database Storage
The complete conversation is saved to the database with generated images, location data, and categorization for future reference.
Response Categories
Responses are automatically categorized into one of these categories:
Amazon Affiliate Links
⚠️ Important: Affiliate Tag Requirement
All Amazon product links returned by the API include the current affiliate URL tag. These links are automatically formatted with the proper affiliate tracking parameters.
What This Means
- Product URLs are pre-tagged: All Amazon product links in the
amazon_productsarray include the affiliate tag parameter. - No modification needed: You can use the product URLs directly without adding additional parameters.
- Tracking enabled: Purchases made through these links will be tracked for affiliate commission purposes.
Example Product Object
{
"title": "Fishing Rod Combo Kit",
"price": "$49.99",
"rating": 4.5,
"reviews": 1234,
"image": "https://m.media-amazon.com/images/I/example.jpg",
"url": "https://amazon.com/dp/B08EXAMPLE?tag=youraffid-20", // ← Includes affiliate tag
"asin": "B08EXAMPLE"
}Compliance Notes
- FTC Disclosure: If you display these product links to end users, you must include appropriate affiliate disclosure statements per FTC guidelines.
- Amazon Associates Terms: Use of these links must comply with Amazon Associates Program Operating Agreement.
- Link Integrity: Do not modify or remove the affiliate tag from the URLs provided by the API.
Error Handling
Non-Fishing Questions
If your question isn't fishing-related, you'll receive: "Sorry, I only answer fishing questions."
API Failures
If external APIs (YouTube, Amazon, etc.) fail, the endpoint continues with available data. Weather data has a 3-second timeout to prevent blocking.
Stream Interruption
If the stream is interrupted, you'll receive a progress update with status: "error"
Best Practices
- ✓Ask specific fishing-related questions for best results
- ✓Include location information for weather and geo-specific advice
- ✓Disable unused tools to improve response time
- ✓Handle both progress updates and final response in your stream reader
- ✓Implement proper error handling for network issues
- ✗Don't send extremely long questions (keep under 500 characters)
- ✗Don't send non-fishing questions (they'll be rejected)
Technical Details
Model
GPT-5-nano (OpenAI)
Max Duration
200 seconds (Vercel limit)
Response Length
250-700 words (markdown formatted)
Streaming Format
Server-Sent Events (SSE)
Need help? Questions about the API? Contact support.