Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thedrone7/shieldbow

An all-purpose league of legends API Client.
https://github.com/thedrone7/shieldbow

hacktoberfest league-of-legends nodejs npm typescript

Last synced: about 18 hours ago
JSON representation

An all-purpose league of legends API Client.

Awesome Lists containing this project

README

        

# shieldbow (v2)

An all-purpose, easy-to-use API wrapper for the league of legends API





npm version
npm downloads
Tests status
code coverage


> The code in the repository is for the unpublished, work in progress version (v3) of shieldbow.

> The published version (v2) is available for use on npm.

---

### Installing

Node.JS 16 or higher is recommended.

Install using
```
npm install shieldbow

yarn add shieldbow

pnpm add shieldbow
```

See the [documentation](https://thedrone7.github.io/shieldbow/) to learn more!

---

# @shieldbow/web (v1)

An all-purpose, easy-to-use client for the league of legends API.
This is safe to use on the frontend, requires no API key, but is less powerful than the full library.

This is part of Shieldbow (v3) - a work in progress.

There are no shieldbow-web specific documentation (yet), but is fairly intuitive and similar to shieldbow (v2) on the surface.
The documentation will be available upon completion of shieldbow (v3).

To install shieldbow-web, use (depending on your package manager)
```bash
npm install @shieldbow/web axios

yarn add @shieldbow/web axios

pnpm add @shieldbow/web axios
```

### NOTE

In [`@shieldbow/web`](https://npmjs.com/package/@shieldbow/web), the `axios` package is an optional dependency.

This means that you can use any other HTTP client too! However, if you do not provide a HTTP client,
shieldbow will try to default to `axios` (if it is installed).

If it is not installed, shieldbow will throw an error.

You can provide your own HTTP client by passing it to the `Client` initialization

Here is an example with the built-in JavaScript fetch API (which is available in the browser)
```ts

// Typescript
client.initialize({
// ... other options,
fetchMethod: (url: string) => fetch(url).then(res => {
if (!res.ok) throw new Error(res.statusText);
if (res.headers.get('content-type')?.includes('application/json')) return res.json() as Promise;
else return res.text() as unknown as Promise;
});
})

// Javascript
client.initialize({
// ... other options,
fetchMethod: function (url) {
return fetch(url).then(res => {
if (!res.ok) throw new Error(res.statusText);
if (res.headers.get('content-type')?.includes('application/json')) return res.json();
else return res.text();
});
}
})
```

---