@@ -5,20 +5,25 @@ Generate dynamic GitHub stats and language cards for README embeds.
55## Endpoints
66
77### GET /
8+
89Returns JSON describing the live route list and static asset roots.
910
1011Example:
12+
1113```
1214GET https://stats.pphat.top/
1315```
1416
1517### GET /stats
18+
1619Returns an SVG (default) or WebP stats card for a user.
1720
1821Required query params:
22+
1923- username
2024
2125Optional query params:
26+
2227- theme
2328- hide_title
2429- hide_border
@@ -36,17 +41,21 @@ Optional query params:
3641- format (svg | webp)
3742
3843Example:
44+
3945```
4046GET https://stats.pphat.top/stats?username=pphatdev&theme=dark
4147```
4248
4349### GET /languages
50+
4451Returns an SVG languages card or pie chart for a user.
4552
4653Required query params:
54+
4755- username
4856
4957Optional query params:
58+
5059- theme
5160- show_info
5261- top
@@ -59,17 +68,21 @@ Optional query params:
5968- format
6069
6170Example:
71+
6272```
6373GET https://stats.pphat.top/languages?username=pphatdev&theme=default
6474```
6575
6676### GET /graph
77+
6778Returns an SVG activity graph for a user for a specific year or the last 365 days.
6879
6980Required query params:
81+
7082- ` username `
7183
7284Optional query params:
85+
7386- ` theme ` — see [ Graph Themes] ( #graph-themes ) below
7487- ` year ` — 4-digit year (default: last 365 days)
7588- ` animate ` — cell animation mode: ` glow ` (default) | ` wave ` | ` pulse ` | ` none `
@@ -84,6 +97,7 @@ Optional query params:
8497- ` titleColor `
8598
8699Example:
100+
87101```
88102GET https://stats.pphat.top/graph?username=pphatdev&year=2024
89103GET https://stats.pphat.top/graph?username=pphatdev&theme=aurora
@@ -94,33 +108,72 @@ GET https://stats.pphat.top/graph?username=pphatdev&theme=matrix&animate=pulse&a
94108GET https://stats.pphat.top/graph?username=pphatdev&as=png
95109```
96110
111+ ### GET /badge
112+
113+ Returns a dynamic visitor badge SVG that increments on every page load.
114+
115+ Required query params:
116+
117+ - ` username `
118+
119+ Optional query params:
120+
121+ - ` theme `
122+ - ` labelColor `
123+ - ` labelBackground `
124+ - ` valueColor `
125+ - ` valueBackground `
126+
127+ Example:
128+
129+ ```
130+ GET https://stats.pphat.top/badge?username=pphatdev&theme=tokyo
131+ ```
132+
97133## Usage in README
98134
99135Stats card:
136+
100137``` markdown
101138![ GitHub Stats] ( https://stats.pphat.top/stats?username=YOUR_USERNAME )
102139```
103140
104141Languages card:
142+
105143``` markdown
106144![ Top Languages] ( https://stats.pphat.top/languages?username=YOUR_USERNAME )
107145```
108146
109147Languages pie chart:
148+
110149``` markdown
111150![ Top Languages] ( https://stats.pphat.top/languages?username=YOUR_USERNAME&type=pie )
112151```
113152
114153Activity graph:
154+
115155``` markdown
116156![ Activity Graph] ( https://stats.pphat.top/graph?username=YOUR_USERNAME )
117157```
118158
119159Activity graph with theme and animation:
160+
120161``` markdown
121162![ Activity Graph] ( https://stats.pphat.top/graph?username=YOUR_USERNAME&theme=aurora&animate=pulse )
122163```
123164
165+ Visitor badge:
166+
167+ ``` markdown
168+ ![ Visitor Badge] ( https://stats.pphat.top/badge?username=YOUR_USERNAME )
169+ ```
170+
171+ Visitor badge with theme and custom colors:
172+
173+ ``` markdown
174+ ![ Visitor Badge] ( https://stats.pphat.top/badge?username=YOUR_USERNAME&theme=tokyo&labelColor=ff0000 )
175+ ```
176+
124177## Example Themes
125178
126179Use the ` theme ` query param. A few previews:
@@ -161,54 +214,61 @@ All available themes: `aurora` · `matrix` · `inferno` · `ocean` · `neon` ·
161214
162215### Animate Modes
163216
164- | Mode | Description |
165- | ---| ---|
166- | ` glow ` | Default — active cells pulse with a soft glow |
167- | ` wave ` | Cells ripple in a wave pattern across columns |
168- | ` pulse ` | ~ 16 random cells flash independently |
169- | ` none ` | No animation — static render |
217+ | Mode | Description |
218+ | ------- | --------------------------------------------- |
219+ | ` glow ` | Default — active cells pulse with a soft glow |
220+ | ` wave ` | Cells ripple in a wave pattern across columns |
221+ | ` pulse ` | ~ 16 random cells flash independently |
222+ | ` none ` | No animation — static render |
170223
171224### Size Presets
172225
173- | Value | Canvas | Cell size |
174- | ---| ---| ---|
175- | ` default ` | 1200 × 600 | 14 px |
176- | ` small ` | 800 × 400 | 9 px |
177- | ` medium ` | 1000 × 500 | 12 px |
178- | ` large ` | 1400 × 700 | 16 px |
226+ | Value | Canvas | Cell size |
227+ | --------- | ---------- | --------- |
228+ | ` default ` | 1200 × 600 | 14 px |
229+ | ` small ` | 800 × 400 | 9 px |
230+ | ` medium ` | 1000 × 500 | 12 px |
231+ | ` large ` | 1400 × 700 | 16 px |
179232
180233## Development
181234
182235### Prerequisites
236+
183237- Node.js 16+
184238- GitHub Personal Access Token (recommended)
185239
186240### Setup
241+
187242``` bash
188243npm install
189244```
190245
191246Create a .env file:
247+
192248``` env
193249GITHUB_TOKEN=your_github_personal_access_token
194250PORT=3000
195251APP_ENV=development
196252```
197253
198254Build and run:
255+
199256``` bash
200257npm run build
201258npm start
202259```
203260
204261Development mode:
262+
205263``` bash
206264npm run dev
207265```
208266
209267## Notes
268+
210269- The API uses GitHub REST and caches responses for 20 minutes.
211270- Without a token, GitHub rate limits are low; set GITHUB_TOKEN for higher limits.
212271
213272## License
273+
214274MIT. See LICENSE.
0 commit comments