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>"
}Actualizar reglas de transmisión
Agrega o elimina reglas del conjunto de reglas activas para el stream filtrado.
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>"
}Autorizaciones
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Parámetros de consulta
Dry Run puede utilizarse tanto con la acción de agregar como con la de eliminar; devuelve el resultado esperado, pero sin ejecutar realmente ninguna acción en el sistema (es decir, que el estado final siempre será el mismo que cuando se envió la solicitud). Esto es especialmente útil para validar cambios en las reglas.
Delete All puede utilizarse para eliminar todas las reglas asociadas a esta App; se debe especificar sin ningún otro parámetro. Una vez eliminadas, las reglas no se pueden recuperar.
Cuerpo
- Option 1
- Option 2
Una solicitud para agregar una regla de filtrado de flujo definida por el usuario.
Show child attributes
Show child attributes
Respuesta
La solicitud se ha completado correctamente.
Respuesta a la modificación de reglas de filtrado de flujo definidas por el usuario.
Show child attributes
Show child attributes
Todas las reglas de filtrado de flujo definidas por el usuario que se han creado.
Show child attributes
Show child attributes
1Un objeto HTTP Problem Details, tal como se define en el IETF RFC 7807 (https://tools.ietf.org/html/rfc7807).
- 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