Skip to main content
POST
/
v1
/
twitter
/
stream
/
filter-rules
Create filter rule
curl --request POST \
  --url https://scrapebadger.com/v1/twitter/stream/filter-rules \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "tag": "AI news tracker",
  "query": "(\"artificial intelligence\" OR \"machine learning\") min_faves:100 lang:en",
  "interval_seconds": 60,
  "max_results_per_poll": 20,
  "webhook_url": "https://example.com/webhooks/filter-rules",
  "webhook_secret": "<string>"
}
'
{
  "id": "<string>",
  "tag": "AI news tracker",
  "query": "(\"artificial intelligence\" OR \"machine learning\") min_faves:100 lang:en",
  "interval_seconds": 60,
  "max_results_per_poll": 20,
  "status": "active",
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "status_reason": "<string>",
  "webhook_url": "<string>",
  "webhook_secret_set": true,
  "credits_per_rule_per_day": 123,
  "pricing_tier": "1-minute"
}

Authorizations

x-api-key
string
header
required

Your ScrapeBadger API key. You can find this in your dashboard at https://scrapebadger.com/dashboard/api-keys.

Body

application/json

Filter rule configuration.

tag
string
required

Human-readable label for the filter rule.

Required string length: 1 - 100
Example:

"AI news tracker"

query
string
required

Twitter Advanced Search query. Supports operators like from:, to:, min_faves:, lang:, etc.

Required string length: 1 - 1024
Example:

"(\"artificial intelligence\" OR \"machine learning\") min_faves:100 lang:en"

interval_seconds
number
required

Polling interval in seconds. Lower intervals detect tweets faster but cost more credits per day.

Required range: 0.1 <= x <= 86400
Example:

60

max_results_per_poll
integer
default:20

Maximum number of tweets to return per poll cycle.

Required range: 1 <= x <= 100
webhook_url
string | null

HTTPS URL to receive webhook deliveries. Must use HTTPS.

Example:

"https://example.com/webhooks/filter-rules"

webhook_secret
string | null

Secret used to sign webhook payloads with HMAC-SHA256.

Response

Filter rule created successfully.

Filter rule configuration and status.

id
string
required

Unique filter rule identifier.

tag
string
required

Human-readable label for the rule.

Example:

"AI news tracker"

query
string
required

Twitter Advanced Search query.

Example:

"(\"artificial intelligence\" OR \"machine learning\") min_faves:100 lang:en"

interval_seconds
number
required

Polling interval in seconds.

Example:

60

max_results_per_poll
integer
required

Maximum number of tweets returned per poll cycle.

Example:

20

status
enum<string>
required

Current status of the rule. Suspended indicates the rule was auto-paused due to insufficient credits.

Available options:
active,
paused,
suspended
created_at
string<date-time>
required

Timestamp when the rule was created.

updated_at
string<date-time>
required

Timestamp when the rule was last updated.

status_reason
string | null

Reason for the current status, if applicable.

webhook_url
string | null

HTTPS URL receiving webhook deliveries.

webhook_secret_set
boolean

Whether a webhook secret is configured. The actual secret is never returned.

credits_per_rule_per_day
number

Credit cost per day for this rule at the current interval.

pricing_tier
string

Current pricing tier label based on interval.

Example:

"1-minute"