semvec/pypi-packages huggingface dataset:
fun-api-testing 0.1.0
A Python tool for testing API endpoints.
Requires Python: >=3.10


# APITestTool

APITestTool is a Python-based tool for testing API endpoints. It provides a simple interface to send requests, handle authentication, and even manage dependencies between APIs. This tool is designed for developers to easily test their APIs during development.

## Features

- **Send Requests**: Supports GET, POST, PUT, DELETE, and other HTTP methods.
- **Authentication**: Built-in strategies for API Key and Basic Auth.
- **Configuration Management**: Singleton pattern for global configurations.
- **API Dependency Graph**: Execute APIs in a defined order based on dependencies.
- **Utility Functions**: Search and sort endpoints for better usability.

## Installation

1. Clone the repository:
   ```bash
   git clone https://github.com/Moataz0000/Quick_API.git
   cd fun-api-testing/core
   ```

2. Install the package locally:
   ```bash
   pip install -e .
   ```

3. Alternatively, install from PyPI:
   ```bash
   pip install apitesttool
   ```

## Usage

### Command-Line Interface

To use APITestTool from the command line, run:

```bash
apitesttool --base-url "https://jsonplaceholder.typicode.com" --auth-type "apikey" --api-key "your-api-key"
```

This will send an example request to the `/example` endpoint of the base URL.

### Python API

#### Example 1: Sending a GET Request

```python
from apitesttool.core import APITestTool

# Initialize the tool
tool = APITestTool("https://jsonplaceholder.typicode.com")

# Send a GET request
response = tool.send_request("GET", "/posts/1")
print(response)
```

#### Example 2: Using API Key Authentication

```python
from apitesttool.core import APITestTool
from apitesttool.auth import APIKeyAuth

# Initialize the tool with API Key authentication
auth = APIKeyAuth("your-api-key")
tool = APITestTool("https://api.example.com", auth_strategy=auth)

response = tool.send_request("GET", "/data")
print(response)
```

#### Example 3: Dependency Graph

```python
from apitesttool.graph import APIDependencyGraph

# Create a graph
graph = APIDependencyGraph()
graph.add_dependency("/start", "/next")

def execute(api):
    print(f"Executing API: {api}")

graph.execute_in_order("/start", execute)
```

## Testing

Run the tests using `pytest`:

```bash
pytest tests/
```

## Contribution

1. Fork the repository.
2. Create a new branch: `git checkout -b feature-name`.
3. Make your changes and commit: `git commit -m 'Add new feature'`.
4. Push to your branch: `git push origin feature-name`.
5. Open a pull request.