Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
8230288
feat: v2
MagicTheDev Jan 23, 2025
0c02315
feat: v2
MagicTheDev Jan 27, 2025
6a75742
feat: App auth endpoints
Destinea Feb 8, 2025
32c8f37
feat: dev build
Destinea Feb 10, 2025
91f1dae
fix: Sanitized branch name
Destinea Feb 10, 2025
8b6a79b
fix: dev redirection
Destinea Feb 10, 2025
1b9b022
fix: code verifier in auth
Destinea Feb 15, 2025
a088645
feat: Added encryption
Destinea Feb 16, 2025
954ac68
feat: Added Discord proxy
Destinea Feb 16, 2025
6d91713
feat: Get Discord User infos
Destinea Feb 16, 2025
0850e6e
feat: v2 endpoints
MagicTheDev Feb 16, 2025
2bad57d
feat: v2 endpoints
MagicTheDev Feb 19, 2025
c3513d5
feat: v2 endpoints
MagicTheDev Feb 19, 2025
b4262fb
feat: Updated /users/me
Destinea Feb 22, 2025
71a4a91
feat: Updated refresh_discord_access_token
Destinea Feb 22, 2025
c690593
fix: module 'jwt' has no attribute 'JWTError'
Destinea Feb 22, 2025
2030856
chore: debug
Destinea Feb 22, 2025
12dcf94
feat: Updated Auth token handling
Destinea Mar 3, 2025
37cb129
fix: async client
Destinea Mar 3, 2025
e3f9d14
fix: db collections
Destinea Mar 3, 2025
905d268
fix: token model
Destinea Mar 3, 2025
f553bab
fix: bearer token
Destinea Mar 3, 2025
f62e366
fix: Access token
Destinea Mar 3, 2025
8f5875c
fix: Hash token
Destinea Mar 3, 2025
7b14cb8
fix: UTF8 encryption
Destinea Mar 3, 2025
4c07028
fix: jwt
Destinea Mar 4, 2025
28db294
fix: refresh_token collection
Destinea Mar 4, 2025
fc56d3d
fix: discord token
Destinea Mar 4, 2025
53a9d8c
fix: uuid
Destinea Mar 4, 2025
81d0342
fix: uuid
Destinea Mar 4, 2025
687e53f
fix: randint
Destinea Mar 4, 2025
96d3bbb
chore: debug
Destinea Mar 4, 2025
31e281d
chore: debug
Destinea Mar 4, 2025
cfe6036
chore: debug
Destinea Mar 4, 2025
d9613dd
chore: debug
Destinea Mar 4, 2025
6200fe5
fix: timestamp
Destinea Mar 4, 2025
90bf821
feat: coc accounts endpoints
Destinea Mar 4, 2025
e0b07ae
fix: coc accounts db
Destinea Mar 4, 2025
16e8c0a
feat: Send name and townhall level when adding account
Destinea Mar 4, 2025
71df6be
fix: Coc Account management
Destinea Mar 4, 2025
ff33a7b
fix: add coc account with token
Destinea Mar 4, 2025
17f9d03
fix: add coc account with token
Destinea Mar 4, 2025
f5f6f6c
chore: move files
Destinea Mar 5, 2025
06c6931
Merge branch 'v2' into feat/appEndpoints
Destinea Mar 5, 2025
f89d4bd
feat: Added player full-stats endpoint
Destinea Mar 5, 2025
54c5c52
feat: Reorder COC Accounts
Destinea Mar 5, 2025
26889ca
chore: Renamed variables
Destinea Mar 7, 2025
2fab9d9
fix: Modified model
Destinea Mar 7, 2025
3357f4d
feat: full stats clan endpoint
Destinea Mar 8, 2025
7223a2c
fix: variables name
Destinea Mar 8, 2025
22f9f52
chore: Changed runner
Destinea Mar 8, 2025
7d713b7
feat: v2 endpoints
MagicTheDev Mar 17, 2025
f3477c4
chore: Restored runner
Destinea Mar 17, 2025
8dddc7d
Merge branch 'v2' into feat/appEndpoints
Destinea Mar 17, 2025
a0e6dcb
feat: v2 endpoints
MagicTheDev Mar 17, 2025
57990f0
feat: v2 endpoints
MagicTheDev Mar 17, 2025
ab8ed85
feat: v2 endpoints
MagicTheDev Mar 17, 2025
771ed2c
feat: legends stats
Destinea Mar 26, 2025
f86a5c0
Merge remote-tracking branch 'origin/v2' into feat/appEndpoints
Destinea Mar 26, 2025
4ce7630
feat: season end trophies
Destinea Mar 26, 2025
8b94c9a
fix: number of defenses
Destinea Mar 27, 2025
a965148
feat: Added player rankings
Destinea Mar 28, 2025
099f15b
fix: got multiple values for argument 'request'
Destinea Mar 28, 2025
f75d1ef
fix: got multiple values for argument 'request'
Destinea Mar 28, 2025
0760811
chore: removed caching
Destinea Mar 28, 2025
14a2a20
feat: season duration
Destinea Mar 28, 2025
e1b9340
feat: legends stars stats
Destinea Mar 28, 2025
559fd84
feat: v2 endpoints
MagicTheDev Mar 29, 2025
329b95d
feat: v2
MagicTheDev Apr 1, 2025
1851422
feat: Improved stars stats
Destinea Apr 3, 2025
077dedc
Merge remote-tracking branch 'origin/v2' into feat/appEndpoints
Destinea Apr 3, 2025
ca23e87
feat: War summary
Destinea Apr 3, 2025
9fa636b
chore: Renamed war endpoint
Destinea Apr 3, 2025
8ea9107
chore: Changed tag
Destinea Apr 3, 2025
3b4018e
Merge remote-tracking branch 'origin/master' into feat/appEndpoints
Destinea Apr 3, 2025
9f5e19e
feat: Used Asyncio on war endpoint
Destinea Apr 3, 2025
80cb4c9
feat: War & CWL stats
Destinea Apr 4, 2025
11d19df
feat: Added CWL defenses stats
Destinea Apr 4, 2025
9cb79c8
feat: Added war_tag in CWL wars
Destinea Apr 4, 2025
693bb8e
feat: Better Discord Auth error Handle
Destinea Apr 4, 2025
bb785ae
feat: Dynamic Discord redirect uri
Destinea Apr 4, 2025
4842f8a
feat: Used asyncio
Destinea Apr 5, 2025
f51ed73
feat: Added TownHallLevels
Destinea Apr 5, 2025
94426c2
feat: One tag endpoint
Destinea Apr 5, 2025
75a5af9
feat: Added avgMapPosition, avgOpponentPosition, avgAttackOrder
Destinea Apr 6, 2025
46fd669
feat: Added average TownHall Level
Destinea Apr 7, 2025
85b53d3
feat: Added average defense stats
Destinea Apr 7, 2025
c76a584
feat: Added missed defenses
Destinea Apr 7, 2025
8cf12bf
feat: stars by TH level
Destinea Apr 7, 2025
3b7a968
feat: Added /players/warhits
Destinea Apr 10, 2025
4232e3d
feat: Added same TH filter in warhits endpoint
Destinea Apr 10, 2025
49f0c7e
feat: Added warCounts
Destinea Apr 10, 2025
f14a9ae
fix: Limit for each profile
Destinea Apr 11, 2025
5638223
feat: Separated player endpoint in two endpoints
Destinea Apr 11, 2025
212d651
feat: Added war data in warhits
Destinea Apr 11, 2025
8ce1ecc
feat: Added players name
Destinea Apr 11, 2025
591777e
feat: Stats by war type
Destinea Apr 11, 2025
9bd197b
chore: Moved some keys
Destinea Apr 11, 2025
deb9e13
chore: Added one day to is_cwl
Destinea Apr 11, 2025
dbb5602
chore: Added one day to is_cwl
Destinea Apr 11, 2025
13cda4e
feat: Added /war/cwl-summary/export
Destinea Apr 11, 2025
22bc2f9
feat: Clashking them + fix on missed attacks
Destinea Apr 12, 2025
1f9f62e
feat: Added v2/clans/join-leave endpoint with filters & stats
Destinea Apr 13, 2025
12a4a57
feat: Updated requirements.txt
Destinea Apr 13, 2025
8b685c2
feat: Added current_season filter
Destinea Apr 13, 2025
e37607b
fix: Added players stats in join/leave
Destinea Apr 13, 2025
23cf1e9
feat: Added maintenance info on /players
Destinea Apr 14, 2025
381a409
fix: Return results
Destinea Apr 14, 2025
38abe00
feat: Load player war data if player isn't in their war clan
Destinea Apr 19, 2025
7d8c104
chore: Move war stats endpoint
Destinea May 11, 2025
46d5031
feat: Players war stats for a clan
Destinea May 11, 2025
749da65
support: debug
Destinea May 11, 2025
4b5d643
Merge branch 'master' into feat/appEndpoints
Destinea May 11, 2025
fda554f
fix: war stats structure
Destinea May 11, 2025
3f03432
fix: Missing member attacks
Destinea May 11, 2025
c5a3181
fix: cwl export function call
Destinea May 11, 2025
3877508
fix: war stats structure
Destinea May 11, 2025
09c3ab2
fix: war stats structure for multiple players and multiple clans
Destinea May 11, 2025
92eb90a
chore: parallelization
Destinea May 11, 2025
0580b44
feat: War stats by th vs th
Destinea May 13, 2025
7e51e68
fix: townhall level
Destinea May 20, 2025
09e0640
fix: List index out of range
Destinea May 29, 2025
69ff0cb
fix: improve auth security
Destinea Jun 22, 2025
229fa7d
fix: remove limiter
Destinea Jun 22, 2025
c9c6c72
fix: user_id format
Destinea Jun 22, 2025
19e888e
fix: 401 in email login
Destinea Jun 22, 2025
9a5e2d5
chore: add sentry messages for auth endpoints
Destinea Jun 23, 2025
8edd66a
chore: add sentry dsn
Destinea Jun 23, 2025
6ee728a
fix: change user_id type
Destinea Jun 23, 2025
d81e16a
chore: add sentry messages
Destinea Jun 23, 2025
2f31f32
chore: add email encryption
Destinea Jun 23, 2025
ce25c37
fix: 'NoneType' object is not subscriptable for war
Destinea Jun 23, 2025
532b48e
chore: remove print
Destinea Jun 23, 2025
cf88ec9
feat: app endpoint to faster loading time
Destinea Jun 29, 2025
d190fb5
chore: reorder endpoints
Destinea Jun 29, 2025
a59c6f3
fix: add missing clan_tag in capital endpoint
Destinea Jun 29, 2025
3bf2bf0
fix: add missing player to do info
Destinea Jun 29, 2025
68bb3a3
feat: add api token verification
Destinea Jun 29, 2025
81ca3fb
chore: move sentry dsn to backend
Destinea Jun 30, 2025
c6d813a
chore: remove dead import
Destinea Jun 30, 2025
6893852
feat: add email verification
Destinea Jul 9, 2025
be45da9
chore: clashking colors in email
Destinea Jul 9, 2025
0f316c9
chore: clashking redirect page
Destinea Jul 9, 2025
a7939e3
fix: app redirect
Destinea Jul 9, 2025
c9a1a7a
fix: app redirect
Destinea Jul 9, 2025
0793563
feat: switch email auth to 6 digit code
Destinea Jul 10, 2025
1f958df
fix: error 500 in email auth
Destinea Jul 10, 2025
db34afd
chore: revert limiter
Destinea Jul 10, 2025
c1c72c1
fix: error 500 in email auth
Destinea Jul 10, 2025
2e648c0
chore: debug
Destinea Jul 10, 2025
948f511
chore: debug
Destinea Jul 10, 2025
be0cc9d
chore: debug
Destinea Jul 10, 2025
dc8bea7
fix: error 500 in email auth
Destinea Jul 10, 2025
6ca8a7b
chore: debug
Destinea Jul 10, 2025
64e96db
chore: remove debug prints
Destinea Jul 10, 2025
3d5c3db
feat: add forgot password
Destinea Jul 11, 2025
862df45
chore: debug
Destinea Jul 11, 2025
977e375
fix: import
Destinea Jul 11, 2025
c698761
fix: import
Destinea Jul 11, 2025
d2bfbd6
fix: reset password error 500
Destinea Jul 11, 2025
40591b6
fix: timezone in resend email
Destinea Jul 11, 2025
b0f09a2
fix: missing clan tag and remove debug
Destinea Jul 11, 2025
371b329
chore: remove unused sentry log
Destinea Jul 11, 2025
c8fe5f0
fix: remove redondant fetch_opponent_tag function
Destinea Jul 14, 2025
7f24203
fix: division by 0
Destinea Jul 18, 2025
fdcd255
fix: war errors handling
Destinea Jul 18, 2025
f88547e
feat: player war stats export
Destinea Jul 19, 2025
efa147e
fix: file not readable
Destinea Jul 19, 2025
84f99a7
feat: enhance TH statistics display in Excel export with performance …
Destinea Jul 20, 2025
30f6bf1
feat: add defense details to excel export
Destinea Jul 20, 2025
b18185d
chore: move exports to an exports folder
Destinea Jul 20, 2025
4a5a584
fix: missing argument for app init
Destinea Jul 20, 2025
92f6f5e
feat: allow lowercase letters when adding account & send account info…
Destinea Jul 26, 2025
435cfed
fix: legends start trophies
Destinea Jul 30, 2025
ae2dd2f
fix: legends start and end trophies
Destinea Jul 30, 2025
f654d24
fix: dont return _id
MagicTheDev Aug 16, 2025
6a6e279
fix: improve legends stats
Destinea Jul 30, 2025
d27ff73
feat: add return message when email not verified
Destinea Aug 17, 2025
3478a33
feat: add specific error code for email not verified
Destinea Aug 17, 2025
2d6ccae
feat: add specific error code for email not verified
Destinea Aug 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/dev-image-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Dev API Image Builder

