-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
# gw2api | ||
|
||
TypeScript first packages to work with the Guild Wars 2 API | ||
|
||
- [`@gw2api/types`](./packages/types/): Strong types for all data structures used by the Guild Wars 2 API | ||
- [`@gw2api/fetch`](./packages/fetch/): Tiny wrapper around fetch that returns type-safe responses. | ||
- [`@gw2api/client`](./packages/client/): High level abstraction to access the Guild Wars 2 API with support for automatic batching, middlewares, caching, rate-limiting and more. | ||
|
||
|
||
## Contributing | ||
|
||
1. Clone this repository or [make a fork](https://docs.github.com/en/github/getting-started-with-github/quickstart/fork-a-repo) if you plan to submit your changes. | ||
2. Run `npm install` to install the required dependencies. | ||
3. Make your changes. | ||
4. Run `npm run test` to test your changes (make sure to include new tests if you add new functionality). | ||
4. Commit the changes to a new branch and push them to your fork. | ||
5. Create a new [Pull Request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests). | ||
|
||
|
||
## License | ||
|
||
Licensed under the [MIT License](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 darthmaim | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# `@gw2api/client` | ||
|
||
This package provies a high level abstraction to access the Guild Wars 2 API in a typesafe way. | ||
|
||
## Usage | ||
|
||
> [!WARNING] | ||
> This package is still highly Work In Progress and the API might change drastically in the first few versions. | ||
|
||
```ts | ||
import { Gw2ApiClient } from '@gw2api/client'; | ||
|
||
const client = new Gw2ApiClient(); | ||
|
||
// get the first 10 items in german | ||
const items = await client.items.lang('de').page(0, 10); | ||
// -> Array<{ id: number, name: string, ... }> | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm i @gw2api/client | ||
``` | ||
|
||
## Contributing | ||
|
||
See [parent readme](../../README.md#contributing). | ||
|
||
## License | ||
|
||
Licensed under the [MIT License](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 darthmaim | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# `@gw2api/fetch` | ||
|
||
This package provides a tiny wrapper around native fetch to call the Guild Wars 2 API that returns typesafe responses. | ||
|
||
## Usage | ||
|
||
```ts | ||
import { fetchGw2Api } from '@gw2api/fetch'; | ||
|
||
const item = await fetchGw2Api('/v2/items/1234'); | ||
// -> { id: number, name: string, ... } | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm i @gw2api/fetch | ||
``` | ||
|
||
## Contributing | ||
|
||
See [parent readme](../../README.md#contributing). | ||
|
||
## License | ||
|
||
Licensed under the [MIT License](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 darthmaim | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# `@gw2api/types` | ||
|
||
TypeScript types for all datastructures used by the Guild Wars 2 API. | ||
|
||
## Usage | ||
|
||
You can use this library to add strong types when working with the Guild Wars 2 API and not using `@gw2api/fetch` or `@gw2api/client`, for example when using your own api client, working with data from a database, or writing helper functions. | ||
|
||
```ts | ||
import type { Gw2Api, EndpointType } from '@gw2api/types'; | ||
|
||
function getItemName(item: Gw2Api.V2.Item) { | ||
return item.name; | ||
} | ||
|
||
type ItemEndpointResponse = EndpointType<'/v2/items?ids=1,2,3'>; | ||
// -> Array<{ id: number, name: string, ... }> | ||
``` | ||
|
||
## Installation | ||
|
||
```sh | ||
npm i @gw2api/types | ||
``` | ||
|
||
## Contributing | ||
|
||
See [parent readme](../../README.md#contributing). | ||
|
||
## License | ||
|
||
Licensed under the [MIT License](./LICENSE). |