ani-client 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,23 +1,24 @@
1
- # ani-client
1
+ # ani-client
2
2
 
3
+ ![ani-client logo](docs/public/assets/logo.png)
3
4
  [![CI](https://github.com/gonzyui/ani-client/actions/workflows/ci.yml/badge.svg)](https://github.com/gonzyui/ani-client/actions/workflows/ci.yml)
4
5
  [![npm](https://img.shields.io/npm/v/ani-client)](https://www.npmjs.com/package/ani-client)
5
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
7
 
7
8
  > A simple, typed client to fetch anime, manga, character, staff and user data from [AniList](https://anilist.co).
8
9
 
9
- ✨ **Showcase**: [Check here](https://docs-aniclient.gonzyuidev.xyz/showcase) to see which projects use this package!
10
+ ✨ **Showcase**: [Check here](https://gonzyuidev.xyz/projects/aniclient/showcase) to see which projects use this package!
10
11
 
11
12
  - **Zero dependencies** — uses the native `fetch` API
12
13
  - **Universal** — Node.js ≥ 20, Bun, Deno and modern browsers
13
14
  - **Dual format** — ships ESM + CJS with full TypeScript declarations
14
- - **Reliable** — Built-in caching, Rate-limit protections, automatic retries & request deduplication!
15
+ - **Reliable** — Built-in caching, Rate-limit protections with exponential backoff, automatic retries & request deduplication!
15
16
 
16
17
  ## 📖 Documentation
17
18
 
18
19
  The full API reference, usage guide, and configuration examples are available on our official documentation website!
19
20
 
20
- **[👉 View the full documentation here](https://docs-aniclient.gonzyuidev.xyz/)**
21
+ **[👉 View the full documentation here](https://gonzyuidev.xyz/projects/aniclient/)**
21
22
 
22
23
  ## Install
23
24
 
@@ -55,6 +56,43 @@ const results = await client.searchMedia({
55
56
  console.log(results.results.map((m) => m.title.english));
56
57
  ```
57
58
 
59
+ ### Fetch user favorites
60
+
61
+ ```ts
62
+ const favs = await client.getUserFavorites("AniList");
63
+
64
+ favs.anime.forEach((a) => console.log(a.title.romaji));
65
+ favs.characters.forEach((c) => console.log(c.name.full));
66
+ ```
67
+
68
+ ### Monitor rate limits
69
+
70
+ ```ts
71
+ const client = new AniListClient({
72
+ rateLimit: {
73
+ retryStrategy: (attempt) => (attempt + 1) * 1000, // linear backoff
74
+ },
75
+ });
76
+
77
+ await client.getMedia(1);
78
+
79
+ const info = client.rateLimitInfo;
80
+ console.log(`${info?.remaining}/${info?.limit} requests remaining`);
81
+
82
+ const meta = client.lastRequestMeta;
83
+ console.log(`${meta?.durationMs}ms, cache: ${meta?.fromCache}`);
84
+ ```
85
+
86
+ ### Cancel requests
87
+
88
+ ```ts
89
+ const controller = new AbortController();
90
+ const client = new AniListClient({ signal: controller.signal });
91
+
92
+ setTimeout(() => controller.abort(), 5_000);
93
+ await client.getMedia(1); // aborted after 5s
94
+ ```
95
+
58
96
  ## Contributing
59
97
 
60
98
  See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, coding standards, and how to submit changes.