on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- reopened
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}

- name: Set environment variables
run: |
echo "APP_ENV=development" >> $GITHUB_ENV
echo "IMAGE_NAME=ghcr.io/clashkinginc/clashkingapi-dev" >> $GITHUB_ENV

- name: Sanitize branch name
id: sanitize
run: echo "SANITIZED_BRANCH=$(echo '${{ github.event.pull_request.head.ref }}' | sed 's/[^a-zA-Z0-9_.-]/-/g')" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.SANITIZED_BRANCH }}
${{ env.IMAGE_NAME }}:latest
build-args: APP_ENV=${{ env.APP_ENV }}

36 changes: 0 additions & 36 deletions .github/workflows/main.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/prod-image-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Production API Image Builder

on:
push:
branches:
- master # Trigger only on push to master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }} # Automatically checkout the triggering branch

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}

- name: Set environment variables
run: |
echo "APP_ENV=production" >> $GITHUB_ENV
echo "IMAGE_NAME=ghcr.io/clashkinginc/clashkingapi" >> $GITHUB_ENV

- name: Sanitize branch name
id: sanitize
run: echo "SANITIZED_BRANCH=$(echo '${{ github.event.pull_request.head.ref }}' | sed 's/[^a-zA-Z0-9_.-]/-/g')" >> $GITHUB_ENV

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ github.sha }}
build-args: APP_ENV=${{ env.APP_ENV }}

