A fast, caching reverse proxy and API backend built in Go to serve Smogon usage stats efficiently.
Features strict SSRF protections, graceful shutdown, and robust caching (BigCache) to minimize bandwidth and database queries. The backend operates on the optimized v3 API layer to serve highly condensed JSON payloads (stripping expensive string formatting overhead). It also includes the necessary data populator scripts to scrape Smogon stats directly into PostgreSQL.
- Go 1.20+
- PostgreSQL instance running locally on
/var/run/postgresqlwith asmogon_statsdatabase andubuntuuser (or setDATABASE_URL).
The project includes a Makefile to easily build the API server and all the data scrapers.
To compile all binaries:
make buildTo run the local proxy server:
make runNote: The proxy runs on port 9000 by default. This can be overridden with the PORT environment variable.
This repository includes 5 standalone tools to scrape and populate the PostgreSQL database from the raw Smogon text files:
populate-usage-stats-binpopulate-format-stats-binpopulate-leads-binpopulate-metagame-binpopulate-viability-bin
To build and run all populator scripts sequentially:
make populateThis API is designed to be hosted on a Linux instance. To ensure the proxy runs forever and automatically restarts on system boot or crash, a systemd service file is provided.
- Copy the service file to the systemd directory:
sudo cp proxy-api.service /etc/systemd/system/- Reload systemd, enable the service to start on boot, and start it:
sudo systemctl daemon-reload
sudo systemctl enable proxy-api
sudo systemctl start proxy-api- Check the status or view logs:
sudo systemctl status proxy-api
sudo journalctl -u proxy-api -f- Go: For the high-performance standard library and concurrency primitives.
- Smogon: For providing the raw competitive Pokémon usage statistics data.
- pgx: For the fast PostgreSQL driver.
- BigCache: For the high-performance concurrent local cache.
This project is licensed under the MIT License.