X API の返信非表示エンドポイントの比較
コード例
返信を非表示にする (v2)
cURL
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
| 説明 | Labs v2 | X API v2 |
|---|---|---|
| ホストドメイン | https://api.x.com | https://api.x.com |
| エンドポイントパス | /labs/2/tweets/:id/hidden | /2/tweets/:id/hidden |
| 認証方式 | OAuth 1.0a User context | OAuth 1.0a User context |
| サポートされる HTTP メソッド | PUT | PUT |
| デフォルトのレート制限 | 15 分あたり 10 リクエスト (すべての認証済みユーザーで共有) | 15 分あたり 50 リクエスト (認証済みユーザーごと) |
| 返信を非表示にできる | ✔︎ | ✔︎ |
| 以前に非表示にした返信を再表示できる | ✔︎ | ✔︎ |
| 返信の非表示/再表示を複数回行える | ✔︎ | ✔︎ |
| project に関連付けられた developer App の認証情報を使用する必要がある | ✔ |
curl -X PUT "https://api.x.com/2/tweets/1234567890/hidden" \
-H "Authorization: OAuth ..." \
-H "Content-Type: application/json" \
-d '{"hidden": true}'
# OAuth 1.0a のユーザーコンテキストによる認証が必要です
import requests
from requests_oauthlib import OAuth1
auth = OAuth1(
"API_KEY", "API_SECRET",
"ACCESS_TOKEN", "ACCESS_TOKEN_SECRET"
)
url = "https://api.x.com/2/tweets/1234567890/hidden"
response = requests.put(url, auth=auth, json={"hidden": True})
print(response.json())
from xdk import Client
from xdk.oauth1_auth import OAuth1
oauth1 = OAuth1(
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
access_token="YOUR_ACCESS_TOKEN",
access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
)
client = Client(auth=oauth1)
# 返信を非表示にする
response = client.posts.hide_reply("1234567890", hidden=True)
print(f"Hidden: {response.data.hidden}")
import { Client, OAuth1 } from "@xdevplatform/xdk";
const oauth1 = new OAuth1({
apiKey: "YOUR_API_KEY",
apiSecret: "YOUR_API_SECRET",
accessToken: "YOUR_ACCESS_TOKEN",
accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
});
const client = new Client({ oauth1 });
// 返信を非表示にする
const response = await client.posts.hideReply("1234567890", { hidden: true });
console.log(`Hidden: ${response.data?.hidden}`);