Twitter API v2
  1. Tweets
Twitter API v2
  • General
    • Returns the open api spec document.
      GET
  • Tweets
    • Tweet lookup by Tweet IDs
      GET
    • Full archive search counts
      GET
    • Recent search counts
      GET
    • Sample stream
      GET
    • Full-archive search
      GET
    • Recent search
      GET
    • Filtered stream
      GET
    • Rules lookup
      GET
    • Add/Delete rules
      POST
    • Tweet lookup by Tweet ID
      GET
    • Hide replies
      PUT
    • Returns Tweet objects liked by the provided User ID
      GET
    • Causes the user (in the path) to like the specified tweet
      POST
    • Causes the user (in the path) to unlike the specified tweet
      DELETE
    • User mention timeline by User ID
      GET
    • Causes the user (in the path) to retweet the specified tweet
      POST
    • Causes the user (in the path) to unretweet the specified tweet
      DELETE
    • User Tweets timeline by User ID
      GET
  • Users
    • Returns user objects that have liked the provided Tweet ID
      GET
    • Returns user objects that have retweeted the provided Tweet ID
      GET
    • User lookup by IDs
      GET
    • User lookup by usernames
      GET
    • User lookup by username
      GET
    • User lookup by ID
      GET
    • Returns user objects that are blocked by provided user ID
      GET
    • Block User by User ID
      POST
    • Returns user objects that follow the provided user ID
      GET
    • Following by User ID
      GET
    • Follow User
      POST
    • Mute User by User ID
      POST
    • Unblock User by User ID
      DELETE
    • Unfollow User
      DELETE
    • Unmute User by User ID
      DELETE
  1. Tweets

Add/Delete rules

POST
/2/tweets/search/stream/rules
Tweets
Add or delete rules from a user's active rule set. Users can provide unique, optionally tagged rules to add. Users can delete their entire rule set or a subset specified by rule ids or values.
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.twitter.com/2/tweets/search/stream/rules' \
--header 'Content-Type: application/json' \
--data-raw '{
    "add": [
        {
            "tag": "Non-retweeted coffee tweets",
            "value": "coffee -is:retweet"
        }
    ]
}'
响应示例响应示例
200 - 示例 1
{
    "data": [
        {
            "id": "120897978112909812",
            "tag": "Non-retweeted coffee tweets",
            "value": "coffee -is:retweet"
        }
    ],
    "meta": {
        "sent": "string",
        "summary": {
            "created": 1,
            "invalid": 1,
            "not_created": 1,
            "valid": 1
        }
    }
}

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Query 参数
dry_run
可选
Dry Run can be used with both the add and delete action, with the expected result given, but without actually taking any action in the system (meaning the end state will always be as it was when the request was submitted). This is particularly useful to validate rule changes.
Body 参数application/json
AddOrDeleteRulesRequest
可选
One of
A request to add a user-specified stream filtering rule.
add
array[object (RuleNoId) {2}] 
必需
示例

返回响应

🟢200The request was successful
application/json
Body
AddOrDeleteRulesResponse
可选
One of
A response from adding user-specified stream filtering rules.
data
array[object (Rule) {3}] 
必需
All user-specified stream filtering rules that were created.
meta
object 
RulesResponseMetadata
必需
🔴500500
上一页
Rules lookup
下一页
Tweet lookup by Tweet ID
Built with