Operating Modes
The SDK supports three operating modes for different use cases.
Hybrid Mode (Default)
Automatically switches between scraping and API:
typescript
const client = new XTwitterClient({
mode: 'hybrid',
preferredMode: 'crawler' // Try scraping first
});1
2
3
4
2
3
4
Best for: Flexibility and reliability
API Mode
Uses only the official Twitter API:
typescript
const client = new XTwitterClient({
mode: 'api'
});1
2
3
2
3
Best for: Guaranteed compatibility, write operations
Crawler Mode
Uses only web scraping:
typescript
const client = new XTwitterClient({
mode: 'crawler'
});1
2
3
2
3
Best for: Read-only operations, higher volume
Choosing a Mode
| Mode | Read Operations | Write Operations | Fallback |
|---|---|---|---|
| Hybrid | Scraping → API | API | Yes |
| API | API | API | No |
| Crawler | Scraping | Not supported | No |
Next Steps
- Configuration - Configure each mode
- Error Handling - Handle mode-specific errors