Cosmic-Radiance

Just another Riot Games API rate limiter with a cosmic glance ✨.
Features
- Automatic endpoint and platform detection
- Automatic rate limit discovery
- Customizable Timeout and good Retry-After handling
- GZIP handling to reduce traffic
- Prioritize requests with a
X-Priority: high header
- Prometheus metrics to create dashboards about the rate limit status and queue sizes
- up to 99% close to uptime rate limits[^1]
Getting started
To get started, clone the project from GitHub.
git clone https://github.com/DarkIntaqt/cosmic-radiance.git
Next, you need to set a few environment variables. For that, you can copy the .env.example and adjust the settings to your needs.
Finally, run the project in a docker container with:
docker compose up -d
Then, you can start requesting http://localhost:PORT/<platform>/<method> or http://<platform>.api.riotgames.com/<method> (with proxy-pass), based on your MODE (see configuration).
Otherwise, you can run the project manually by installing the dependencies with go mod tidy and then run it with go run cmd/cosmic-radiance/main.go.
Configuration
There are several .env variables which can fine tune cosmic-radiance. Some are required
| Name |
Function |
| API_KEY required |
Your Riot Games API key. Cosmic-radiance needs your key to fire requests to the Riot Games API. |
| PORT required |
Port on which the proxy is running. Chose a port that is free. Please double-check your port and Dockerfile configuration. |
| MODE required |
Either PATH or PROXY. In path mode, you request cosmic-radiance like a normal webserver with the endpoint following the endpoint. In the proxy mode, you can use proxy-pass to redirect .api.riotgames.com requests directly to cosmic-radiance. You need to use http. |
| TIMEOUT |
The wait time after which incoming requests are getting rejected. Time in seconds |
| PRIORITY_QUEUE_SIZE |
The size of the priority queue compared to the normal queue. In percent (%). |
| PROMETHEUS |
Either ON or OFF. Disabled by default. Enable to get prometheus statistics |
Error Codes
All error codes are returned as by the Riot Games API. There were a few additional error codes added.
| Code |
Where to be found |
What does this mean |
| 408 |
Metrics |
The request timed out. Check the Retry-After header. |
| 499 |
Metrics |
The requesting client dropped the request. |
| 500 |
Metrics and Proxy |
The request to the Riot Games API failed before it was executed. |
Contributing
This rate limiter is by no means feature complete, however it should be able to run in production without any issues. If you have any ideas or improvements, feel free to open an issue or a pull request.
License
This project is licensed under the Apache 2.0 License.
[^1]: Tested with 100 available request per second (rps) in which the average was 99rps.