API-ARM: Application Programming Interface with Automated Request Manipulator
Project description
API-ARM ๐ฆพ
Application Programming Interface with Automated Request Manipulator
API-ARM is a powerful Python tool that analyzes APIs, determines their usage patterns, and mimics secure requests to return anticipated results.
โจ Features
| Feature | Description |
|---|---|
| ๐ API Analysis | Auto-discover endpoints, auth methods, and rate limits from OpenAPI/Swagger |
| ๐ Multi-Auth Support | API Key, Bearer Token, Basic Auth, OAuth 2.0 |
| ๐ก Smart Requests | Make properly authenticated requests with retry logic |
| ๐ Request Logging | Track all requests with timing and statistics |
| โก Response Caching | LRU cache with TTL for faster repeated requests |
| ๐ฅ๏ธ Beautiful CLI | Terminal interface with Rich formatting |
๐ Installation
# Clone the repository
git clone https://github.com/yourusername/apiarm.git
cd apiarm
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
๐ Quick Start
Python API
import asyncio
from apiarm import APIArm
async def main():
async with APIArm("https://api.example.com") as arm:
# Configure authentication
arm.set_api_key("your-api-key")
# Enable logging and caching
arm.enable_logging(console=True)
arm.enable_caching(max_size=100, default_ttl=300)
# Analyze the API
analysis = await arm.analyze()
print(f"Found {analysis.endpoint_count} endpoints")
# Make requests
response = await arm.get("/users")
print(response.data)
# Print statistics
arm.print_stats()
asyncio.run(main())
CLI Commands
# Analyze an API
apiarm analyze https://api.example.com
# Make a GET request
apiarm request https://api.example.com/users
# Make a POST request with data
apiarm request https://api.example.com/users -m POST -d '{"name": "John"}'
# With authentication
apiarm request https://api.example.com/users -k "your-api-key"
apiarm request https://api.example.com/users -b "your-bearer-token"
๐๏ธ Project Structure
apiarm/
โโโ apiarm/ # Main package
โ โโโ __init__.py
โ โโโ cli.py # Command-line interface
โ โโโ core/
โ โ โโโ analyzer.py # API analysis engine
โ โ โโโ requester.py # Request handling
โ โ โโโ security.py # Authentication
โ โ โโโ logger.py # Request logging
โ โ โโโ cache.py # Response caching
โ โ โโโ arm.py # Main unified interface
โ โโโ models/
โ โ โโโ endpoint.py # Endpoint model
โ โ โโโ response.py # Response model
โ โโโ utils/
โ โโโ helpers.py # Utility functions
โโโ examples/
โ โโโ basic_usage.py
โโโ tests/
โโโ requirements.txt
โโโ pyproject.toml
๐ Authentication Methods
from apiarm import APIArm
from apiarm.models import AuthMethod
async with APIArm("https://api.example.com") as arm:
# API Key
arm.set_api_key("your-key", header_name="X-API-Key")
# Bearer Token
arm.set_bearer_token("your-token")
# Or use configure_auth for any method
arm.configure_auth(
AuthMethod.BASIC,
username="user",
password="pass"
)
arm.configure_auth(
AuthMethod.OAUTH2,
client_id="id",
client_secret="secret",
token="access-token"
)
๐ Logging & Caching
from pathlib import Path
async with APIArm("https://api.example.com") as arm:
# Enable console logging
arm.enable_logging(console=True)
# Log to file (JSON lines format)
arm.enable_logging(console=True, file_path=Path("requests.log"))
# Enable caching (5 minute TTL by default)
arm.enable_caching(max_size=100, default_ttl=300)
# Make requests...
await arm.get("/users")
await arm.get("/users") # Cache hit!
# View statistics
arm.print_stats()
# Access logger directly
for log in arm.logger.get_logs():
print(f"{log.method} {log.path} - {log.duration_ms}ms")
๐งช Running Tests
# Run all tests
pytest tests/ -v
# With coverage
pytest tests/ --cov=apiarm --cov-report=html
๐ ๏ธ Development
# Format code
black apiarm/ tests/
isort apiarm/ tests/
# Type checking
mypy apiarm/
๐ License
MIT License - See LICENSE file for details.
๐ค Author
Rayen Bahroun - bahroun.me
Made with ๐ฆพ by API-ARM
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apiarm-0.1.1.tar.gz.
File metadata
- Download URL: apiarm-0.1.1.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2a61d91f68f994dccad440a38880af1d64e4f869d9257582086d0a4f3c3a195
|
|
| MD5 |
9c4fba77d25d850b1cbfca511cb1e5aa
|
|
| BLAKE2b-256 |
92ec59504c439f1ca12bb9eff8d4f0af32e69bc7d63176b0a5214c7030d9a877
|
File details
Details for the file apiarm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: apiarm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 31.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1a99e8943ca9ec9397f6860fd2415b14d32f54e40786d0915b19c729f6a3e71
|
|
| MD5 |
650ea86769be6aefb7ef6a3dd7a38a96
|
|
| BLAKE2b-256 |
9af381f5ac47bcbd42a4019fdc5dcf1bdea6c309f6c059032480fd74f90bad97
|