- Identify the User ID for the User who’s events you want to filter on
- Create a subscription for the type of event you want to filter for that User
- Receive the events using webhook or persistent http stream connection
Getting User IDs
Before creating subscriptions, you’ll need to know the user ID of the account you want to filter on. In this example, we will use the XDevelopers handle. You can look up user IDs in a few of ways including: Look up a user’s ID by username:id
field, which you can use in subscription filters. Example json response is shown below:
Creating a Subscription
Next step is to create a subscription. In this example, we will subscribe to XDevelopers’s bio updates. In order to do so, we will pass theuser_id
and event_type
in the JSON body. In this case, the event_type
is ProfileBioUpdate
.
We’ll pass X Developer’s user ID: 2244994945
, and an optional tag:
Getting the events
Once we have created the subscription, we can receive the events via webhooks or a persistent HTTP stream. In this example, we will open the persistent HTTP stream:Subscription Management
The X Activity API provides endpoints to manage your subscriptions through standard CRUD operations.Create Subscription
Create a new subscription to receive events:- The
tag
field is optional. This can be used to help identify events on delivery. - The
webhook_id
field is also optional. See our webhook docs for help setting up a webhook. If awebhook_id
is specified, the event will be delivered to the provided webhook, in addition to the stream if it is open.
List Subscriptions
Retrieve all active subscriptions for your application:Delete Subscription
Remove a subscription:total_subscriptions
shows the remaining number of subscriptions associated with your app after the delete operation.
Update Subscription
The PUT endpoint allows you to update a subscription’s delivery method or tag. Updating thefilter
or event_type
requires deleting the existing subscription and adding a new one.