Metadata-Version: 2.4
Name: arythmatic-flow-client
Version: 0.2.0
Summary: Official Python client for Arythmatic Flow — API testing, workflows, AI, monitoring, and security scanning.
Project-URL: Homepage, https://flow.arythmatic.cloud
Project-URL: Repository, https://github.com/askmeidentitycorp/flowapi-releases
Author: Arythmatic
License: MIT
Keywords: api,arythmatic,client,flow,http,monitoring,security,testing,workflow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# @arythmatic/flow-client-py

Official Python client for [Arythmatic Flow](https://flow.arythmatic.cloud) — the API platform for testing, workflows, AI, monitoring, and security scanning.

## Install

```bash
pip install flow-client
```

## Quick Start

```python
from flow_client import FlowClient

flow = FlowClient()

# Authenticate
flow.login({"email": "you@example.com", "password": "secret"})

# Set active team
flow.set_team_id("your-team-id")

# Run a stored collection
collections = flow.collections.list()
result = flow.collections.run(collections[0]["id"])
print(result)
```

## Features

- **HTTP Client** — requests-like interface with interceptors, timeouts, and auto-auth headers.
- **Collections** — list, run, and inspect stored request collections.
- **Workflows** — execute DAG-based workflows with custom inputs.
- **AI** — generate requests from descriptions, suggest assertions, manage conversations.
- **Monitoring** — create uptime/performance monitors and trigger on-demand checks.
- **Security Scanning** — run OWASP-style vulnerability scans on requests, collections, or URLs.
- **Proxy Execution** — send arbitrary HTTP requests through Flow's engine (CORS-free, with variables, scripts, and assertions).

## Configuration

```python
flow = FlowClient(
    base_url="https://flow.arythmatic.cloud",  # or your self-hosted instance
    access_token="...",   # optional: pre-authenticated
    refresh_token="...",  # optional
    team_id="...",        # optional: default team
    timeout=30000,        # request timeout in ms
    headers={},           # extra default headers
)
```

## Authentication

```python
# Login (stores tokens automatically)
user_and_teams = flow.login({"email": email, "password": password})

# Register
user_and_team = flow.register({"email": email, "password": password, "name": name})

# Refresh
flow.refresh()

# Get current user
me = flow.auth.me()
```

## Collections

```python
collections = flow.collections.list()

# Run the entire collection
run = flow.collections.run(collection_id, {
    "mode": "sequential",       # or "parallel"
    "environmentId": "env-id",
    "stopOnFailure": True,
})

# Run only specific requests from the collection
run_subset = flow.collections.run(collection_id, {
    "requestIds": ["req-id-1", "req-id-2"],
})

# Run a single request from a collection
run_one = flow.collections.run_one(collection_id, "req-id-1")

runs = flow.collections.runs(collection_id)
```

## Workflows

```python
workflows = flow.workflows.list()
result = flow.workflows.run(workflow_id, {
    "environmentId": "env-id",
    "input": {"userId": "123"},
})
history = flow.workflows.runs(workflow_id)

# Get a specific run or resume a failed one
run = flow.workflows.run_detail(run_id)
resumed = flow.workflows.resume_run(run_id, from_node_id="node-1")
```

## AI

```python
# Generate request definitions from text
result = flow.ai.generate({
    "input": "A todo list API with CRUD",
    "type": "description",
})

# Suggest assertions
result = flow.ai.suggest_assertions({
    "status": 200,
    "headers": {},
    "body": "...",
    "url": "https://api.example.com/users",
    "method": "GET",
})

# Token usage
usage = flow.ai.usage()
```

## Monitors

```python
monitor = flow.monitors.create({
    "name": "API Health",
    "type": "standalone",
    "url": "https://api.example.com/health",
    "method": "GET",
    "expectedStatus": 200,
    "interval": "30m",
})
flow.monitors.check(monitor["id"])
```

## Security Scans

```python
# Scan a stored request
flow.scans.scan_request(request_id)

# Scan a collection
flow.scans.scan_collection(collection_id)

# Scan any URL
flow.scans.scan_url("https://api.example.com/users")

# Get results
report = flow.scans.get(scan_id)
```

## Environments

```python
envs = flow.environments.list()
env = flow.environments.create("Staging", color="#3b82f6")
flow.environments.set_vars(env["id"], [{"k": "BASE_URL", "v": "https://staging.example.com"}])
```

## Data Tables

```python
tables = flow.data_tables.list()
table = flow.data_tables.create("Users", columns=["id", "name", "role"])
flow.data_tables.update(table["id"], rows=[[1, "Alice", "admin"]])
```

## Request Templates

```python
tpls = flow.request_templates.list()
tpl = flow.request_templates.create("Get User", method="GET", path="/users/{{id}}")
```

## Comments

```python
comments = flow.comments.list_for_request(request_id)
flow.comments.create(request_id, "Looks good!")
```

## Audit Log

```python
log = flow.audit_log.list(entity="collection", limit=50)
users = flow.audit_log.users()
```

## Performance Tests

```python
result = flow.perf_tests.run("https://api.example.com/health", concurrency=20, total_requests=200)
runs = flow.perf_tests.list()
```

## Team Management

```python
my_teams = flow.teams.list()
members = flow.teams.members(team_id)
flow.teams.invite(team_id, "new@example.com", role="admin")
flow.teams.accept_invitation(token)
```

## History

```python
entries = flow.history.list(collection_id=collection_id, limit=20)
entry = flow.history.get(entry_id)
flow.history.delete_many(older_than_days=30)
```

## Import / Export

```python
result = flow.import_export.import_collection(postman_json)
flow.import_export.export_collection(collection_id, format="openapi")
flow.import_export.export_cicd(collection_id, platform="github", schedule="0 9 * * *")
```

## Workflow Folders & Templates

```python
folders = flow.workflow_folders.list()
flow.workflow_folders.create("Onboarding", parent_id=parent_folder_id)

templates = flow.workflow_templates.list()
flow.workflow_templates.use(template_id, name="My Onboarding Flow")
```

## MCP Servers

```python
templates = flow.mcp_servers.templates()
servers = flow.mcp_servers.list()
flow.mcp_servers.create("slack", type="template", credentials={"token": "xoxb-..."})
flow.mcp_servers.reconnect(server_id)
```

## Proxy / Arbitrary Requests

Send any HTTP request through Flow's execution engine:

```python
res = flow.requests.execute({
    "method": "POST",
    "url": "https://api.example.com/users",
    "headers": {"Content-Type": "application/json"},
    "body": '{"name": "Alice"}',
    "envVars": [{"key": "BASE_URL", "value": "https://api.example.com"}],
    "assertions": [
        {"type": "status", "operator": "eq", "expected": 201},
    ],
})
```

Shorthand helpers are also available:

```python
flow.requests.get(url, opts)
flow.requests.post(url, opts)
# put, patch, delete
```

## Interceptors

```python
flow.interceptors.request.use(lambda cfg: {
    **cfg,
    "headers": {**cfg["headers"], "X-Custom": "value"}
})

flow.interceptors.response.use(
    lambda res: res,
    lambda err: print(f"Request failed: {err}") or (_ for _ in ()).throw(err)
)
```

## Error Handling

```python
from flow_client import FlowError, FlowAuthError

try:
    flow.collections.list()
except FlowAuthError:
    flow.refresh()
except FlowError as err:
    print(err.status, err.code, err.response)
```

## CLI

A small CLI is included for quick tasks:

```bash
# Login
python -m flow_client login -u http://localhost:3001 -e you@example.com -p secret

# List collections
python -m flow_client collections list

# Run a collection
python -m flow_client collections run <collection-id> -e <env-id>

# View runs
python -m flow_client runs list <collection-id>
python -m flow_client runs get <collection-id> <run-id>
```

## License

MIT
