How crawlbase/crawlbase-node works
Project Type Analysis
This is an API wrapper library that provides interfaces to multiple Crawlbase services. It's a dependency-free Node.js module designed for making HTTP requests to different Crawlbase API endpoints.
Main Components
A. Client Layer:
• Main API classes (CrawlingAPI, ScraperAPI, LeadsAPI, ScreenshotsAPI)
• Each class inherits from BaseAPI (visible in src/base-api.js)
B. External Service Layer:
• Crawlbase API Services
• Different endpoints for each service type
[Client Application] → [Crawlbase Node.js Library]
• ↓
• ┌──────────────────────┴───────────────────────┐
• ↓ ↓ ↓
• [Base API Layer] [Configuration Layer] [Utility Layer]
• ↓
• ┬──────────┬──────────┬─────────┐
• ↓ ↓ ↓ ↓ ↓
[Crawling API] [Scraper API] [Leads API] [Screenshots API] [Utils]
• ↓ ↓ ↓ ↓
• ┴──────────┴──────────┴─────────┐
• ↓
• [Crawlbase REST APIs]
Component Details
a) Client Layer:
• Supported HTTP methods (GET, POST, PUT)
• Promise-based async operations
• Configuration options input
b) Base API Layer:
• Common functionality shared across all API types
• Error handling mechanisms
• Request/response processing
c) Service-Specific APIs:
• CrawlingAPI: Show both normal and JavaScript token support
• ScraperAPI: Indicate JSON response handling
• LeadsAPI: Show domain-based querying
• ScreenshotsAPI: Indicate binary response handling
d) External Services:
• Connection to Crawlbase's different API endpoints
• Authentication token flow
Important Flows to Highlight
• Authentication flow using tokens
• Request transformation and handling
• Response processing and error handling
• Binary data handling (especially for Screenshots API)
Additional Elements
• Different request types (GET, POST, PUT)
• Response formats (JSON, binary, HTML)
• Authentication mechanisms
• Error handling patterns
Technical Details to Note
• That it's a dependency-free implementation
• TypeScript support (note the .d.ts files)
• Configuration options handling
• Promise-based async operations