Skip to content

Commit c1997b2

Browse files
committed
feat: add /badge endpoint documentation and usage examples to README.
1 parent a1de7d1 commit c1997b2

File tree

1 file changed

+72
-12
lines changed

1 file changed

+72
-12
lines changed

README.md

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@ Generate dynamic GitHub stats and language cards for README embeds.
55
## Endpoints
66

77
### GET /
8+
89
Returns JSON describing the live route list and static asset roots.
910

1011
Example:
12+
1113
```
1214
GET https://stats.pphat.top/
1315
```
1416

1517
### GET /stats
18+
1619
Returns an SVG (default) or WebP stats card for a user.
1720

1821
Required query params:
22+
1923
- username
2024

2125
Optional query params:
26+
2227
- theme
2328
- hide_title
2429
- hide_border
@@ -36,17 +41,21 @@ Optional query params:
3641
- format (svg | webp)
3742

3843
Example:
44+
3945
```
4046
GET https://stats.pphat.top/stats?username=pphatdev&theme=dark
4147
```
4248

4349
### GET /languages
50+
4451
Returns an SVG languages card or pie chart for a user.
4552

4653
Required query params:
54+
4755
- username
4856

4957
Optional query params:
58+
5059
- theme
5160
- show_info
5261
- top
@@ -59,17 +68,21 @@ Optional query params:
5968
- format
6069

6170
Example:
71+
6272
```
6373
GET https://stats.pphat.top/languages?username=pphatdev&theme=default
6474
```
6575

6676
### GET /graph
77+
6778
Returns an SVG activity graph for a user for a specific year or the last 365 days.
6879

6980
Required query params:
81+
7082
- `username`
7183

7284
Optional 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

8699
Example:
100+
87101
```
88102
GET https://stats.pphat.top/graph?username=pphatdev&year=2024
89103
GET 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
94108
GET 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

99135
Stats card:
136+
100137
```markdown
101138
![GitHub Stats](https://stats.pphat.top/stats?username=YOUR_USERNAME)
102139
```
103140

104141
Languages card:
142+
105143
```markdown
106144
![Top Languages](https://stats.pphat.top/languages?username=YOUR_USERNAME)
107145
```
108146

109147
Languages pie chart:
148+
110149
```markdown
111150
![Top Languages](https://stats.pphat.top/languages?username=YOUR_USERNAME&type=pie)
112151
```
113152

114153
Activity graph:
154+
115155
```markdown
116156
![Activity Graph](https://stats.pphat.top/graph?username=YOUR_USERNAME)
117157
```
118158

119159
Activity 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

126179
Use 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
188243
npm install
189244
```
190245

191246
Create a .env file:
247+
192248
```env
193249
GITHUB_TOKEN=your_github_personal_access_token
194250
PORT=3000
195251
APP_ENV=development
196252
```
197253

198254
Build and run:
255+
199256
```bash
200257
npm run build
201258
npm start
202259
```
203260

204261
Development mode:
262+
205263
```bash
206264
npm 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+
214274
MIT. See LICENSE.

0 commit comments

Comments
 (0)