PrerequisitesBefore you begin, you’ll need:
- A developer account
- Your App’s Bearer Token (found in the Developer Console under “Keys and tokens”)
Create a filter rule
Rules define which Posts to receive. Use operators to match on keywords, hashtags, users, and more.Example rule: Match Posts containing “cat” with images:
Build a rule
Learn rule syntax and operators
Add the rule to your stream
Add your rule using the rules endpoint. Include a Response:
tag to identify which rule matched each Post:cURL
Verify your rules
List all active rules to confirm your rule was added:
cURL
Connect to the stream
Open a persistent connection to receive matching Posts:
cURL
Process incoming Posts
Matching Posts stream as JSON objects:
Delete rules (optional)
Remove rules by their ID:
cURL
Managing your connection
Keep-alive signals
Keep-alive signals
The stream sends blank lines (
\r\n) every 20 seconds. If you don’t receive data or a keep-alive for 20 seconds, reconnect.Disconnecting
Disconnecting
Press
Ctrl+C to close the connection, or close your terminal window.Connection limits
Connection limits
Only one connection per App is allowed. Opening a new connection will close any existing one.