BNCA provides a simple, fast API for web scraping with intelligent fallback. Get started in minutes with just two endpoints.
Sign up and create an API key in your dashboard.
You can use the API directly via HTTP or use our lightweight client.
// Using direct API call
const response = await fetch('https://bnca-api.fly.dev/scrapeurl', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key'
},
body: JSON.stringify({ url: 'https://example.com' })
});
const result = await response.json();
console.log('Success:', result.success);
console.log('Content:', result.data);
// Or using our client helper
import { createBNCAClient } from '@/lib/bnca-client';
const client = createBNCAClient('your-api-key');
const result = await client.scrape('https://example.com');
console.log('Content:', result.data);
All API requests require authentication using your API key as a Bearer token.
curl -X POST https://bnca-api.fly.dev/scrapeurl \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com"}'
The BNCA API provides intelligent web scraping with automatic fallback between Direct Fetch → Lightpanda → Puppeteer.
Main endpoint for scraping web content with intelligent fallback
{
"url": "https://example.com", // Required: URL to scrape
"screenshot": false, // Optional: Include screenshot
"question": "What is this about?" // Optional: AI question to answer
}
Fast screenshot-only endpoint
// Using fetch
const response = await fetch('https://bnca-api.fly.dev/quickshot', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key'
},
body: JSON.stringify({ url: 'https://example.com' })
});
const result = await response.json();
console.log('Screenshot:', result.screenshot); // Base64 image
{
"success": true,
"data": {
"title": "Page Title",
"content": "Main content...",
"description": "Meta description",
"headings": [...],
"links": [...],
"structuredData": {...}
},
"metadata": {
"method": "lightpanda", // Method that succeeded
"timestamp": "2024-01-01T...",
"responseTime": 1234
},
"screenshot": "data:image/png;base64,..." // If requested
}
Check API health status
const screenshot = await scraper.screenshot('https://example.com', {
width: 1920,
height: 1080,
fullPage: true,
quality: 90,
format: 'png' // 'png' or 'jpeg'
});
if (screenshot.success) {
console.log('Screenshot saved to:', screenshot.path);
console.log('Size:', screenshot.size, 'bytes');
}
Ask AI questions about webpage content
const result = await scraper.askAI(
'https://example.com',
'What is this website about?'
);
if (result.success) {
console.log('Answer:', result.answer);
console.log('Scrape method used:', result.method);
console.log('Processing time:', result.scrapeTime, 'ms');
}
// Use backend API for better AI responses
const scraper = new BNCASmartScraper({
apiKey: 'your-api-key',
apiUrl: 'https://bnca-api.fly.dev'
});
const result = await scraper.askAI(
'https://news.site.com',
'What are the top 3 headlines?'
);
Additional methods for monitoring and cleanup
// Check if all components are working
const health = await scraper.healthCheck();
console.log('Lightpanda available:', health.lightpanda);
console.log('Puppeteer available:', health.puppeteer);
// Clean up browser instances and resources
await scraper.cleanup();
// Get performance statistics
const stats = scraper.getStats();
console.log('Success rates:', stats);
Convenience functions for quick operations
import { smartScrape } from '@monostate/node-scraper';
// One-off scraping without class instantiation
const result = await smartScrape('https://example.com', {
timeout: 5000,
verbose: true
});
import { smartScreenshot, quickShot } from '@monostate/node-scraper';
// High-quality screenshot
const screenshot = await smartScreenshot('https://example.com');
// Fast screenshot for previews
const preview = await quickShot('https://example.com', {
width: 800,
height: 600
});
import { askWebsiteAI } from '@monostate/node-scraper';
// Ask AI about a webpage
const result = await askWebsiteAI(
'https://example.com',
'What services does this company offer?',
{ apiKey: 'your-api-key' }
);
console.log('Answer:', result.answer);
Extract data from any website with intelligent fallback system
{
"url": "https://example.com", // Required: URL to scrape
"screenshot": false // Optional: Take screenshot (default: false)
}
{
"success": true,
"data": {
"title": "Example Domain",
"content": "This domain is for use in illustrative examples...",
"metaDescription": "Example description",
"links": [
{
"text": "More information...",
"href": "https://www.iana.org/domains/example"
}
],
"images": [
{
"src": "https://example.com/image.jpg",
"alt": "Example image"
}
],
"structuredData": { /* JSON-LD data if found */ }
},
"metadata": {
"url": "https://example.com",
"method": "direct", // direct | lightpanda | puppeteer
"timestamp": "2024-01-01T00:00:00.000Z",
"performance": {
"totalTime": 1234
},
"screenshot": null // Base64 image if requested
}
}
const response = await fetch('https://api.bnca.monostate.ai/scrapeurl', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://news.ycombinator.com',
screenshot: true
})
});
const result = await response.json();
console.log('Page title:', result.data.title);
console.log('Extraction method:', result.metadata.method);
Get AI-powered answers about webpage content
{
"url": "https://example.com", // Required: URL to analyze
"question": "What is this page about?", // Required: Question to ask
"screenshot": false // Optional: Take screenshot
}
{
"success": true,
"answer": "This page is about domain examples used in documentation...",
"metadata": {
"url": "https://example.com",
"question": "What is this page about?",
"method": "direct",
"timestamp": "2024-01-01T00:00:00.000Z",
"performance": {
"totalTime": 2345,
"scrapeTime": 1234,
"processingTime": 1111
},
"screenshot": null
}
}
const response = await fetch('https://api.bnca.monostate.ai/aireply', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://techcrunch.com/2024/01/01/some-article',
question: 'What are the main points of this article?'
})
});
const result = await response.json();
console.log('AI Answer:', result.answer);
Both endpoints support optional screenshot capture using Puppeteer.
{
"url": "https://example.com",
"screenshot": true // Enables screenshot capture
}
Screenshots are returned as base64-encoded PNG images in the metadata.
{
"success": true,
"data": { /* ... page data ... */ },
"metadata": {
"screenshot": "iVBORw0KGgoAAAANSUhEUgAAA..." // Base64 PNG
}
}
// Convert base64 to image
const imageUrl = `data:image/png;base64,${result.metadata.screenshot}`;
// Display in HTML
document.getElementById('screenshot').src = imageUrl;
// Or save to file (Node.js)
const fs = require('fs');
const buffer = Buffer.from(result.metadata.screenshot, 'base64');
fs.writeFileSync('screenshot.png', buffer);
{
"error": "Error type",
"message": "Human readable error message"
}
400
Bad Request - Missing required parameters401
Unauthorized - Invalid/missing API key403
Forbidden - Subscription required429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorFree forever
Most popular
For high volume
Current API performance and status.