secureflow-api-rate-LIMITER 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- secureflow_api_rate_limiter-1.0.1/PKG-INFO +486 -0
- secureflow_api_rate_limiter-1.0.1/README.md +435 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/__init__.py +0 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/auth.py +563 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/database.py +713 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/email_notifier.py +154 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/geo_router.py +551 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/load_balancer.py +967 -0
- secureflow_api_rate_limiter-1.0.1/api_shield/log_manager.py +497 -0
- secureflow_api_rate_limiter-1.0.1/secureflow_api_rate_LIMITER.egg-info/PKG-INFO +486 -0
- secureflow_api_rate_limiter-1.0.1/secureflow_api_rate_LIMITER.egg-info/SOURCES.txt +14 -0
- secureflow_api_rate_limiter-1.0.1/secureflow_api_rate_LIMITER.egg-info/dependency_links.txt +1 -0
- secureflow_api_rate_limiter-1.0.1/secureflow_api_rate_LIMITER.egg-info/requires.txt +13 -0
- secureflow_api_rate_limiter-1.0.1/secureflow_api_rate_LIMITER.egg-info/top_level.txt +1 -0
- secureflow_api_rate_limiter-1.0.1/setup.cfg +4 -0
- secureflow_api_rate_limiter-1.0.1/setup.py +57 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: secureflow-api-rate-LIMITER
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Open-source API rate limiting and protection toolkit with dynamic configuration
|
|
5
|
+
Home-page: https://github.com/samadrehman/secureflow-api-rate-LIMITER
|
|
6
|
+
Author: Samad Rehman
|
|
7
|
+
Author-email: samadrehman550@gmail.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/samadrehman/secureflow-api-rate-LIMITER/issues
|
|
9
|
+
Project-URL: Source, https://github.com/samadrehman/secureflow-api-rate-LIMITER
|
|
10
|
+
Keywords: rate-limiting api-protection security rate-limiter
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Framework :: Flask
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: System :: Networking
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
Requires-Dist: Flask==2.3.3
|
|
28
|
+
Requires-Dist: flask-cors==4.0.0
|
|
29
|
+
Requires-Dist: flask-socketio==5.3.6
|
|
30
|
+
Requires-Dist: python-socketio==5.9.0
|
|
31
|
+
Requires-Dist: PyJWT==2.8.0
|
|
32
|
+
Requires-Dist: bcrypt==4.1.2
|
|
33
|
+
Requires-Dist: requests==2.31.0
|
|
34
|
+
Requires-Dist: python-dotenv==1.0.0
|
|
35
|
+
Requires-Dist: aiohttp==3.9.1
|
|
36
|
+
Requires-Dist: pytz==2023.3
|
|
37
|
+
Requires-Dist: gunicorn==21.2.0
|
|
38
|
+
Requires-Dist: geoip2==4.7.0
|
|
39
|
+
Requires-Dist: redis==5.0.1
|
|
40
|
+
Dynamic: author
|
|
41
|
+
Dynamic: author-email
|
|
42
|
+
Dynamic: classifier
|
|
43
|
+
Dynamic: description
|
|
44
|
+
Dynamic: description-content-type
|
|
45
|
+
Dynamic: home-page
|
|
46
|
+
Dynamic: keywords
|
|
47
|
+
Dynamic: project-url
|
|
48
|
+
Dynamic: requires-dist
|
|
49
|
+
Dynamic: requires-python
|
|
50
|
+
Dynamic: summary
|
|
51
|
+
|
|
52
|
+
# API Rate Limiter
|
|
53
|
+
|
|
54
|
+
**Open-source, self-hosted API rate limiting service** with JWT authentication, dynamic rate limit configuration, API key management, admin controls, SDK integration, and optional load balancer support.
|
|
55
|
+
|
|
56
|
+
> **100% Free & Open Source** - No subscription system, no billing, just pure rate limiting protection!
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
✅ **Dynamic Rate Limiting** - Configure rate limits at startup and adjust per API key
|
|
61
|
+
✅ **Zero Subscription System** - Completely free and open-source
|
|
62
|
+
✅ **JWT Authentication** - Secure user registration, login, and token refresh
|
|
63
|
+
✅ **API Key Management** - Generate and manage API keys with custom rate limits
|
|
64
|
+
✅ **Admin Controls** - Dashboard to manage users, set custom rate limits, block/unblock keys
|
|
65
|
+
✅ **SDK Integration** - JavaScript SDK for frontend rate limit checking
|
|
66
|
+
✅ **Real-time Monitoring** - WebSocket-based live dashboard
|
|
67
|
+
✅ **Multi-deployment** - Docker, Kubernetes, or standalone Python
|
|
68
|
+
✅ **Distributed via npm & pip** - Easy installation for all developers
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
### Prerequisites
|
|
73
|
+
|
|
74
|
+
- Python 3.8+
|
|
75
|
+
- Docker and Docker Compose (optional)
|
|
76
|
+
- `kubectl` and a Kubernetes cluster (optional)
|
|
77
|
+
|
|
78
|
+
### Install dependencies
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install -r requirements.txt
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Run locally with interactive setup
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
python app.py
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
On first run, you'll be prompted to configure:
|
|
91
|
+
- **Requests per window** - Max requests allowed (default: 100)
|
|
92
|
+
- **Time window** - Window duration in seconds (default: 60)
|
|
93
|
+
|
|
94
|
+
Example:
|
|
95
|
+
```
|
|
96
|
+
Enter max requests per window [100]: 50
|
|
97
|
+
Enter time window in seconds [60]: 30
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then open your browser to `http://localhost:5000/dashboard`
|
|
101
|
+
|
|
102
|
+
### Docker Compose
|
|
103
|
+
|
|
104
|
+
1. Create or update `.env` in the repository root.
|
|
105
|
+
2. Start the application:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
docker compose up --build -d
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
3. Open the service at:
|
|
112
|
+
|
|
113
|
+
- API: `http://localhost:8000`
|
|
114
|
+
- Dashboard: `http://localhost:8000/dashboard`
|
|
115
|
+
- SDK demo: `http://localhost:8000/sdk`
|
|
116
|
+
|
|
117
|
+
### Kubernetes
|
|
118
|
+
|
|
119
|
+
1. Build the Docker image:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
docker build -t api-rate-limiter:latest .
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. Update `k8s/secret.yaml` with real secrets.
|
|
126
|
+
3. Apply manifests:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
kubectl apply -f k8s/pvc.yaml
|
|
130
|
+
kubectl apply -f k8s/configmap.yaml
|
|
131
|
+
kubectl apply -f k8s/secret.yaml
|
|
132
|
+
kubectl apply -f k8s/deployment.yaml
|
|
133
|
+
kubectl apply -f k8s/service.yaml
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
4. Forward a port if needed:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
kubectl port-forward svc/api-rate-limiter-service 8000:80
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Quick-Start Guide
|
|
143
|
+
|
|
144
|
+
### 1) Start the app
|
|
145
|
+
|
|
146
|
+
For development:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pip install -r requirements.txt
|
|
150
|
+
python app.py
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Then open `http://localhost:5000/dashboard`.
|
|
154
|
+
|
|
155
|
+
### 2) Register a user
|
|
156
|
+
|
|
157
|
+
Send a request to create a new account:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
curl -X POST http://localhost:5000/auth/register \
|
|
161
|
+
-H "Content-Type: application/json" \
|
|
162
|
+
-d '{"email":"user@example.com","password":"Secret123"}'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 3) Login and receive tokens
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
curl -X POST http://localhost:5000/auth/login \
|
|
169
|
+
-H "Content-Type: application/json" \
|
|
170
|
+
-d '{"email":"user@example.com","password":"Secret123"}'
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 4) Create an API key
|
|
174
|
+
|
|
175
|
+
Use the returned access token:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
curl -X POST http://localhost:5000/auth/create_api_key \
|
|
179
|
+
-H "Authorization: Bearer <ACCESS_TOKEN>" \
|
|
180
|
+
-H "Content-Type: application/json"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 5) Call protected data endpoint
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
curl "http://localhost:5000/data?api_key=<YOUR_API_KEY>"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Examples
|
|
190
|
+
|
|
191
|
+
### Example 1: Health check
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
curl http://localhost:5000/health
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Example 2: Fetch usage data
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
curl "http://localhost:5000/usage?api_key=<YOUR_API_KEY>"
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Example 3: SDK check
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
curl -X POST http://localhost:5000/sdk/check \
|
|
207
|
+
-H "Content-Type: application/json" \
|
|
208
|
+
-d '{"api_key":"<YOUR_API_KEY>","endpoint":"/data","method":"GET"}'
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Example 4: SDK tracking
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
curl -X POST http://localhost:5000/sdk/track \
|
|
215
|
+
-H "Content-Type: application/json" \
|
|
216
|
+
-d '{"api_key":"<YOUR_API_KEY>","endpoint":"/data","method":"GET","status_code":200,"response_time_ms":123}'
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Dynamic Rate Limiting Configuration
|
|
220
|
+
|
|
221
|
+
### Startup Configuration
|
|
222
|
+
|
|
223
|
+
When you run `python app.py`, you'll be prompted to configure rate limits interactively:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
📋 SETUP - Configure Your Rate Limits
|
|
227
|
+
Enter max requests per window [100]: 50
|
|
228
|
+
Enter time window in seconds [60]: 30
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
These settings become the **default rate limits** for all new API keys.
|
|
232
|
+
|
|
233
|
+
### Per-Key Rate Limit Configuration
|
|
234
|
+
|
|
235
|
+
Use the admin endpoint to set custom rate limits for specific API keys:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
curl -X POST http://localhost:5000/admin/set_rate_limit \
|
|
239
|
+
-H "Authorization: Bearer <ADMIN_TOKEN>" \
|
|
240
|
+
-H "Content-Type: application/json" \
|
|
241
|
+
-d '{
|
|
242
|
+
"api_key": "<YOUR_API_KEY>",
|
|
243
|
+
"requests": 100,
|
|
244
|
+
"window": 60
|
|
245
|
+
}'
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Parameters:**
|
|
249
|
+
- `api_key` - The API key to configure
|
|
250
|
+
- `requests` - Maximum requests allowed per window (required)
|
|
251
|
+
- `window` - Time window in seconds (required)
|
|
252
|
+
|
|
253
|
+
**Response:**
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"status": "success",
|
|
257
|
+
"rate_limit_requests": 100,
|
|
258
|
+
"rate_limit_window": 60
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Check Rate Limit Usage
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
curl "http://localhost:5000/usage?api_key=<YOUR_API_KEY>"
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Response:**
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"requests_left": 45,
|
|
272
|
+
"requests_limit": 100,
|
|
273
|
+
"window_seconds": 60,
|
|
274
|
+
"total_requests_lifetime": 5000
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Admin Endpoints
|
|
279
|
+
|
|
280
|
+
### Set Custom Rate Limit
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
POST /admin/set_rate_limit
|
|
284
|
+
Authorization: Bearer <ADMIN_TOKEN>
|
|
285
|
+
Content-Type: application/json
|
|
286
|
+
|
|
287
|
+
{
|
|
288
|
+
"api_key": "rk_live_...",
|
|
289
|
+
"requests": 100,
|
|
290
|
+
"window": 60
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Get All Users
|
|
295
|
+
|
|
296
|
+
```
|
|
297
|
+
GET /admin/users
|
|
298
|
+
Authorization: Bearer <ADMIN_TOKEN>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Block API Key
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
POST /admin/block_key
|
|
305
|
+
Authorization: Bearer <ADMIN_TOKEN>
|
|
306
|
+
Content-Type: application/json
|
|
307
|
+
|
|
308
|
+
{
|
|
309
|
+
"api_key": "rk_live_..."
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Unblock API Key
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
POST /admin/unblock_key
|
|
317
|
+
Authorization: Bearer <ADMIN_TOKEN>
|
|
318
|
+
Content-Type: application/json
|
|
319
|
+
|
|
320
|
+
{
|
|
321
|
+
"api_key": "rk_live_..."
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Installation Methods
|
|
326
|
+
|
|
327
|
+
### Via pip (Python)
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
pip install api-rate-limiter
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Then run:
|
|
334
|
+
```bash
|
|
335
|
+
python -m api_shield.app
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Via npm
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
npm install api-rate-limiter
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Then use the CLI:
|
|
345
|
+
```bash
|
|
346
|
+
npm start
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Via Docker
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
docker build -t api-rate-limiter .
|
|
353
|
+
docker run -p 5000:5000 api-rate-limiter
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### From Source
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
git clone https://github.com/yourusername/api-rate-limiter.git
|
|
360
|
+
cd api-rate-limiter
|
|
361
|
+
pip install -r requirements.txt
|
|
362
|
+
python app.py
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Features & Benefits
|
|
366
|
+
|
|
367
|
+
- ✅ **100% Free** - No subscription, no licensing fees
|
|
368
|
+
- ✅ **Open Source** - MIT License, fully customizable
|
|
369
|
+
- ✅ **Production Ready** - Used in real-world deployments
|
|
370
|
+
- ✅ **Dynamic Configuration** - Change rate limits without restarting
|
|
371
|
+
- ✅ **Multiple Deployment Options** - Docker, Kubernetes, or standalone
|
|
372
|
+
- ✅ **Comprehensive Admin Panel** - Manage users and limits from web UI
|
|
373
|
+
- ✅ **Real-time Monitoring** - WebSocket dashboard with live metrics
|
|
374
|
+
- ✅ **SDK Integration** - Browser-ready rate limiting checks
|
|
375
|
+
- ✅ **Secure** - JWT authentication, API key hashing, IP protection
|
|
376
|
+
|
|
377
|
+
## Environment Variables
|
|
378
|
+
|
|
379
|
+
Create a `.env` file in the project root:
|
|
380
|
+
|
|
381
|
+
```env
|
|
382
|
+
FLASK_ENV=development
|
|
383
|
+
SECRET_KEY=your-secret-key-here
|
|
384
|
+
ADMIN_TOKEN=your-admin-token-here
|
|
385
|
+
DATABASE_URL=sqlite:///ratelimiter.db
|
|
386
|
+
CORS_ORIGINS=http://localhost:5000,http://localhost:3000
|
|
387
|
+
EMAIL_NOTIFICATIONS=false
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Contributing
|
|
391
|
+
|
|
392
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
393
|
+
|
|
394
|
+
## License
|
|
395
|
+
|
|
396
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
397
|
+
|
|
398
|
+
## Support
|
|
399
|
+
|
|
400
|
+
- 📖 [API Documentation](./API_DOCUMENTATION.md)
|
|
401
|
+
- 📧 Email: samadrehman550@gmail.com
|
|
402
|
+
- 🐛 [Report Issues](https://github.com/yourusername/api-rate-limiter/issues)
|
|
403
|
+
|
|
404
|
+
## Roadmap
|
|
405
|
+
|
|
406
|
+
- [ ] GraphQL API support
|
|
407
|
+
- [ ] Advanced analytics dashboard
|
|
408
|
+
- [ ] Machine learning-based anomaly detection
|
|
409
|
+
- [ ] Webhook notifications
|
|
410
|
+
- [ ] Rate limit templates & presets
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
**Made with ❤️ by Samad Rehman**
|
|
415
|
+
|
|
416
|
+
## SDK Usage
|
|
417
|
+
|
|
418
|
+
The repository includes a browser SDK demo page and two SDK API endpoints.
|
|
419
|
+
|
|
420
|
+
- Demo page: `http://localhost:5000/sdk`
|
|
421
|
+
- Browser SDK script: `http://localhost:5000/sdk.js`
|
|
422
|
+
|
|
423
|
+
### SDK flow
|
|
424
|
+
|
|
425
|
+
1. Call `/sdk/check` before the real request to verify allowance.
|
|
426
|
+
2. Send the actual request if allowed.
|
|
427
|
+
3. Report request telemetry to `/sdk/track`.
|
|
428
|
+
|
|
429
|
+
### Example: browser-like flow
|
|
430
|
+
|
|
431
|
+
```bash
|
|
432
|
+
curl -X POST http://localhost:5000/sdk/check \
|
|
433
|
+
-H "Content-Type: application/json" \
|
|
434
|
+
-d '{"api_key":"<YOUR_API_KEY>","endpoint":"/data","method":"GET"}'
|
|
435
|
+
|
|
436
|
+
curl "http://localhost:5000/data?api_key=<YOUR_API_KEY>"
|
|
437
|
+
|
|
438
|
+
curl -X POST http://localhost:5000/sdk/track \
|
|
439
|
+
-H "Content-Type: application/json" \
|
|
440
|
+
-d '{"api_key":"<YOUR_API_KEY>","endpoint":"/data","method":"GET","status_code":200,"response_time_ms":123}'
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Deep Example: Full usage flow
|
|
444
|
+
|
|
445
|
+
This example shows a complete request flow from registration through rate-limited access.
|
|
446
|
+
|
|
447
|
+
1. Register user.
|
|
448
|
+
2. Login and receive `access_token`.
|
|
449
|
+
3. Create an API key.
|
|
450
|
+
4. Check rate-limit allowance with SDK.
|
|
451
|
+
5. Call the protected endpoint.
|
|
452
|
+
6. Inspect usage.
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
# Register
|
|
456
|
+
curl -X POST http://localhost:5000/auth/register \
|
|
457
|
+
-H "Content-Type: application/json" \
|
|
458
|
+
-d '{"email":"user@example.com","password":"Secret123"}'
|
|
459
|
+
|
|
460
|
+
# Login
|
|
461
|
+
curl -X POST http://localhost:5000/auth/login \
|
|
462
|
+
-H "Content-Type: application/json" \
|
|
463
|
+
-d '{"email":"user@example.com","password":"Secret123"}'
|
|
464
|
+
|
|
465
|
+
# Create API key
|
|
466
|
+
curl -X POST http://localhost:5000/auth/create_api_key \
|
|
467
|
+
-H "Authorization: Bearer <ACCESS_TOKEN>" \
|
|
468
|
+
-H "Content-Type: application/json"
|
|
469
|
+
|
|
470
|
+
# SDK check before request
|
|
471
|
+
curl -X POST http://localhost:5000/sdk/check \
|
|
472
|
+
-H "Content-Type: application/json" \
|
|
473
|
+
-d '{"api_key":"<YOUR_API_KEY>","endpoint":"/data","method":"GET"}'
|
|
474
|
+
|
|
475
|
+
# Make protected request
|
|
476
|
+
curl "http://localhost:5000/data?api_key=<YOUR_API_KEY>"
|
|
477
|
+
|
|
478
|
+
# View usage
|
|
479
|
+
curl "http://localhost:5000/usage?api_key=<YOUR_API_KEY>"
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## Notes
|
|
483
|
+
|
|
484
|
+
- Use `API_DOCUMENTATION.md` for endpoint reference and deeper API examples.
|
|
485
|
+
- The default rate limit behavior is tier-based and can be adjusted through configuration.
|
|
486
|
+
- For production, prefer Docker Compose or Kubernetes deployment.
|