ストリームルールを更新
curl --request POST \
--url https://api.x.com/2/tweets/search/stream/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"add": [
{
"value": "coffee -is:retweet",
"tag": "Non-retweeted coffee Posts"
}
]
}
'import requests
url = "https://api.x.com/2/tweets/search/stream/rules"
payload = { "add": [
{
"value": "coffee -is:retweet",
"tag": "Non-retweeted coffee Posts"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({add: [{value: 'coffee -is:retweet', tag: 'Non-retweeted coffee Posts'}]})
};
fetch('https://api.x.com/2/tweets/search/stream/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.x.com/2/tweets/search/stream/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'add' => [
[
'value' => 'coffee -is:retweet',
'tag' => 'Non-retweeted coffee Posts'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.x.com/2/tweets/search/stream/rules"
payload := strings.NewReader("{\n \"add\": [\n {\n \"value\": \"coffee -is:retweet\",\n \"tag\": \"Non-retweeted coffee Posts\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.x.com/2/tweets/search/stream/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"add\": [\n {\n \"value\": \"coffee -is:retweet\",\n \"tag\": \"Non-retweeted coffee Posts\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/tweets/search/stream/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"add\": [\n {\n \"value\": \"coffee -is:retweet\",\n \"tag\": \"Non-retweeted coffee Posts\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"sent": "<string>",
"next_token": "<string>",
"result_count": 123,
"summary": {
"created": 1,
"invalid": 1,
"not_created": 1,
"valid": 1
}
},
"data": [
{
"value": "coffee -is:retweet",
"id": "120897978112909812",
"tag": "Non-retweeted coffee Posts"
}
],
"errors": [
{
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"status": 123
}
]
}{
"code": 123,
"message": "<string>"
}フィルタ済みストリーム
ストリームルールを更新
フィルタ済みストリームのアクティブなルールセットに対して、ルールの追加または削除を行います。
POST
/
2
/
tweets
/
search
/
stream
/
rules
ストリームルールを更新
curl --request POST \
--url https://api.x.com/2/tweets/search/stream/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"add": [
{
"value": "coffee -is:retweet",
"tag": "Non-retweeted coffee Posts"
}
]
}
'import requests
url = "https://api.x.com/2/tweets/search/stream/rules"
payload = { "add": [
{
"value": "coffee -is:retweet",
"tag": "Non-retweeted coffee Posts"
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({add: [{value: 'coffee -is:retweet', tag: 'Non-retweeted coffee Posts'}]})
};
fetch('https://api.x.com/2/tweets/search/stream/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.x.com/2/tweets/search/stream/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'add' => [
[
'value' => 'coffee -is:retweet',
'tag' => 'Non-retweeted coffee Posts'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.x.com/2/tweets/search/stream/rules"
payload := strings.NewReader("{\n \"add\": [\n {\n \"value\": \"coffee -is:retweet\",\n \"tag\": \"Non-retweeted coffee Posts\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.x.com/2/tweets/search/stream/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"add\": [\n {\n \"value\": \"coffee -is:retweet\",\n \"tag\": \"Non-retweeted coffee Posts\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.x.com/2/tweets/search/stream/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"add\": [\n {\n \"value\": \"coffee -is:retweet\",\n \"tag\": \"Non-retweeted coffee Posts\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"meta": {
"sent": "<string>",
"next_token": "<string>",
"result_count": 123,
"summary": {
"created": 1,
"invalid": 1,
"not_created": 1,
"valid": 1
}
},
"data": [
{
"value": "coffee -is:retweet",
"id": "120897978112909812",
"tag": "Non-retweeted coffee Posts"
}
],
"errors": [
{
"title": "<string>",
"type": "<string>",
"detail": "<string>",
"status": 123
}
]
}{
"code": 123,
"message": "<string>"
}承認
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
クエリパラメータ
Dry Run は追加および削除の両方のアクションで使用でき、想定される結果がレスポンスとして返されますが、システム上では実際には何も処理されません(つまり、リクエスト送信時点から最終的な状態は変化しません)。これはルール変更を検証する際に特に有用です。
Delete All は、このクライアント App に紐づくすべてのルールを削除するために使用できます。他のパラメータは一切指定せずに使用する必要があります。一度削除されたルールは復元できません。
ボディ
application/json
レスポンス
リクエストは成功しました。
ユーザー定義ストリームフィルタリングルールを変更した際のレスポンス。
Show child attributes
Show child attributes
作成されたすべてのユーザー定義ストリームフィルタリングルール。
Show child attributes
Show child attributes
Minimum array length:
1IETF RFC 7807 (https://tools.ietf.org/html/rfc7807) で定義された HTTP Problem Details オブジェクト。
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
- Option 8
- Option 9
- Option 10
- Option 11
- Option 12
- Option 13
- Option 14
- Option 15
- Option 16
- Option 17
- Option 18
Show child attributes
Show child attributes
⌘I