스트림 규칙 업데이트
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