guildwars2-ts 1.0.1

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 ADDED
@@ -0,0 +1,16 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2022 Ivan Sosnov
4
+ Copyright (c) 2021 Julio Sansossio (parts of request base code)
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted, provided that the above
8
+ copyright notice and this permission notice appear in all copies.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Typescript API Wrapper for Guild Wars 2
2
+
3
+ ## Plans
4
+ - Conditional type validation for several endpoints
5
+ - Data caching for repeated requests
6
+ - Better logging
7
+ - Support for different schemas, when available
8
+
9
+ ## Available Endpoints (Guild Wars 2)
10
+
11
+ Full support of all endpoints listed in the [API:2 Wiki](https://wiki.guildwars2.com/wiki/API:2) page
12
+
13
+
14
+ ## Request Example
15
+
16
+ ```typescript
17
+ import { GW2Api, ApiLanguage } from "guildwars2-ts";
18
+
19
+ const api: GW2Api = new GW2Api({
20
+ // Token is not required for all of the endpoints
21
+ token: "YOUR-TOKEN-HERE",
22
+ language: ApiLanguage.English,
23
+ rateLimit: {
24
+ retry: true,
25
+ attempts: 3,
26
+ },
27
+ });
28
+
29
+ (async () => {
30
+ // Obtain names of all characters on the account
31
+ await api.account.get().then(console.log);
32
+ // Obtain details about each of them
33
+ await api.characters.get().then((characters) => {
34
+ characters.forEach(async (character) => {
35
+ await api.characters.getCore(character).then(console.log);
36
+ });
37
+ });
38
+ })();
39
+ ```