Skip to main content

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.

Python 3.10+ License: MIT

โœจ 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apiarm-0.1.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apiarm-0.1.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file apiarm-0.1.0.tar.gz.

File metadata

  • Download URL: apiarm-0.1.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for apiarm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9323375a582687c04698ad45191bf212f812c526ac788c2840f983d840d182d4
MD5 71112458180144050d2cf4251379248c
BLAKE2b-256 95157194a2f99cd6c70c88ed6c7efda2d668f896241e7a91bc40f8a759b11589

See more details on using hashes here.

File details

Details for the file apiarm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: apiarm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for apiarm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13f975c9d3943494be23555eeb9e27d8d5e8734ae314d387e8eda99990c55b75
MD5 1df95f0c7af5b3fc68c3d3370bdd3a38
BLAKE2b-256 fb7cc45580ea05f63707a3b2343b832d4da5f301e7267530c2bb23c09424680c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page