Skip to content

About

High performance proxy for the clash of clans api

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

ClashKingProxy

Lightweight Go proxy for the Clash of Clans API with rotating production keys, built-in request stats, and a Cloudflare Worker asset proxy for CORS-safe image delivery.

Features

  • Rotates requests across multiple production API keys from COC_KEYS
  • Proxies Clash of Clans production traffic under /v1/
  • Exposes rolling request, latency, status-code, and endpoint usage metrics at /stats
  • Includes assets-proxy.js for proxying Clash of Clans API assets through Cloudflare Workers
  • Keeps metrics aggregate-only; do not log bearer tokens, COC_KEYS, raw authorization headers, request bodies, or client IP addresses

Requirements

  • Go 1.26.2+ recommended
  • One or more Clash of Clans API keys

Configuration

Variable Required Default Description
COC_KEYS Yes - Comma-separated Clash of Clans API keys used for /v1/ requests
HOST No 0.0.0.0 Bind host
PORT No 8011 Bind port
DEV_COC_URL No - Base URL for the /dev/ upstream

The server also loads a local .env file automatically when present.

Run Locally

export COC_KEYS="key1,key2"
go run .

Docker

docker build -t clashking-proxy .
docker run --rm -p 8011:8011 -e COC_KEYS="key1,key2" clashking-proxy

API

  • GET / health-style status response
  • GET /stats rolling stats summary
  • GET /stats?series=5m&lookback=48h time-series metrics
  • GET /stats?endpoints=24h&limit=25 top endpoint usage
  • /v1/* proxied to https://api.clashofclans.com/v1/ with rotated bearer keys
  • /dev/* proxied to DEV_COC_URL and forwards the incoming Authorization: Bearer ... header

Example:

curl http://localhost:8011/v1/players/%23PLAYER_TAG

Asset Worker

assets-proxy.js is a standalone Cloudflare Worker proxy for Clash of Clans API image assets.

Example:

Proxy:
https://assets-proxy.clashk.ing/badges/512/
eX-l0ROdCFJw-nYPv721y1exbwOwDBZZRZuxMRGg2xo.png

Upstream:
https://api-assets.clashofclans.com/badges/512/
eX-l0ROdCFJw-nYPv721y1exbwOwDBZZRZuxMRGg2xo.png

License

MIT

About

High performance proxy for the clash of clans api

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Used by

Contributors

Languages