@wynnjs/api 3.0.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/LICENSE +21 -0
- package/README.md +159 -0
- package/dist/index.cjs +1804 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2862 -0
- package/dist/index.d.ts +2862 -0
- package/dist/index.js +1699 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# @wynnjs/api
|
|
2
|
+
|
|
3
|
+
TypeScript client for the [Wynncraft API v3](https://docs.wynncraft.com/). Covers all public v3 endpoints with typed request options and response shapes.
|
|
4
|
+
|
|
5
|
+
Version `3.0.0` is the client release. This package implements [Wynncraft API v3](https://docs.wynncraft.com/) release **`3.7.2`** — see `WYNNCRAFT_API_VERSION` from the package.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @wynnjs/api zod
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires TypeScript 5+ (or any runtime that can consume `.d.ts` files). Ships ESM and CommonJS builds.
|
|
14
|
+
|
|
15
|
+
`zod` is a peer dependency — the client uses it for error parsing and exports schemas for optional response validation. npm 7+, pnpm, and Bun install peers automatically; add `zod` explicitly if your package manager does not.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { WynnClient } from "@wynnjs/api";
|
|
21
|
+
|
|
22
|
+
const client = new WynnClient();
|
|
23
|
+
const { data, rateLimit } = await client.classes.list();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Every method returns `{ data, rateLimit }` where `rateLimit` is parsed from Wynncraft headers when present. Response and options types are exported from the package — use editor hover or `import type { ... } from "@wynnjs/api"` for full shapes.
|
|
27
|
+
|
|
28
|
+
For endpoint behaviour and response fields, see the [Wynncraft API docs](https://docs.wynncraft.com/). This README lists client methods; JSDoc on `WynnClient` and module methods covers params and options.
|
|
29
|
+
|
|
30
|
+
### Authentication
|
|
31
|
+
|
|
32
|
+
Pass `auth` when constructing the client. Supports API tokens, OAuth access tokens, and session cookies via the `WynnAuth` union.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
const client = new WynnClient({
|
|
36
|
+
auth: { type: "token", token: process.env.WYNN_API_TOKEN! },
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Endpoints like `client.player.whoAmI()` and `client.oauth.me()` require auth. See [`examples/auth-token.ts`](./examples/auth-token.ts).
|
|
41
|
+
|
|
42
|
+
### Errors
|
|
43
|
+
|
|
44
|
+
Failed API responses throw `WynnApiError` subclasses (`NotFound`, `Forbidden`, `TooManyRequest`, `MultipleObjectsReturned`, etc.). See [`examples/errors.ts`](./examples/errors.ts).
|
|
45
|
+
|
|
46
|
+
## API reference
|
|
47
|
+
|
|
48
|
+
`client.<module>.<method>()`. Path parameters come first, options second. Some options are presence-only flags (`fullResult`, `full_result`, `static`) — pass them in the options object and the client sends the flag without a value.
|
|
49
|
+
|
|
50
|
+
### Player (`client.player`)
|
|
51
|
+
|
|
52
|
+
| Method | Description |
|
|
53
|
+
| -------------------------------------------------------------- | ------------------------------------- |
|
|
54
|
+
| `client.player.listOnlinePlayers(options?)` | Online player list |
|
|
55
|
+
| `client.player.whoAmI()` | Authenticated profile (auth required) |
|
|
56
|
+
| `client.player.getPlayer(username, options?)` | Player profile by username |
|
|
57
|
+
| `client.player.listCharacters(username)` | Characters for a player |
|
|
58
|
+
| `client.player.getCharacterAbilities(username, characterUuid)` | Ability assignments for a character |
|
|
59
|
+
|
|
60
|
+
### OAuth (`client.oauth`)
|
|
61
|
+
|
|
62
|
+
| Method | Description |
|
|
63
|
+
| ------------------------------------- | -------------------------------------- |
|
|
64
|
+
| `client.oauth.me()` | OAuth user identity (auth required) |
|
|
65
|
+
| `client.oauth.exchangeToken(options)` | Exchange authorization code for tokens |
|
|
66
|
+
|
|
67
|
+
### Guild (`client.guild`)
|
|
68
|
+
|
|
69
|
+
| Method | Description |
|
|
70
|
+
| ------------------------------------------------- | -------------------- |
|
|
71
|
+
| `client.guild.listGuilds(options?)` | Guild list |
|
|
72
|
+
| `client.guild.listTerritories()` | Guild territories |
|
|
73
|
+
| `client.guild.listSeasons()` | Guild season history |
|
|
74
|
+
| `client.guild.getGuild(name, options?)` | Guild by name |
|
|
75
|
+
| `client.guild.getGuildByPrefix(prefix, options?)` | Guild by tag prefix |
|
|
76
|
+
| `client.guild.getGuildByUuid(uuid, options?)` | Guild by UUID |
|
|
77
|
+
|
|
78
|
+
### Item (`client.item`)
|
|
79
|
+
|
|
80
|
+
| Method | Description |
|
|
81
|
+
| ----------------------------------------------- | ------------------------------------ |
|
|
82
|
+
| `client.item.listItems(options?)` | Item database |
|
|
83
|
+
| `client.item.searchItems(filters?, options?)` | Structured item search |
|
|
84
|
+
| `client.item.quickSearchItems(query)` | Quick item name search |
|
|
85
|
+
| `client.item.listRecipes(options?)` | Recipe database |
|
|
86
|
+
| `client.item.searchRecipes(filters?, options?)` | Structured recipe search |
|
|
87
|
+
| `client.item.getMetadata(options?)` | Item filter and metadata definitions |
|
|
88
|
+
| `client.item.listSets()` | Item sets |
|
|
89
|
+
|
|
90
|
+
### Ability (`client.ability`)
|
|
91
|
+
|
|
92
|
+
| Method | Description |
|
|
93
|
+
| ---------------------------------- | ------------------------ |
|
|
94
|
+
| `client.ability.getTree(tree)` | Ability tree for a class |
|
|
95
|
+
| `client.ability.getMap(tree)` | Ability map for a class |
|
|
96
|
+
| `client.ability.listAspects(tree)` | Aspects for a class tree |
|
|
97
|
+
|
|
98
|
+
### Classes (`client.classes`)
|
|
99
|
+
|
|
100
|
+
| Method | Description |
|
|
101
|
+
| ------------------------------------ | -------------------- |
|
|
102
|
+
| `client.classes.list()` | All playable classes |
|
|
103
|
+
| `client.classes.getClass(className)` | Class metadata |
|
|
104
|
+
|
|
105
|
+
### Map (`client.map`)
|
|
106
|
+
|
|
107
|
+
| Method | Description |
|
|
108
|
+
| ------------------------------------ | ------------------------- |
|
|
109
|
+
| `client.map.listPlayerLocations()` | Live player map locations |
|
|
110
|
+
| `client.map.listMarkers()` | Map markers |
|
|
111
|
+
| `client.map.listWorldEvents()` | Active world events |
|
|
112
|
+
| `client.map.listCamps(options?)` | Camps |
|
|
113
|
+
| `client.map.listRaids(options?)` | Raids |
|
|
114
|
+
| `client.map.listLootPools(options?)` | Loot pools |
|
|
115
|
+
| `client.map.listGatheringNodes()` | Gathering nodes |
|
|
116
|
+
| `client.map.getQuestCount()` | Quest completion counts |
|
|
117
|
+
|
|
118
|
+
### Search (`client.search`)
|
|
119
|
+
|
|
120
|
+
| Method | Description |
|
|
121
|
+
| --------------------------------------- | ------------- |
|
|
122
|
+
| `client.search.search(query, options?)` | Global search |
|
|
123
|
+
|
|
124
|
+
### Leaderboards (`client.leaderboards`)
|
|
125
|
+
|
|
126
|
+
| Method | Description |
|
|
127
|
+
| ------------------------------------------- | --------------------------- |
|
|
128
|
+
| `client.leaderboards.listTypes()` | Available leaderboard types |
|
|
129
|
+
| `client.leaderboards.get(lbType, options?)` | Leaderboard entries |
|
|
130
|
+
|
|
131
|
+
### News (`client.news`)
|
|
132
|
+
|
|
133
|
+
| Method | Description |
|
|
134
|
+
| ------------------------------------------------- | -------------------------- |
|
|
135
|
+
| `client.news.fetchArticle(articleType, pk)` | Single publisher article |
|
|
136
|
+
| `client.news.listArticles(articleType, options?)` | Publisher articles by type |
|
|
137
|
+
| `client.news.listVideos()` | Publisher videos |
|
|
138
|
+
| `client.news.listLatestNews()` | Latest news feed |
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
Runnable scripts live in [`examples/`](./examples/). Run with `bun run examples/basic.ts` from the repo root.
|
|
143
|
+
|
|
144
|
+
| File | Module |
|
|
145
|
+
| ------------------------------------------------------- | --------------------------- |
|
|
146
|
+
| [`basic.ts`](./examples/basic.ts) | classes |
|
|
147
|
+
| [`player.ts`](./examples/player.ts) | player |
|
|
148
|
+
| [`auth-token.ts`](./examples/auth-token.ts) | player (API token) |
|
|
149
|
+
| [`oauth.ts`](./examples/oauth.ts) | oauth |
|
|
150
|
+
| [`guild-and-search.ts`](./examples/guild-and-search.ts) | search, guild, leaderboards |
|
|
151
|
+
| [`item-search.ts`](./examples/item-search.ts) | item |
|
|
152
|
+
| [`map.ts`](./examples/map.ts) | map |
|
|
153
|
+
| [`news.ts`](./examples/news.ts) | news |
|
|
154
|
+
| [`ability.ts`](./examples/ability.ts) | ability |
|
|
155
|
+
| [`errors.ts`](./examples/errors.ts) | error handling |
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|