Yay! API client SDK
Project description
Yay! の API を Python から扱うための非公式 SDK です。
インストール
pip install yaylib
対応バージョン: Python 3.10 / 3.11 / 3.12 / 3.13
クイックスタート
import asyncio
import yaylib
async def main():
# `async with` で接続が自動的にクローズされます
async with yaylib.Client() as client:
# ログイン(セッションは透過的にキャッシュされます)
await client.login_with_email(email="...", password="...")
# タイムラインを取得
timeline = await client.get_timeline(
noreply_mode=yaylib.NoreplyMode.EMPTY, number=20
)
for post in timeline.posts:
print(post.id, post.text)
# 投稿する
await client.create_post(
x_jwt=client.generate_x_jwt(),
post_type="text",
text="hello from yaylib",
)
asyncio.run(main())
すべてのオペレーションは client.<operation> として直接呼び出せます。
イベントストリーム
async with client.open_event_stream() as stream:
sub = stream.subscribe(yaylib.chat_room_channel())
# 新着メッセージを受信
@sub.on_new_message
async def _(event):
print("new message:", event)
await sub.wait_closed()
サンプル
実行できるサンプルを examples/ に用意しています(全言語共通)。
- 認証 + タイムライン取得
- テキスト投稿
- イベントストリームの簡単なボット
- セッション永続化とエラー処理
YAY_EMAIL=... YAY_PASSWORD=... python examples/python/timeline.py
⚖️ ライセンス
MIT © ekkx
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yaylib-2.2.0.tar.gz
(272.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
yaylib-2.2.0-py3-none-any.whl
(868.3 kB
view details)
File details
Details for the file yaylib-2.2.0.tar.gz.
File metadata
- Download URL: yaylib-2.2.0.tar.gz
- Upload date:
- Size: 272.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec45b9a8cb5dcd2ba34dc1bf1ea6b4e107fc030c187d0a6cfc0274d3fa055ac7
|
|
| MD5 |
828aeef20adbf02edac20f0fb230e60b
|
|
| BLAKE2b-256 |
686d73119ba0d60dad9e2332421129fa67ea2079e6a868a2e3cd6fe3b25b9b45
|
File details
Details for the file yaylib-2.2.0-py3-none-any.whl.
File metadata
- Download URL: yaylib-2.2.0-py3-none-any.whl
- Upload date:
- Size: 868.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f609069ff70ea757579b6213b562243fa335dacb48d31d6298886d2da8fe11c7
|
|
| MD5 |
50dcce3713655699fa7e26242ba33fcd
|
|
| BLAKE2b-256 |
d8b55349d75cabd794f69ccd66b6763dd13863e42ef8d0fbb8795406efb2daa1
|