便利なツール
Postman
コードサンプル
サードパーティ製ライブラリ
基本概念
認証
開発者コンソール、プロジェクト、および開発者 App
レート制限
ソースラベル
プロフィール設定
ポストへのメディアの追加
コードサンプル
ポストを作成
cURL
返信を作成
cURL
ポストを削除する
cURL
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: OAuth ..." \
-H "Content-Type: application/json" \
-d '{"text": "Hello world!"}'
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.create(text="Hello world!")
print(f"Created Post: {response.data.id}")
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.create({ text: "Hello world!" });
console.log(`Created Post: ${response.data?.id}`);
curl -X POST "https://api.x.com/2/tweets" \
-H "Authorization: OAuth ..." \
-H "Content-Type: application/json" \
-d '{"text": "これは返信です!", "reply": {"in_reply_to_tweet_id": "1234567890"}}'
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.create(
text="これは返信です!",
reply={"in_reply_to_tweet_id": "1234567890"}
)
print(f"Created reply: {response.data.id}")
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.create({
text: "これは返信です!",
reply: { inReplyToTweetId: "1234567890" },
});
console.log(`Created reply: ${response.data?.id}`);
curl -X DELETE "https://api.x.com/2/tweets/1234567890" \
-H "Authorization: OAuth ..."
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.delete("1234567890")
print(f"Deleted: {response.data.deleted}")
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.delete("1234567890");
console.log(`Deleted: ${response.data?.deleted}`);