Magicode logo
Magicode
3 min read

【Bluesky Social】APIの使い方

https://cdn.magicode.io/media/notebox/7d7ef8aa-c7ed-408a-8fbb-331ff37038fd.jpeg
Bluesky SocialでのAPIの使い方をまとめてみました。随時更新予定です

ベースURL

https://bsky.social/xrpc

エンドポイント一覧

getActorFeeds

自身の投稿を取得するエンドポイント
◼️パラメータ
プロパティ詳細
actorstringハンドルネームを入力する
limitintmin: 1, max: 100 default: 50
◼️レスポンス
プロパティ詳細
cursorstring
feedsarray

基本的な使い方(Python)

def get_author_feed(self, access_jwt):
        base_url = "https://bsky.social/xrpc"
        endpoint = "app.bsky.feed.getAuthorFeed"
        url = f"{base_url}/{endpoint}"

        params = {"actor": identifier}
        headers = {"Authorization": f"Bearer {access_jwt}"}
        response = requests.get(url, params=params, headers=headers)

        response_json = response.json()
        print(response_json)

レスポンス例

{
    "feed": [
        {
            "post": {
                "uri": "",
                "cid": "",
                "author": {
                    "did": "",
                    "handle": "amatyrain.bsky.social",
                    "displayName": "あまてぃ",
                    "avatar": "",
                    "viewer": {
                        "muted": False,
                        "blockedBy": False
                    },
                    "labels": []
                },
                "record": {
                    "text": "テスト",
                    "$type": "app.bsky.feed.post",
                    "langs": [
                        "ja"
                    ],
                    "createdAt": "2023-11-18T10:42:49.198Z"
                },
                "replyCount": 0,
                "repostCount": 0,
                "likeCount": 1,
                "indexedAt": "2023-11-18T10:42:49.198Z",
                "viewer": {},
                "labels": []
            }
        }
    ],
    "cursor": ""
}

createRecord

投稿用のエンドポイント
詳細は以下参照

Discussion

コメントにはログインが必要です。