|
| 1 | +# API Endpoint Reference |
| 2 | + |
| 3 | +Base URL: `http://localhost:3000/api/v1` |
| 4 | + |
| 5 | +## Health Endpoints |
| 6 | + |
| 7 | +### GET /health |
| 8 | + |
| 9 | +Simple health check for load balancers. |
| 10 | + |
| 11 | +- **Auth:** None |
| 12 | +- **Response:** `200 OK` |
| 13 | + |
| 14 | +```json |
| 15 | +{ |
| 16 | + "success": true, |
| 17 | + "message": "OK", |
| 18 | + "timestamp": "2025-01-15T10:30:00.000Z" |
| 19 | +} |
| 20 | +``` |
| 21 | + |
| 22 | +### GET /health/ready |
| 23 | + |
| 24 | +Readiness check with dependency probes. |
| 25 | + |
| 26 | +- **Auth:** None |
| 27 | +- **Response:** `200 OK` or `503 Service Unavailable` |
| 28 | + |
| 29 | +```json |
| 30 | +{ |
| 31 | + "ready": true, |
| 32 | + "timestamp": "2025-01-15T10:30:00.000Z", |
| 33 | + "checks": [ |
| 34 | + { "name": "database", "status": "ok", "latencyMs": 12 }, |
| 35 | + { "name": "cache", "status": "ok" } |
| 36 | + ] |
| 37 | +} |
| 38 | +``` |
| 39 | + |
| 40 | +### GET /health/detailed |
| 41 | + |
| 42 | +Full diagnostics including memory and system info. |
| 43 | + |
| 44 | +- **Auth:** None |
| 45 | +- **Response:** `200 OK` |
| 46 | + |
| 47 | +```json |
| 48 | +{ |
| 49 | + "success": true, |
| 50 | + "message": "Access Layer server is running", |
| 51 | + "timestamp": "2025-01-15T10:30:00.000Z", |
| 52 | + "version": "1.0.0", |
| 53 | + "environment": "development", |
| 54 | + "uptime": 12345.67, |
| 55 | + "memory": { "used": 45.23, "total": 128.5 }, |
| 56 | + "system": { "platform": "darwin", "nodeVersion": "v20.10.0" }, |
| 57 | + "database": { "status": "connected", "responseTime": 12 }, |
| 58 | + "services": [ |
| 59 | + { "name": "API Server", "status": "healthy" }, |
| 60 | + { "name": "Database", "status": "healthy" } |
| 61 | + ] |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +--- |
| 66 | + |
| 67 | +## Auth Endpoints |
| 68 | + |
| 69 | +### POST /auth/login |
| 70 | + |
| 71 | +Authenticate a user. |
| 72 | + |
| 73 | +- **Auth:** None |
| 74 | +- **Body:** |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "email": "user@example.com", |
| 79 | + "password": "securepassword" |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +- **Response:** `200 OK` |
| 84 | + |
| 85 | +### POST /auth/register |
| 86 | + |
| 87 | +Register a new user. |
| 88 | + |
| 89 | +- **Auth:** None |
| 90 | +- **Body:** |
| 91 | + |
| 92 | +```json |
| 93 | +{ |
| 94 | + "email": "user@example.com", |
| 95 | + "password": "securepassword", |
| 96 | + "name": "User Name" |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +- **Response:** `201 Created` |
| 101 | + |
| 102 | +--- |
| 103 | + |
| 104 | +## Config Endpoints |
| 105 | + |
| 106 | +### GET /config |
| 107 | + |
| 108 | +Get protocol bootstrap configuration. |
| 109 | + |
| 110 | +- **Auth:** None |
| 111 | +- **Response:** `200 OK` |
| 112 | + |
| 113 | +```json |
| 114 | +{ |
| 115 | + "network": "testnet", |
| 116 | + "contractAddress": "..." |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## Creators Endpoints |
| 123 | + |
| 124 | +### GET /creators |
| 125 | + |
| 126 | +List all creators with pagination. |
| 127 | + |
| 128 | +- **Auth:** None |
| 129 | +- **Query Params:** |
| 130 | + - `page` (number, default: 1) |
| 131 | + - `limit` (number, default: 10) |
| 132 | +- **Response:** `200 OK` |
| 133 | + |
| 134 | +```json |
| 135 | +{ |
| 136 | + "creators": [...], |
| 137 | + "pagination": { |
| 138 | + "page": 1, |
| 139 | + "limit": 10, |
| 140 | + "total": 100 |
| 141 | + } |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +### GET /creators/:id/stats |
| 146 | + |
| 147 | +Get public stats for a specific creator. |
| 148 | + |
| 149 | +- **Auth:** None |
| 150 | +- **Response:** `200 OK` |
| 151 | + |
| 152 | +```json |
| 153 | +{ |
| 154 | + "creatorId": "...", |
| 155 | + "totalSales": 150, |
| 156 | + "totalEarnings": 12500.50 |
| 157 | +} |
| 158 | +``` |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +## Creator Profile Endpoints |
| 163 | + |
| 164 | +### GET /creators/:creatorId/profile |
| 165 | + |
| 166 | +Get creator profile scaffold payload. |
| 167 | + |
| 168 | +- **Auth:** None |
| 169 | +- **Response:** `200 OK` |
| 170 | + |
| 171 | +```json |
| 172 | +{ |
| 173 | + "creatorId": "...", |
| 174 | + "displayName": "Creator Name", |
| 175 | + "bio": "...", |
| 176 | + "avatarUrl": "..." |
| 177 | +} |
| 178 | +``` |
| 179 | + |
| 180 | +### PUT /creators/:creatorId/profile |
| 181 | + |
| 182 | +Upsert creator profile. |
| 183 | + |
| 184 | +- **Auth:** Wallet ownership required |
| 185 | +- **Headers:** |
| 186 | + - `x-wallet-address: <wallet_address>` (must match creator) |
| 187 | +- **Body:** |
| 188 | + |
| 189 | +```json |
| 190 | +{ |
| 191 | + "displayName": "New Name", |
| 192 | + "bio": "Updated bio", |
| 193 | + "avatarUrl": "https://..." |
| 194 | +} |
| 195 | +``` |
| 196 | + |
| 197 | +- **Response:** `200 OK` |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## Metrics Endpoints |
| 202 | + |
| 203 | +### GET /metrics/queues |
| 204 | + |
| 205 | +Queue depth metrics for indexer workers. |
| 206 | + |
| 207 | +- **Auth:** None |
| 208 | +- **Response:** `200 OK` |
| 209 | + |
| 210 | +```json |
| 211 | +{ |
| 212 | + "queues": { |
| 213 | + "indexer": { "depth": 42, "processing": 5 }, |
| 214 | + "notifications": { "depth": 10, "processing": 2 } |
| 215 | + } |
| 216 | +} |
| 217 | +``` |
| 218 | + |
| 219 | +--- |
| 220 | + |
| 221 | +## Admin Endpoints |
| 222 | + |
| 223 | +### PATCH /admin/creators/:id/metadata |
| 224 | + |
| 225 | +Update creator metadata. |
| 226 | + |
| 227 | +- **Auth:** Admin required |
| 228 | +- **Body:** |
| 229 | + |
| 230 | +```json |
| 231 | +{ |
| 232 | + "metadata": { "key": "value" } |
| 233 | +} |
| 234 | +``` |
| 235 | + |
| 236 | +- **Response:** `200 OK` |
| 237 | + |
| 238 | +### POST /admin/indexer/replay |
| 239 | + |
| 240 | +Replay indexer events. |
| 241 | + |
| 242 | +- **Auth:** Admin required |
| 243 | +- **Response:** `200 OK` |
| 244 | + |
| 245 | +--- |
| 246 | + |
| 247 | +## Common Headers |
| 248 | + |
| 249 | +| Header | Description | |
| 250 | +|--------|-------------| |
| 251 | +| `x-wallet-address` | Wallet address for ownership verification | |
| 252 | +| `Authorization` | Bearer token for authenticated requests | |
| 253 | +| `Content-Type` | `application/json` | |
| 254 | + |
| 255 | +## Error Responses |
| 256 | + |
| 257 | +```json |
| 258 | +{ |
| 259 | + "success": false, |
| 260 | + "message": "Error description", |
| 261 | + "error": "Detailed error (dev only)" |
| 262 | +} |
| 263 | +``` |
| 264 | + |
| 265 | +| Status | Description | |
| 266 | +|--------|-------------| |
| 267 | +| 400 | Bad request / validation error | |
| 268 | +| 401 | Unauthorized | |
| 269 | +| 403 | Forbidden | |
| 270 | +| 404 | Not found | |
| 271 | +| 429 | Rate limit exceeded | |
| 272 | +| 500 | Internal server error | |
| 273 | + |
| 274 | +--- |
| 275 | + |
| 276 | +See [Local Setup](./local-setup.md) for development environment configuration. |
0 commit comments