Buffer
認証管理付きでBuffer GraphQL APIにアクセスします。Instagram、Facebook、Twitter、LinkedIn、TikTokなどのソーシャルメディアプラットフォームをまたいで投稿をスケジュール・管理します。
クイックスタート
# 組織を含むアカウント情報を取得
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": "query { account { id email organizations { id name } } }"
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
ベースURL
https://gateway.maton.ai/buffer/
Bufferは単一のGraphQLエンドポイントを使用します。すべてのクエリとミューテーションはPOSTリクエストとしてこのエンドポイントに送信されます。
認証
すべてのリクエストは、AuthorizationヘッダーにMaton APIキーを必要とします:
Authorization: Bearer $MATON_API_KEY
環境変数: APIキーを MATON_API_KEY として設定します:
export MATON_API_KEY="YOUR_API_KEY"
APIキーの取得
- maton.ai にサインインまたはアカウントを作成します
- maton.ai/settings に移動します
- APIキーをコピーします
接続管理
Bufferの接続は https://ctrl.maton.ai で管理します。
接続一覧
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=buffer&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
接続作成
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'buffer'}).encode()
req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
接続取得
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
応答:
{
"connection": {
"connection_id": "a71282a3-52be-473d-9273-22b4546dc146",
"status": "ACTIVE",
"creation_time": "2026-03-12T00:18:28.327860Z",
"last_updated_time": "2026-03-12T00:18:42.818009Z",
"url": "https://connect.maton.ai/?session_token=...",
"app": "buffer",
"metadata": {},
"method": "API_KEY"
}
}
接続削除
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
接続の指定
複数のBuffer接続がある場合は、Maton-Connection ヘッダーで使用する接続を指定します:
python <<'EOF'
import urllib.request, os, json
data = json.dumps({"query": "query { account { id } }"}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
req.add_header('Maton-Connection', 'a71282a3-52be-473d-9273-22b4546dc146')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
省略した場合、ゲートウェイはデフォルト(最も古い)アクティブな接続を使用します。
APIリファレンス
アカウント取得
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
query {
account {
id
email
name
avatar
timezone
createdAt
preferences {
timeFormat
startOfWeek
}
}
}
"""
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
応答:
{
"data": {
"account": {
"id": "69846f7479b75e6487fa3482",
"email": "[email protected]",
"name": "John Doe",
"avatar": "https://...",
"timezone": "America/New_York",
"createdAt": "2024-01-15T10:30:00Z",
"preferences": {
"timeFormat": "12h",
"startOfWeek": "sunday"
}
}
}
}
組織取得
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
query {
account {
organizations {
id
name
channels {
id
name
service
avatar
isDisconnected
}
}
}
}
"""
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
応答:
{
"data": {
"account": {
"organizations": [
{
"id": "69846f7479b75e6487fa3484",
"name": "My Organization",
"channels": [
{
"id": "channel123",
"name": "My Twitter",
"service": "twitter",
"avatar": "https://...",
"isDisconnected": false
}
]
}
]
}
}
}
チャンネル取得
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
query GetChannels($organizationId: OrganizationId!) {
channels(organizationId: $organizationId) {
id
name
service
displayName
avatar
timezone
isDisconnected
isQueuePaused
postingSchedule {
days
times
}
}
}
""",
"variables": {
"organizationId": "69846f7479b75e6487fa3484"
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
単一チャンネル取得
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
query GetChannel($channelId: ChannelId!) {
channel(channelId: $channelId) {
id
name
service
displayName
avatar
timezone
postingSchedule {
days
times
}
postingGoal {
postsPerWeek
progress
}
}
}
""",
"variables": {
"channelId": "channel123"
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
投稿一覧
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
query GetPosts($channelId: ChannelId!, $status: PostStatus, $first: Int) {
posts(channelId: $channelId, status: $status, first: $first) {
edges {
node {
id
text
status
createdAt
dueAt
sentAt
channelService
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
""",
"variables": {
"channelId": "channel123",
"status": "scheduled",
"first": 10
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
投稿ステータス値:
draft- 下書きとして保存scheduled- 公開予定sent- 公開済みfailed- 公開失敗
単一投稿取得
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
query GetPost($postId: PostId!) {
post(id: $postId) {
id
text
status
createdAt
dueAt
sentAt
author {
name
email
}
channel {
id
name
service
}
assets {
id
url
type
}
}
}
""",
"variables": {
"postId": "post123"
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
投稿作成
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
mutation CreatePost($input: CreatePostInput!) {
createPost(input: $input) {
... on Post {
id
text
status
dueAt
}
... on InvalidInputError {
message
}
... on UnauthorizedError {
message
}
}
}
""",
"variables": {
"input": {
"channelId": "channel123",
"text": "Buffer APIからのこんにちは!",
"schedulingType": "scheduled",
"dueAt": "2026-03-15T14:00:00Z",
"mode": "queue"
}
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
CreatePostInput フィールド:
channelId(必須): ターゲットチャンネルIDtext: 投稿内容schedulingType(必須): "scheduled"、"draft"、"now" のいずれかdueAt: 予約投稿用のISO 8601日時mode(必須): "queue" または "share"assets: メディア添付tagIds: コンテンツタグmetadata: プラットフォーム固有のオプション(プラットフォームメタデータセクション参照)ideaId: 既存のアイデアにリンクdraftId: 既存の下書きから作成source: 投稿の起源aiAssisted: AIがコンテンツ作成を支援したかどうかsaveToDraft: スケジュールではなく下書きとして保存
Instagramメタデータ付き投稿作成
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
mutation CreatePost($input: CreatePostInput!) {
createPost(input: $input) {
... on Post { id text status }
... on InvalidInputError { message }
}
}
""",
"variables": {
"input": {
"channelId": "instagram_channel_id",
"text": "最新の投稿をチェック! #photography",
"schedulingType": "scheduled",
"dueAt": "2026-03-15T14:00:00Z",
"mode": "queue",
"metadata": {
"instagram": {
"type": "post",
"firstComment": "フォローしてね!",
"shouldShareToFeed": True
}
}
}
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Twitterスレッド作成
python <<'EOF'
import urllib.request, os, json
data = json.dumps({
"query": """
mutation CreatePost($input: CreatePostInput!) {
createPost(input: $input) {
... on Post { id text status }
... on InvalidInputError { message }
}
}
""",
"variables": {
"input": {
"channelId": "twitter_channel_id",
"text": "スレッドの最初のツイート",
"schedulingType": "scheduled",
"dueAt": "2026-03-15T14:00:00Z",
"mode": "queue",
"metadata": {
"twitter": {
"thread": [
{"text": "スレッドの2番目のツイート"},
{"text": "スレッドの3番目のツイート"}
]
}
}
}
}
}).encode()
req = urllib.request.Request('https://gateway.maton.ai/buffer/', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
リンク付きLinkedIn投稿作成
python <<'EOF'