|
| 1 | +# Badge Collections |
| 2 | + |
| 3 | +This guide explains how to combine multiple user badges into a single SVG using the badge collection endpoint. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Badge collections are useful when you want one compact image instead of many separate badge URLs. |
| 8 | + |
| 9 | +Use cases: |
| 10 | +- GitHub profile README blocks |
| 11 | +- Documentation hero sections |
| 12 | +- Project landing pages |
| 13 | +- Release notes snapshots |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Endpoint |
| 18 | + |
| 19 | +```http |
| 20 | +GET /badge/collection |
| 21 | +``` |
| 22 | + |
| 23 | +Base demo URL: |
| 24 | + |
| 25 | +```text |
| 26 | +https://stats.pphat.top/badge/collection |
| 27 | +``` |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Required Query Parameters |
| 32 | + |
| 33 | +| Parameter | Type | Description | |
| 34 | +|---|---|---| |
| 35 | +| `username` | string | GitHub username | |
| 36 | +| `type` | string | Comma-separated user badge types | |
| 37 | + |
| 38 | +Supported badge types: |
| 39 | +- `visitors` |
| 40 | +- `repositories` |
| 41 | +- `organization` |
| 42 | +- `languages` |
| 43 | +- `followers` |
| 44 | +- `total-stars` |
| 45 | +- `total-contributors` |
| 46 | +- `total-commits` |
| 47 | +- `total-code-reviews` |
| 48 | +- `total-issues` |
| 49 | +- `total-pull-requests` |
| 50 | +- `total-joined-years` |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Optional Query Parameters |
| 55 | + |
| 56 | +| Parameter | Type | Default | Description | |
| 57 | +|---|---|---|---| |
| 58 | +| `columns` | integer | `50` | Grid column count (`1` to `50`) | |
| 59 | +| `gap` | integer | `5` | Space between badges in pixels (`0` to `100`) | |
| 60 | +| `theme` | string | `default` | Theme name | |
| 61 | +| `customLabel` | string | - | Override label text for all badges in the collection | |
| 62 | +| `labelColor` | string | - | Label text color | |
| 63 | +| `labelBackground` | string | - | Label background color | |
| 64 | +| `iconColor` | string | - | Icon color | |
| 65 | +| `valueColor` | string | - | Value text color | |
| 66 | +| `valueBackground` | string | - | Value background color | |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Basic Usage |
| 71 | + |
| 72 | +### 1) Minimal request |
| 73 | + |
| 74 | +```bash |
| 75 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars" |
| 76 | +``` |
| 77 | + |
| 78 | +Preview: |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +### 2) Set explicit columns |
| 83 | + |
| 84 | +```bash |
| 85 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2" |
| 86 | +``` |
| 87 | + |
| 88 | +Preview: |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +### 3) Add spacing with gap |
| 93 | + |
| 94 | +```bash |
| 95 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2&gap=12" |
| 96 | +``` |
| 97 | + |
| 98 | +Preview: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Styling Examples |
| 105 | + |
| 106 | +### Theme |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | +### Custom colors |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +### Custom label applied to all badges |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Embedding |
| 121 | + |
| 122 | +### Markdown |
| 123 | + |
| 124 | +```markdown |
| 125 | + |
| 126 | +``` |
| 127 | + |
| 128 | +### HTML |
| 129 | + |
| 130 | +```html |
| 131 | +<img src="https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2" alt="My Badge Collection" /> |
| 132 | +``` |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +## Error Cases |
| 137 | + |
| 138 | +### Missing `username` |
| 139 | + |
| 140 | +```bash |
| 141 | +curl "https://stats.pphat.top/badge/collection?type=visitors,total-stars" |
| 142 | +``` |
| 143 | + |
| 144 | +### Missing `type` |
| 145 | + |
| 146 | +```bash |
| 147 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev" |
| 148 | +``` |
| 149 | + |
| 150 | +### Invalid `type` |
| 151 | + |
| 152 | +```bash |
| 153 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,unknown" |
| 154 | +``` |
| 155 | + |
| 156 | +### Invalid `columns` |
| 157 | + |
| 158 | +```bash |
| 159 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars&columns=0" |
| 160 | +``` |
| 161 | + |
| 162 | +### Invalid `gap` |
| 163 | + |
| 164 | +```bash |
| 165 | +curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars&gap=500" |
| 166 | +``` |
| 167 | + |
| 168 | +--- |
| 169 | + |
| 170 | +## Notes |
| 171 | + |
| 172 | +- The `visitors` badge in collection mode is read-only and does not increment visitor count. |
| 173 | +- Collection responses are served as `image/svg+xml` with ETag and cache headers. |
| 174 | +- Badge IDs are scoped internally to prevent SVG filter/clip-path collisions. |
0 commit comments