Webhooks Introduction
Webhooks provide real-time data delivery from Scrapest to your endpoints, allowing you to receive Twitter/X data instantly without continuous polling.What Are Webhooks?
Webhooks are automated HTTP callbacks that send data to your specified URL when events occur. Instead of repeatedly asking Scrapest for new data, webhooks push data to you as soon as it’s available.Key Benefits
Real-Time Delivery
- Instant Updates: Receive data immediately when events occur
- No Polling: Eliminate the need for continuous API requests
- Reduced Latency: Get data faster than polling-based approaches
Efficiency
- Resource Savings: Reduce server load and bandwidth usage
- Cost Effective: Lower API usage and infrastructure costs
- Scalable: Handle high-volume data streams efficiently
Reliability
- Event-Driven: Reliable event delivery with retry mechanisms
- Persistent: Automatic retry on delivery failures
- Monitoring: Built-in delivery status tracking
Webhook Events
Tweet Events
- New Tweets: Real-time delivery of new tweets matching your criteria
- Tweet Updates: Updates to existing tweets (likes, retweets, replies)
- User Mentions: Tweets mentioning specific users or keywords
User Events
- Profile Updates: Changes to user profiles and metadata
- Follower Changes: New followers or unfollow events
- User Activity: Significant user activities and status changes
System Events
- Webhook Status: Delivery success/failure notifications
- Rate Limit Alerts: When approaching API rate limits
- System Maintenance: Scheduled maintenance notifications
Webhook Lifecycle
1. Creation
- Define your webhook endpoint URL
- Configure event filters and data format
- Set up authentication and security
- Activate the webhook
2. Verification
- Scrapest sends verification request to your endpoint
- Your endpoint responds with verification token
- Webhook becomes active and verified
3. Data Delivery
- Events occur in the Scrapest system
- Webhook payload is constructed and sent to your endpoint
- Your endpoint processes the received data
- Delivery status is tracked and logged
4. Monitoring
- Monitor delivery success rates
- Track failed deliveries and retries
- Analyze performance metrics
- Optimize endpoint performance
Security Considerations
Authentication
- HMAC Signatures: Each webhook request includes cryptographic signature
- Secret Keys: Use unique secret keys for each webhook
- Timestamp Validation: Verify request freshness to prevent replay attacks
Endpoint Security
- HTTPS Required: All webhook endpoints must use HTTPS
- IP Whitelisting: Restrict webhook reception to Scrapest IP addresses
- Rate Limiting: Implement rate limiting on your endpoints
- Input Validation: Validate all incoming webhook data
Data Protection
- Encryption: All webhook data is encrypted in transit
- Data Minimization: Only send necessary data fields
- Compliance: GDPR and privacy regulation compliance
Webhook Payload Format
Standard Structure
Event Types
- tweet.created: New tweet created
- tweet.updated: Existing tweet updated
- user.updated: User profile updated
- webhook.delivery_failed: Webhook delivery failed
- webhook.verified: Webhook verification completed
Best Practices
Endpoint Design
- Fast Response: Respond quickly (under 5 seconds)
- Idempotency: Handle duplicate events gracefully
- Error Handling: Return appropriate HTTP status codes
- Async Processing: Process webhook data asynchronously
Reliability
- Retry Logic: Implement retry mechanisms for failed processing
- Logging: Log all webhook deliveries for debugging
- Monitoring: Monitor endpoint health and performance
- Backup Endpoints: Configure backup webhook URLs
Performance
- Load Balancing: Distribute webhook load across multiple servers
- Queue Processing: Use message queues for high-volume webhooks
- Database Optimization: Optimize database writes for webhook data
- Caching: Cache frequently accessed webhook data
Common Use Cases
Social Media Monitoring
- Brand Monitoring: Track mentions of your brand or products
- Competitor Analysis: Monitor competitor activities and announcements
- Influencer Tracking: Track influencer posts and engagement
Content Curation
- News Aggregation: Collect news content from specific sources
- Trend Analysis: Identify trending topics and hashtags
- Content Moderation: Monitor and moderate user-generated content
Business Intelligence
- Customer Feedback: Collect customer mentions and feedback
- Market Research: Gather market insights from social media
- Sentiment Analysis: Analyze sentiment around topics or brands
Getting Started
- Create Webhook: Use the Create Webhook endpoint
- Set Up Endpoint: Prepare your webhook endpoint to receive data
- Verify Webhook: Complete the webhook verification process
- Test Integration: Send test events to verify integration
- Monitor Performance: Track delivery success and performance
Troubleshooting
Common Issues
- SSL Certificate Problems: Ensure valid SSL certificates
- Timeout Issues: Respond quickly to webhook requests
- Authentication Failures: Verify HMAC signature validation
- Rate Limiting: Check endpoint rate limiting configuration
Debugging Tools
- Webhook Logs: Review delivery logs in the dashboard
- Test Events: Send test events to your endpoint
- Signature Validation: Use tools to verify HMAC signatures
- Network Analysis: Check network connectivity and firewall rules
Rate Limits and Quotas
Webhook Limits
- Maximum Webhooks: 50 webhooks per API key
- Delivery Rate: Up to 1000 events per minute per webhook
- Payload Size: Maximum 1MB per webhook payload
- Retry Attempts: Up to 5 retry attempts per failed delivery
Quota Management
- Monitor Usage: Track webhook usage in your dashboard
- Optimize Filters: Use specific filters to reduce unnecessary events
- Batch Processing: Process multiple events together when possible
- Upgrade Plans: Consider higher-tier plans for increased limits