Skip to main content

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

  1. Define your webhook endpoint URL
  2. Configure event filters and data format
  3. Set up authentication and security
  4. Activate the webhook

2. Verification

  1. Scrapest sends verification request to your endpoint
  2. Your endpoint responds with verification token
  3. Webhook becomes active and verified

3. Data Delivery

  1. Events occur in the Scrapest system
  2. Webhook payload is constructed and sent to your endpoint
  3. Your endpoint processes the received data
  4. Delivery status is tracked and logged

4. Monitoring

  1. Monitor delivery success rates
  2. Track failed deliveries and retries
  3. Analyze performance metrics
  4. 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

{
  "id": "webhook_event_1234567890",
  "type": "tweet.created",
  "timestamp": "2024-01-15T10:30:00Z",
  "data": {
    "id": "1234567890123456789",
    "text": "This is a tweet...",
    "user": {
      "id": "987654321",
      "username": "example_user",
      "name": "Example User"
    },
    "created_at": "2024-01-15T10:30:00Z"
  },
  "signature": "sha256=5d41402abc4b2a76b9719d911017c592"
}

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

  1. Create Webhook: Use the Create Webhook endpoint
  2. Set Up Endpoint: Prepare your webhook endpoint to receive data
  3. Verify Webhook: Complete the webhook verification process
  4. Test Integration: Send test events to verify integration
  5. 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
Next: Create Webhook