hammerAPI 0.1.0__tar.gz → 0.1.2__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.
- hammerapi-0.1.2/PKG-INFO +448 -0
- hammerapi-0.1.2/README.md +432 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/pyproject.toml +1 -1
- hammerapi-0.1.0/PKG-INFO +0 -450
- hammerapi-0.1.0/README.md +0 -434
- {hammerapi-0.1.0 → hammerapi-0.1.2}/.gitignore +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/LICENSE +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/examples/hammer_report.html +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/examples/sample-code.py +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/examples/sample-report.jpeg +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/logo.png +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/logo_readme.png +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/src/hammerapi/__init__.py +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/src/hammerapi/monitor.py +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/src/hammerapi/reporter.py +0 -0
- {hammerapi-0.1.0 → hammerapi-0.1.2}/src/hammerapi/runner.py +0 -0
hammerapi-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hammerAPI
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A lightweight, blazing-fast, multi-threaded API performance and load testing library for Python. HammerAPI allows you to orchestrate parallel API requests smoothly while automatically collecting cross-platform hardware telemetry (CPU/RAM usage) from your local machine, compiling everything into a self-contained, interactive HTML dashboard.
|
|
5
|
+
Project-URL: Homepage, https://github.com/shayansaha85/hammerAPI
|
|
6
|
+
Author-email: Shayan <shayan851997@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Requires-Dist: httpx>=0.24.0
|
|
14
|
+
Requires-Dist: psutil>=5.9.0
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[](https://pypi.org/project/hammerapi/)
|
|
21
|
+
[](https://opensource.org/licenses/MIT)
|
|
22
|
+
|
|
23
|
+
A lightweight, blazing-fast, multi-threaded API performance and load testing library for Python.
|
|
24
|
+
|
|
25
|
+
**HammerAPI** helps developers, QA engineers, SREs, and performance testers stress-test REST APIs with minimal code while automatically collecting local machine telemetry (CPU/RAM) and generating beautiful interactive HTML reports.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🚀 Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install hammerapi
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## ✨ Features
|
|
38
|
+
|
|
39
|
+
### 🧵 Concurrent API Execution
|
|
40
|
+
|
|
41
|
+
Run hundreds or thousands of requests using a configurable thread pool.
|
|
42
|
+
|
|
43
|
+
### ⏱️ Multiple Execution Modes
|
|
44
|
+
|
|
45
|
+
* Run each test case exactly once
|
|
46
|
+
* Run continuously for a fixed duration
|
|
47
|
+
* Mix multiple endpoints in the same workload
|
|
48
|
+
|
|
49
|
+
### 🌐 Full HTTP Support
|
|
50
|
+
|
|
51
|
+
Supports:
|
|
52
|
+
|
|
53
|
+
* GET
|
|
54
|
+
* POST
|
|
55
|
+
* PUT
|
|
56
|
+
* PATCH
|
|
57
|
+
* DELETE
|
|
58
|
+
|
|
59
|
+
### 🔐 Authentication Support
|
|
60
|
+
|
|
61
|
+
Works with:
|
|
62
|
+
|
|
63
|
+
* Bearer Tokens
|
|
64
|
+
* API Keys
|
|
65
|
+
* Custom Headers
|
|
66
|
+
* Session Cookies
|
|
67
|
+
|
|
68
|
+
### 📊 Performance Metrics
|
|
69
|
+
|
|
70
|
+
Automatically captures:
|
|
71
|
+
|
|
72
|
+
* Response Time
|
|
73
|
+
* Success / Failure Counts
|
|
74
|
+
* Request Throughput
|
|
75
|
+
* Average Latency
|
|
76
|
+
* P90 Latency
|
|
77
|
+
* P95 Latency
|
|
78
|
+
* P99 Latency
|
|
79
|
+
|
|
80
|
+
### 🖥️ System Resource Monitoring
|
|
81
|
+
|
|
82
|
+
Captures local machine:
|
|
83
|
+
|
|
84
|
+
* CPU Utilization
|
|
85
|
+
* RAM Utilization
|
|
86
|
+
* Operating System Information
|
|
87
|
+
|
|
88
|
+
### 📈 Interactive HTML Dashboard
|
|
89
|
+
|
|
90
|
+
Generate beautiful standalone reports with:
|
|
91
|
+
|
|
92
|
+
* Charts
|
|
93
|
+
* Percentiles
|
|
94
|
+
* Error Analysis
|
|
95
|
+
* Resource Consumption Trends
|
|
96
|
+
* Request Distribution
|
|
97
|
+
|
|
98
|
+
### 🌍 Cross Platform
|
|
99
|
+
|
|
100
|
+
Works on:
|
|
101
|
+
|
|
102
|
+
* Windows
|
|
103
|
+
* Linux
|
|
104
|
+
* macOS
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
# 📁 Project Structure
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
hammerAPI/
|
|
112
|
+
├── LICENSE
|
|
113
|
+
├── README.md
|
|
114
|
+
├── pyproject.toml
|
|
115
|
+
├── logo.png
|
|
116
|
+
├── logo_readme.png
|
|
117
|
+
├── src/
|
|
118
|
+
│ └── hammerapi/
|
|
119
|
+
│ ├── __init__.py
|
|
120
|
+
│ ├── monitor.py
|
|
121
|
+
│ ├── reporter.py
|
|
122
|
+
│ └── runner.py
|
|
123
|
+
└── examples/
|
|
124
|
+
├── sample-code.py
|
|
125
|
+
├── sample-report.html
|
|
126
|
+
└── sample-report.jpeg
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
# Quick Start
|
|
132
|
+
|
|
133
|
+
## Simple GET Request
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from hammerapi import HammerAPI
|
|
137
|
+
|
|
138
|
+
hammer = HammerAPI(max_workers=5)
|
|
139
|
+
|
|
140
|
+
hammer.add_test(
|
|
141
|
+
method="GET",
|
|
142
|
+
url="https://jsonplaceholder.typicode.com/posts/1"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
hammer.run()
|
|
146
|
+
|
|
147
|
+
hammer.generate_report()
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Multiple Endpoints
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from hammerapi import HammerAPI
|
|
156
|
+
|
|
157
|
+
hammer = HammerAPI(max_workers=10)
|
|
158
|
+
|
|
159
|
+
hammer.add_test(
|
|
160
|
+
"GET",
|
|
161
|
+
"https://jsonplaceholder.typicode.com/posts/1"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
hammer.add_test(
|
|
165
|
+
"GET",
|
|
166
|
+
"https://jsonplaceholder.typicode.com/users/1"
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
hammer.add_test(
|
|
170
|
+
"GET",
|
|
171
|
+
"https://jsonplaceholder.typicode.com/comments/1"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
hammer.run()
|
|
175
|
+
|
|
176
|
+
hammer.generate_report()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## POST Request with JSON Payload
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
from hammerapi import HammerAPI
|
|
185
|
+
|
|
186
|
+
hammer = HammerAPI()
|
|
187
|
+
|
|
188
|
+
hammer.add_test(
|
|
189
|
+
method="POST",
|
|
190
|
+
url="https://jsonplaceholder.typicode.com/posts",
|
|
191
|
+
json={
|
|
192
|
+
"title": "HammerAPI",
|
|
193
|
+
"body": "Load Testing",
|
|
194
|
+
"userId": 1
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
hammer.run()
|
|
199
|
+
hammer.generate_report()
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Authenticated API Testing
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from hammerapi import HammerAPI
|
|
208
|
+
|
|
209
|
+
hammer = HammerAPI()
|
|
210
|
+
|
|
211
|
+
hammer.add_test(
|
|
212
|
+
method="GET",
|
|
213
|
+
url="https://api.example.com/users",
|
|
214
|
+
headers={
|
|
215
|
+
"Authorization": "Bearer YOUR_TOKEN"
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
hammer.run()
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## API Key Authentication
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
from hammerapi import HammerAPI
|
|
228
|
+
|
|
229
|
+
hammer = HammerAPI()
|
|
230
|
+
|
|
231
|
+
hammer.add_test(
|
|
232
|
+
method="GET",
|
|
233
|
+
url="https://api.example.com/data",
|
|
234
|
+
headers={
|
|
235
|
+
"x-api-key": "YOUR_API_KEY"
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
hammer.run()
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Query Parameters
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
from hammerapi import HammerAPI
|
|
248
|
+
|
|
249
|
+
hammer = HammerAPI()
|
|
250
|
+
|
|
251
|
+
hammer.add_test(
|
|
252
|
+
method="GET",
|
|
253
|
+
url="https://api.example.com/search",
|
|
254
|
+
params={
|
|
255
|
+
"page": 1,
|
|
256
|
+
"limit": 100
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
hammer.run()
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Custom Headers
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
from hammerapi import HammerAPI
|
|
269
|
+
|
|
270
|
+
hammer = HammerAPI()
|
|
271
|
+
|
|
272
|
+
hammer.add_test(
|
|
273
|
+
method="GET",
|
|
274
|
+
url="https://api.example.com/data",
|
|
275
|
+
headers={
|
|
276
|
+
"Environment": "QA",
|
|
277
|
+
"Client": "HammerAPI"
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
hammer.run()
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## PUT Request
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
hammer.add_test(
|
|
290
|
+
method="PUT",
|
|
291
|
+
url="https://api.example.com/user/1",
|
|
292
|
+
json={
|
|
293
|
+
"name": "John Doe"
|
|
294
|
+
}
|
|
295
|
+
)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## PATCH Request
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
hammer.add_test(
|
|
304
|
+
method="PATCH",
|
|
305
|
+
url="https://api.example.com/user/1",
|
|
306
|
+
json={
|
|
307
|
+
"status": "active"
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## DELETE Request
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
hammer.add_test(
|
|
318
|
+
method="DELETE",
|
|
319
|
+
url="https://api.example.com/user/1"
|
|
320
|
+
)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
# 🔥 Load Testing For Fixed Duration
|
|
326
|
+
|
|
327
|
+
Continuously hit endpoints for a specific duration.
|
|
328
|
+
|
|
329
|
+
```python
|
|
330
|
+
from hammerapi import HammerAPI
|
|
331
|
+
|
|
332
|
+
hammer = HammerAPI(max_workers=25)
|
|
333
|
+
|
|
334
|
+
hammer.add_test(
|
|
335
|
+
"GET",
|
|
336
|
+
"https://api.example.com/health"
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
hammer.run(duration_seconds=60)
|
|
340
|
+
|
|
341
|
+
hammer.generate_report("load_test_report.html")
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
This will continuously execute requests across 25 worker threads for 60 seconds.
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
# ⚡ High Concurrency Example
|
|
349
|
+
|
|
350
|
+
```python
|
|
351
|
+
from hammerapi import HammerAPI
|
|
352
|
+
|
|
353
|
+
hammer = HammerAPI(max_workers=100)
|
|
354
|
+
|
|
355
|
+
hammer.add_test(
|
|
356
|
+
"GET",
|
|
357
|
+
"https://api.example.com/health"
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
hammer.run(duration_seconds=120)
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Perfect for:
|
|
364
|
+
|
|
365
|
+
* Load Testing
|
|
366
|
+
* Stress Testing
|
|
367
|
+
* Smoke Testing
|
|
368
|
+
* Capacity Planning
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
# 📄 Generate Report
|
|
373
|
+
|
|
374
|
+
```python
|
|
375
|
+
hammer.generate_report(
|
|
376
|
+
output_path="hammer_report.html"
|
|
377
|
+
)
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
Generated report includes:
|
|
381
|
+
|
|
382
|
+
* Total Requests
|
|
383
|
+
* Success Rate
|
|
384
|
+
* Failure Rate
|
|
385
|
+
* Average Response Time
|
|
386
|
+
* P90 Latency
|
|
387
|
+
* P95 Latency
|
|
388
|
+
* P99 Latency
|
|
389
|
+
* CPU Utilization
|
|
390
|
+
* RAM Utilization
|
|
391
|
+
* Throughput Analysis
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
# Report Snapshot
|
|
396
|
+
|
|
397
|
+

|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
# Example Files
|
|
402
|
+
|
|
403
|
+
See the `examples/` directory:
|
|
404
|
+
|
|
405
|
+
```text
|
|
406
|
+
examples/
|
|
407
|
+
├── sample-code.py
|
|
408
|
+
├── sample-report.html
|
|
409
|
+
└── sample-report.jpeg
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
# Use Cases
|
|
415
|
+
|
|
416
|
+
### QA Engineers
|
|
417
|
+
|
|
418
|
+
* Regression Testing
|
|
419
|
+
* Smoke Testing
|
|
420
|
+
* API Validation
|
|
421
|
+
|
|
422
|
+
### SRE Teams
|
|
423
|
+
|
|
424
|
+
* Capacity Testing
|
|
425
|
+
* Reliability Benchmarking
|
|
426
|
+
* SLA Validation
|
|
427
|
+
|
|
428
|
+
### Developers
|
|
429
|
+
|
|
430
|
+
* Endpoint Benchmarking
|
|
431
|
+
* Performance Optimization
|
|
432
|
+
|
|
433
|
+
### DevOps Engineers
|
|
434
|
+
|
|
435
|
+
* Pre-Deployment Validation
|
|
436
|
+
* Infrastructure Load Testing
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
# License
|
|
441
|
+
|
|
442
|
+
MIT License
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
### Attribution
|
|
447
|
+
|
|
448
|
+
<a href="https://www.flaticon.com/free-icons/hammer" title="hammer icons">Hammer icons created by nawicon - Flaticon</a>
|