- name: Verify pushed images
run: |
echo "Pushed image: ${{ env.IMAGE_NAME }}:latest"
echo "Pushed image: ${{ env.IMAGE_NAME }}:${{ github.sha }}"
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# created by virtualenv automatically
.env
*.xml
*.idea
.idea/
*pycache*
.venv/
# created by virtualenv automatically
.env
*.xml
*.idea
.idea/
*pycache*
.venv/
.claude/*
CLAUDE.md
49 changes: 30 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
FROM python:3.11-bookworm

LABEL org.opencontainers.image.source=https://github.com/ClashKingInc/ClashKingAPI
LABEL org.opencontainers.image.description="Image for the ClashKing API"
LABEL org.opencontainers.image.licenses=MIT

RUN apt-get update && apt-get install -y libsnappy-dev

WORKDIR /app

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 6000

CMD ["python", "main.py"]
# Use the official Python 3.11 image
FROM python:3.11-bookworm

# Metadata labels for the image
LABEL org.opencontainers.image.source="https://github.com/ClashKingInc/ClashKingAPI"
LABEL org.opencontainers.image.description="Image for the ClashKing API"
LABEL org.opencontainers.image.licenses="MIT"

# Install system dependencies
RUN apt-get update && apt-get install -y libsnappy-dev

# Set the working directory
WORKDIR /app

# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application files
COPY . .

# Define the environment variable for auth mode (default to development)
ARG APP_ENV=development
ENV APP_ENV=${APP_ENV}

# Expose the ports used by different environments
EXPOSE 6000 8073 8010

# Dynamically set the correct port based on APP_ENV
CMD ["sh", "-c", "python main.py --port=$( [ \"$APP_ENV\" = \"development\" ] && echo 8073 || ( [ \"$APP_ENV\" = \"local\" ] && echo 8000 || echo 8010 ) )"]
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# ClashKing API (api.clashk.ing)

Welcome to the [ClashKing API](https://api.clashk.ing)! This is a public API designed to provide extra & historical **Clash of Clans** data for others.
---

## Key
- **Public Access**: No authentication required.
- **No Rate Limits**: Fetch data freely, but please use responsibly.
- **Cloudflare**: Cached & Protected by.
- **Infra**: Backed by three instances with a load balancer.
- **Caching**: Responses are cached for 5 minutes.

### Respecting Data and Credit
Due to the resource-intensive nature of this data - it requires considerable CPU, Storage, Internet Bandwidth, and in turn cost, please:
1. **Credit the source**: We ask you to credit the ClashKing API where this data is used to ensure clarity and fairness.
2. **No impression of self-collection**: Do not create the impression that your application collects this data independently.

There is no strict requirement for credit format, but we appreciate a visible mention or link to [ClashKing](https://clashk.ing) in your project.

---

## Collaboration and Standards

The ClashKing API is open to contributions! You can suggest new features, fixes, or updates. Contributions should follow proper formatting and standards.

---

## Assets

ClashKing also hosts a public CDN for Clash of Clans assets at **assets.clashk.ing**. These include game icons, images, and other resources. For more details, visit the [ClashKingAssets repository](https://github.com/ClashKingInc/ClashKingAssets).

---

## Notice

This project is **not affiliated with, endorsed, sponsored, or specifically approved by Supercell**. For more information, see [Supercell’s Fan Content Policy](https://supercell.com/en/fan-content-policy/).

By using this API, you agree to use it responsibly and in compliance with Supercell’s Terms of Service and Fan Content Policy.
# ClashKing API (api.clashk.ing)
Welcome to the [ClashKing API](https://api.clashk.ing)! This is a public API designed to provide extra & historical **Clash of Clans** data for others.
---
## Key
- **Public Access**: No authentication required.
- **No Rate Limits**: Fetch data freely, but please use responsibly.
- **Cloudflare**: Cached & Protected by.
- **Infra**: Backed by three instances with a load balancer.
- **Caching**: Responses are cached for 5 minutes.
### Respecting Data and Credit
Due to the resource-intensive nature of this data - it requires considerable CPU, Storage, Internet Bandwidth, and in turn cost, please:
1. **Credit the source**: We ask you to credit the ClashKing API where this data is used to ensure clarity and fairness.
2. **No impression of self-collection**: Do not create the impression that your application collects this data independently.
There is no strict requirement for credit format, but we appreciate a visible mention or link to [ClashKing](https://clashk.ing) in your project.
---
## Collaboration and Standards
The ClashKing API is open to contributions! You can suggest new features, fixes, or updates. Contributions should follow proper formatting and standards.
---
## Assets
ClashKing also hosts a public CDN for Clash of Clans assets at **assets.clashk.ing**. These include game icons, images, and other resources. For more details, visit the [ClashKingAssets repository](https://github.com/ClashKingInc/ClashKingAssets).
---
## Notice
This project is **not affiliated with, endorsed, sponsored, or specifically approved by Supercell**. For more information, see [Supercell’s Fan Content Policy](https://supercell.com/en/fan-content-policy/).
By using this API, you agree to use it responsibly and in compliance with Supercell’s Terms of Service and Fan Content Policy.
Loading