| title | Error Handling |
|---|---|
| description | Understanding and handling ScrapeGraphAI API errors |
All API errors follow a simple format:
{
"error": "Detailed error message"
}Indicates that the request was malformed or invalid.
```json { "error": "Invalid URL format" } ``` The request contains invalid parameters. ```json { "error": "Invalid schema format" } ``` The provided output schema is invalid or malformed. ```json { "error": "Invalid HTML content" } ``` Applies to SmartScraper when the provided HTML is invalid.Authentication-related errors.
```json { "error": "Invalid API key" } ``` The API key is invalid, revoked, or not provided. ```json { "error": "Insufficient credits" } ``` Your account doesn't have enough credits to perform the operation.Rate limiting errors.
```json { "error": "Too many requests" } ``` You've exceeded the rate limit. Wait before retrying.Internal server errors.
```json { "error": "An error occurred while processing your request" } ``` An unexpected error occurred while processing the request. ```json { "error": "Service temporarily unavailable" } ``` The service is temporarily unavailable. Try again later. Our SDKs implement automatic retries for certain errors. For direct API usage, implement your own retry logic.-
Retryable Errors
- Rate limit exceeded (429)
- Service unavailable (500, 503)
- Network timeouts
-
Non-Retryable Errors
- Invalid parameters (400)
- Authentication errors (401)
- Invalid schemas (400)
import { extract } from 'scrapegraph-js';
const result = await extract('your-api-key', {
url: 'https://example.com',
prompt: 'Extract data',
});
if (result.status === 'success') {
console.log('Data:', result.data);
} else {
console.error('Error:', result.error);
}If you encounter any errors not documented here or need assistance:
Get help from our community Contact our technical team