@@ -9,9 +9,14 @@ Misskey API Core is a Dart/Flutter package that provides the core building block
99### Key Features
1010
1111- HTTP foundation: base URL handling (/api), timeouts, idempotent retries (429/5xx/network), request/response logging (debug-only)
12+ - Base URL exposure: access original base URL via ` client.baseUrl ` for derived services
1213- Auth token injection: automatically injects ` i ` into POST JSON bodies when ` authRequired ` is true
14+ - Flexible token providers: support both sync and async token sources via ` FutureOr<String?> `
1315- Unified error: normalize Misskey error response to ` MisskeyApiException(statusCode/code/message) `
16+ - Customizable error handling: map exceptions via ` exceptionMapper ` for unified error policies
17+ - Flexible logging: use ` loggerFn ` for function-style logging or existing ` Logger ` interface
1418- Meta capability: ` /api/meta ` client with a tiny cache and ` supports() ` helper
19+ - Meta refresh: force-refresh cached meta data with ` getMeta(refresh: true) `
1520- JSON serialization: ` json_serializable ` -ready common model(s)
1621
1722### Install
@@ -20,7 +25,7 @@ Add to `pubspec.yaml`:
2025
2126``` yaml
2227dependencies :
23- misskey_api_core : ^0.0.1 -beta
28+ misskey_api_core : ^0.0.2 -beta
2429` ` `
2530
2631Then:
@@ -41,18 +46,24 @@ void main() async {
4146 timeout: const Duration(seconds: 10),
4247 enableLog: true, // logs only in debug mode
4348 ),
44- tokenProvider: () async => 'YOUR_TOKEN',
49+ tokenProvider: () async => 'YOUR_TOKEN', // or sync: () => 'TOKEN'
4550 );
4651
4752 // Fetch meta (no auth)
4853 final meta = await MetaClient(client).getMeta();
54+
55+ // Force refresh meta data
56+ final freshMeta = await MetaClient(client).getMeta(refresh: true);
4957
5058 // Example POST (token `i` will be injected automatically)
5159 final res = await client.send<List<dynamic>>(
5260 '/notes/timeline',
5361 body: {'limit': 10},
5462 options: const RequestOptions(idempotent: true),
5563 );
64+
65+ // Access base URL for derived services (e.g., streaming)
66+ final origin = client.baseUrl;
5667}
5768```
5869
@@ -73,9 +84,14 @@ Misskey API Core は、Misskeyサーバーと連携するためのDart/Flutter
7384### 機能
7485
7586- HTTP基盤: ベースURL(/api付与)・タイムアウト・冪等時の自動リトライ(429/5xx/ネットワーク)・デバッグ時のみログ
87+ - ベースURL公開: ` client.baseUrl ` で元URLにアクセス(派生サービス用)
7688- 認証: POSTのJSONボディに ` i ` を自動注入(` authRequired ` で制御)
89+ - 柔軟なトークン供給: 同期・非同期両方に対応(` FutureOr<String?> ` )
7790- 共通例外: Misskeyのエラーを ` MisskeyApiException(statusCode/code/message) ` に正規化
91+ - カスタマイズ可能な例外処理: ` exceptionMapper ` で例外を一元変換
92+ - 柔軟なログ出力: 関数ベースロガー(` loggerFn ` )または既存Logger IF
7893- メタ/能力検出: ` /api/meta ` の取得と簡易キャッシュ、` supports() ` ヘルパー
94+ - メタ更新: ` getMeta(refresh: true) ` でキャッシュを強制更新
7995- JSONシリアライズ: ` json_serializable ` 対応の共通モデル
8096
8197### インストール
@@ -84,7 +100,7 @@ Misskey API Core は、Misskeyサーバーと連携するためのDart/Flutter
84100
85101``` yaml
86102dependencies :
87- misskey_api_core : ^0.0.1 -beta
103+ misskey_api_core : ^0.0.2 -beta
88104` ` `
89105
90106実行:
@@ -104,18 +120,24 @@ final client = MisskeyHttpClient(
104120 timeout: const Duration(seconds: 10),
105121 enableLog: true, // デバッグ時のみ
106122 ),
107- tokenProvider: () async => 'YOUR_TOKEN',
123+ tokenProvider: () async => 'YOUR_TOKEN', // または同期: () => 'TOKEN'
108124);
109125
110126// 認証不要
111127final meta = await MetaClient(client).getMeta();
112128
129+ // メタデータを強制更新
130+ final freshMeta = await MetaClient(client).getMeta(refresh: true);
131+
113132// 読み取り系POST(`i`は自動注入)
114133final list = await client.send<List<dynamic>>(
115134 '/notes/timeline',
116135 body: {'limit': 10},
117136 options: const RequestOptions(idempotent: true),
118137);
138+
139+ // 派生サービス用にベースURLにアクセス(例: ストリーミング)
140+ final origin = client.baseUrl;
119141```
120142
121143サンプルアプリ(` /example ` )では、` misskey_auth ` を使った認証、ノート投稿、ホームタイムライン、フォロー中/フォロワーの取得まで一通り確認できます。
0 commit comments