GraphQL and Cloudflare workers powered Riot API

I hereby announce that we are making our project to communicate with the League of Legends Riot API open source. So, why might you use this over something else?

  • It makes use of Cloudflare's workers. This means you will gain a globally distributed version of your API, ensuring low latency for all your users.
  • Cloudflare workers can be used at no to little cost, depending on how many users you have. It is free for up to 100 000 requests per day and otherwise starts at €5 per month.
  • If you are currently using a serverless environment your application will only have to do 1 request for all the data you need on a page, so you will also improve user experience.

Still, it is not perfect.

  • The application is lacking rate limiting, which should be implemented according to Riot.
  • You will probably not want to use it if you want to do something else than just calling the Riot API endpoints for your application. Data aggregation over multiple games and the creation of statistics is better done using a server with a database.

Usage

Before you begin, you will need to have Node installed as well as Wrangler.

  1. Get the code from https://gitlab.com/lol-math/cloudflare-workers-riot-api.
  2. Install the dependencies with pnpm or your favorite node package manager.
  3. Set up your cloudflare workers account, and get your account id. See https://developers.cloudflare.com/workers/quickstart/
  4. Create your wrangler.toml (see below).
  5. Create a .env file containing your RIOT_API_KEY (get it from https://developer.riotgames.com).
  6. Run the pnpm run publish command. Or, using your favorite package manager.

wrangler.toml

name = "graphql-riot-api"
account_id = "$yourAccountId"
type = "webpack"
workers_dev = true
webpack_config = "./webpack.config.js"

.env

RIOT_API_KEY=RGAPI-12345-67890
Using chrome bookmarks to proxy the current urlTyping useSelector