Documentation Index
Fetch the complete documentation index at: https://generaltranslation.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
यह मार्गदर्शिका आपको रीयल-टाइम खाता गतिविधि ईवेंट प्राप्त करने के लिए activity stream सदस्यताएँ सेट अप करने की प्रक्रिया से परिचित कराती है।
पूर्वापेक्षाएँशुरू करने से पहले, आपके पास ये होने चाहिए:
सदस्यता बनाएँ
किसी उपयोगकर्ता की गतिविधि से जुड़े ईवेंट की सदस्यता लें:curl -X POST "https://api.x.com/2/activity/subscriptions" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"user_id": "2244994945",
"event_types": ["tweet_create_events", "favorite_events", "follow_events"]
}'
import requests
bearer_token = "YOUR_BEARER_TOKEN"
url = "https://api.x.com/2/activity/subscriptions"
headers = {
"Authorization": f"Bearer {bearer_token}",
"Content-Type": "application/json"
}
payload = {
"user_id": "2244994945",
"event_types": ["tweet_create_events", "favorite_events", "follow_events"]
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
प्रतिक्रिया:{
"data": {
"id": "1234567890",
"user_id": "2244994945",
"event_types": ["tweet_create_events", "favorite_events", "follow_events"],
"created_at": "2024-01-15T10:00:00.000Z"
}
}
स्ट्रीम से कनेक्ट करें
ईवेंट प्राप्त करने के लिए एक स्थायी कनेक्शन खोलें:curl "https://api.x.com/2/activity/stream" \
-H "Authorization: Bearer $BEARER_TOKEN"
import requests
bearer_token = "YOUR_BEARER_TOKEN"
url = "https://api.x.com/2/activity/stream"
headers = {"Authorization": f"Bearer {bearer_token}"}
response = requests.get(url, headers=headers, stream=True)
for line in response.iter_lines():
if line:
print(line.decode("utf-8"))
आने वाले ईवेंट प्रोसेस करें
ईवेंट JSON ऑब्जेक्ट के रूप में स्ट्रीम होते हैं:{
"for_user_id": "2244994945",
"event_type": "tweet_create_events",
"created_at": "2024-01-15T10:30:00.000Z",
"tweet_create_events": [
{
"id": "1234567890",
"text": "Hello from the stream!",
"author_id": "2244994945"
}
]
}
| Event | विवरण |
|---|
tweet_create_events | उपयोगकर्ता नई पोस्ट करता है |
favorite_events | उपयोगकर्ता किसी पोस्ट को लाइक करता है |
follow_events | उपयोगकर्ता किसी को फ़ॉलो करता है या कोई उसे फ़ॉलो करता है |
direct_message_events | उपयोगकर्ता DM भेजता है या प्राप्त करता है |
block_events | उपयोगकर्ता ब्लॉक या अनब्लॉक करता है |
mute_events | उपयोगकर्ता म्यूट या अनम्यूट करता है |
सभी सक्रिय सदस्यताएँ प्राप्त करें:curl "https://api.x.com/2/activity/subscriptions" \
-H "Authorization: Bearer $BEARER_TOKEN"
किसी सदस्यता को अपडेट करें
किसी सदस्यता को हटाएँ:curl -X DELETE "https://api.x.com/2/activity/subscriptions/1234567890" \
-H "Authorization: Bearer $BEARER_TOKEN"
Account Activity API
Webhook-आधारित वैकल्पिक तरीका
API संदर्भ
एंडपॉइंट का पूरा दस्तावेज़ीकरण