{"id":20929493,"url":"https://github.com/integration-automation/apitestka","last_synced_at":"2026-04-25T06:03:59.311Z","repository":{"id":37275665,"uuid":"420008462","full_name":"Integration-Automation/APITestka","owner":"Integration-Automation","description":"A framework for API automation","archived":false,"fork":false,"pushed_at":"2025-07-10T18:51:55.000Z","size":22102,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-11T00:54:51.295Z","etag":null,"topics":["api-testing","api-testing-framework","automation","keyword-driven-testing","mocks-server","python","report-generator","test-automation-framework","testing","testing-framework","testing-tools"],"latest_commit_sha":null,"homepage":"https://integration-automation.github.io/APITestka/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Integration-Automation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"licenses/APITestka_LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-10-22T07:38:29.000Z","updated_at":"2025-07-10T18:52:00.000Z","dependencies_parsed_at":"2024-09-08T12:12:33.335Z","dependency_job_id":"2f4c05ff-d477-41d6-88cd-45efd8696766","html_url":"https://github.com/Integration-Automation/APITestka","commit_stats":null,"previous_names":["integration-automation/apitestka","intergration-automation-testing/apitestka"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Integration-Automation/APITestka","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integration-Automation%2FAPITestka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integration-Automation%2FAPITestka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integration-Automation%2FAPITestka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integration-Automation%2FAPITestka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Integration-Automation","download_url":"https://codeload.github.com/Integration-Automation/APITestka/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integration-Automation%2FAPITestka/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265123682,"owners_count":23714798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-testing","api-testing-framework","automation","keyword-driven-testing","mocks-server","python","report-generator","test-automation-framework","testing","testing-framework","testing-tools"],"created_at":"2024-11-18T21:20:07.425Z","updated_at":"2026-04-25T06:03:59.297Z","avatar_url":"https://github.com/Integration-Automation.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APITestka\n\n[![Python](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](https://www.python.org/)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](licenses/APITestka_LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/je_api_testka.svg)](https://pypi.org/project/je_api_testka/)\n[![Documentation Status](https://readthedocs.org/projects/apitestka/badge/?version=latest)](https://apitestka.readthedocs.io/en/latest/?badge=latest)\n\n**APITestka** is a lightweight, cross-platform framework for automated API testing.\nIt supports HTTP/HTTPS, SOAP/XML, and JSON, with high-performance request execution,\ndetailed reporting, and flexible CLI scripting.\n\nDesigned for speed and scalability, APITestka enables thousands of requests per second,\nintegrates with mock servers and remote automation,\nand generates reports in multiple formats for easy analysis.\n\n\u003e **Translations / Other Languages:**\n\u003e [繁體中文](README/README_zh-TW.md) | [简体中文](README/README_zh-CN.md)\n\n---\n\n## Table of Contents\n\n- [Features](#features)\n- [Architecture Overview](#architecture-overview)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n  - [Using the requests Backend](#using-the-requests-backend)\n  - [Using the httpx Backend (Sync)](#using-the-httpx-backend-sync)\n  - [Using the httpx Backend (Async)](#using-the-httpx-backend-async)\n  - [HTTP/2 Support](#http2-support)\n  - [SOAP/XML Request](#soapxml-request)\n  - [Session-Based Requests](#session-based-requests)\n- [Result Assertion](#result-assertion)\n- [Report Generation](#report-generation)\n  - [HTML Report](#html-report)\n  - [JSON Report](#json-report)\n  - [XML Report](#xml-report)\n- [Mock Server](#mock-server)\n- [Callback Executor](#callback-executor)\n- [Scripting with Executor](#scripting-with-executor)\n  - [JSON Keyword-Driven Testing](#json-keyword-driven-testing)\n  - [Executing JSON Files via Python](#executing-json-files-via-python)\n  - [Executing a Directory of JSON Files](#executing-a-directory-of-json-files)\n  - [Adding Custom Commands](#adding-custom-commands)\n- [CLI Usage](#cli-usage)\n- [Remote Automation (Socket Server)](#remote-automation-socket-server)\n- [Project Scaffolding](#project-scaffolding)\n- [GUI (Optional)](#gui-optional)\n- [Test Record](#test-record)\n- [Project Structure](#project-structure)\n- [Requirements](#requirements)\n- [Development](#development)\n- [Contributing](#contributing)\n- [License](#license)\n- [Links](#links)\n\n---\n\n## Features\n\n| Category | Details |\n|---|---|\n| **HTTP Clients** | `requests` (sync, session support) and `httpx` (sync + async, HTTP/2) |\n| **Protocols** | HTTP, HTTPS, SOAP/XML, JSON |\n| **Report Formats** | HTML, JSON, XML |\n| **Scripting** | JSON keyword-driven test execution via Executor |\n| **Mock Server** | Built-in Flask-based mock server for local testing |\n| **Remote Automation** | TCP socket server for remote command execution |\n| **Assertions** | Built-in response field assertion (status code, headers, body, etc.) |\n| **Callback System** | Execute callback functions after API calls |\n| **CLI** | Full command-line interface for CI/CD integration |\n| **Project Scaffolding** | Auto-generate project structure with templates |\n| **GUI** | Optional PySide6 GUI (install with `pip install je_api_testka[gui]`) |\n| **Cross-Platform** | Windows, macOS, Linux |\n| **Performance** | Thousands of requests per second |\n\n---\n\n## Architecture Overview\n\n```\nje_api_testka/\n├── requests_wrapper/      # requests-based HTTP client\n├── httpx_wrapper/         # httpx-based HTTP client (sync + async)\n├── utils/\n│   ├── assert_result/     # Response assertion\n│   ├── callback/          # Callback function executor\n│   ├── executor/          # JSON keyword-driven action executor\n│   ├── generate_report/   # HTML / JSON / XML report generation\n│   ├── mock_server/       # Flask-based mock server\n│   ├── socket_server/     # TCP socket server for remote automation\n│   ├── project/           # Project scaffolding \u0026 templates\n│   ├── json/              # JSON read/write utilities\n│   ├── xml/               # XML parse/convert utilities\n│   ├── test_record/       # Global test record storage\n│   ├── logging/           # Logging instance\n│   ├── file_process/      # File listing utilities\n│   ├── package_manager/   # Dynamic package loading\n│   └── exception/         # Custom exceptions\n└── gui/                   # Optional PySide6 GUI\n```\n\n---\n\n## Installation\n\n```bash\npip install je_api_testka\n```\n\nTo install with GUI support:\n\n```bash\npip install je_api_testka[gui]\n```\n\n---\n\n## Quick Start\n\n### Using the requests Backend\n\n```python\nfrom je_api_testka import test_api_method_requests\n\n# GET request\nresult = test_api_method_requests(\"get\", \"http://httpbin.org/get\")\nprint(result[\"response_data\"][\"status_code\"])  # 200\n\n# POST request with parameters\nresult = test_api_method_requests(\n    \"post\",\n    \"http://httpbin.org/post\",\n    params={\"task\": \"new task\"}\n)\nprint(result[\"response_data\"][\"status_code\"])  # 200\n```\n\n### Using the httpx Backend (Sync)\n\n```python\nfrom je_api_testka import test_api_method_httpx\n\nresult = test_api_method_httpx(\"get\", \"http://httpbin.org/get\")\nprint(result[\"response_data\"][\"status_code\"])  # 200\n```\n\n### Using the httpx Backend (Async)\n\n```python\nimport asyncio\nfrom je_api_testka import test_api_method_httpx_async\n\nasync def main():\n    result = await test_api_method_httpx_async(\"get\", \"http://httpbin.org/get\")\n    print(result[\"response_data\"][\"status_code\"])  # 200\n\nasyncio.run(main())\n```\n\n### HTTP/2 Support\n\n```python\nimport asyncio\nfrom je_api_testka import test_api_method_httpx_async\n\nasync def main():\n    result = await test_api_method_httpx_async(\n        \"get\",\n        \"https://httpbin.org/get\",\n        http2=True\n    )\n    print(result[\"response_data\"][\"status_code\"])\n\nasyncio.run(main())\n```\n\n### SOAP/XML Request\n\n```python\nfrom je_api_testka import test_api_method_requests\n\nresult = test_api_method_requests(\n    \"post\",\n    \"http://example.com/soap-endpoint\",\n    soap=True,\n    data='\u003csoap:Envelope\u003e...\u003c/soap:Envelope\u003e'\n)\n```\n\nWhen `soap=True`, the `Content-Type` header is automatically set to `application/soap+xml`.\n\n### Session-Based Requests\n\nThe `requests` backend supports session-based methods for persistent connections (cookies, auth, etc.):\n\n```python\nfrom je_api_testka import test_api_method_requests\n\n# Use session_get, session_post, session_put, session_patch, session_delete, session_head, session_options\nresult = test_api_method_requests(\"session_get\", \"http://httpbin.org/get\")\n```\n\n---\n\n## Result Assertion\n\nPass a `result_check_dict` to automatically assert response fields:\n\n```python\nfrom je_api_testka import test_api_method_requests\n\n# This will raise APIAssertException if status_code is not 200\ntest_api_method_requests(\n    \"get\",\n    \"http://httpbin.org/get\",\n    result_check_dict={\"status_code\": 200}\n)\n```\n\nYou can assert on any field in the response data: `status_code`, `text`, `content`, `headers`, `cookies`, `encoding`, `elapsed`, `request_time_sec`, `request_method`, `request_url`, `request_body`, `start_time`, `end_time`.\n\n---\n\n## Report Generation\n\nReports are generated from the global `test_record_instance`, which automatically records all test results.\n\n### HTML Report\n\n```python\nfrom je_api_testka import test_api_method_requests, generate_html_report\n\ntest_api_method_requests(\"get\", \"http://httpbin.org/get\")\ntest_api_method_requests(\"post\", \"http://httpbin.org/post\")\n\n# Generates \"my_report.html\" with success/failure tables\ngenerate_html_report(\"my_report\")\n```\n\n### JSON Report\n\n```python\nfrom je_api_testka import test_api_method_requests, generate_json_report\n\ntest_api_method_requests(\"get\", \"http://httpbin.org/get\")\n\n# Generates \"my_report_success.json\" and \"my_report_failure.json\"\ngenerate_json_report(\"my_report\")\n```\n\n### XML Report\n\n```python\nfrom je_api_testka import test_api_method_requests, generate_xml_report\n\ntest_api_method_requests(\"get\", \"http://httpbin.org/get\")\n\n# Generates \"my_report_success.xml\" and \"my_report_failure.xml\"\ngenerate_xml_report(\"my_report\")\n```\n\n---\n\n## Mock Server\n\nAPITestka includes a built-in Flask-based mock server for local testing:\n\n```python\nfrom je_api_testka import flask_mock_server_instance, request\n\n# Add custom routes\ndef my_endpoint():\n    return {\"message\": \"hello\", \"params\": dict(request.args)}\n\nflask_mock_server_instance.add_router(\n    {\"/api/test\": my_endpoint},\n    methods=[\"GET\", \"POST\"]\n)\n\n# Start the mock server (default: localhost:8090)\nflask_mock_server_instance.start_mock_server()\n```\n\nYou can also create a new instance with a custom host/port:\n\n```python\nfrom je_api_testka.utils.mock_server.flask_mock_server import FlaskMockServer\n\nserver = FlaskMockServer(\"0.0.0.0\", 5000)\nserver.add_router({\"/health\": lambda: \"OK\"}, methods=[\"GET\"])\nserver.start_mock_server()\n```\n\n---\n\n## Callback Executor\n\nExecute a callback function after an API test completes:\n\n```python\nfrom je_api_testka import callback_executor\n\ndef my_callback(message):\n    print(f\"Callback: {message}\")\n\ncallback_executor.callback_function(\n    trigger_function_name=\"AT_test_api_method\",\n    callback_function=my_callback,\n    callback_function_param={\"message\": \"Test done!\"},\n    callback_param_method=\"kwargs\",\n    http_method=\"get\",\n    test_url=\"http://httpbin.org/get\"\n)\n```\n\n---\n\n## Scripting with Executor\n\nThe Executor enables JSON keyword-driven testing, where test actions are defined as JSON arrays and executed programmatically.\n\n### JSON Keyword-Driven Testing\n\nCreate a JSON file (e.g., `test_actions.json`):\n\n```json\n{\n    \"api_testka\": [\n        [\"AT_test_api_method\", {\n            \"http_method\": \"get\",\n            \"test_url\": \"http://httpbin.org/get\",\n            \"result_check_dict\": {\"status_code\": 200}\n        }],\n        [\"AT_test_api_method\", {\n            \"http_method\": \"post\",\n            \"test_url\": \"http://httpbin.org/post\",\n            \"params\": {\"task\": \"new task\"},\n            \"result_check_dict\": {\"status_code\": 200}\n        }]\n    ]\n}\n```\n\n### Executing JSON Files via Python\n\n```python\nfrom je_api_testka import execute_action, read_action_json\n\nexecute_action(read_action_json(\"test_actions.json\"))\n```\n\n### Executing a Directory of JSON Files\n\n```python\nfrom je_api_testka import execute_files, get_dir_files_as_list\n\nexecute_files(get_dir_files_as_list(\"path/to/json_dir\"))\n```\n\n### Adding Custom Commands\n\n```python\nfrom je_api_testka import add_command_to_executor, execute_action\n\ndef my_custom_function(url):\n    print(f\"Custom test on: {url}\")\n\nadd_command_to_executor({\"my_test\": my_custom_function})\n\nexecute_action([\n    [\"my_test\", [\"http://example.com\"]]\n])\n```\n\n**Available built-in Executor commands:**\n\n| Command | Description |\n|---|---|\n| `AT_test_api_method` | Test API with requests backend |\n| `AT_test_api_method_httpx` | Test API with httpx sync backend |\n| `AT_delegate_async_httpx` | Test API with httpx async backend (run synchronously) |\n| `AT_generate_html` | Generate HTML report data |\n| `AT_generate_html_report` | Generate HTML report file |\n| `AT_generate_json` | Generate JSON report data |\n| `AT_generate_json_report` | Generate JSON report file |\n| `AT_generate_xml` | Generate XML report data |\n| `AT_generate_xml_report` | Generate XML report file |\n| `AT_execute_action` | Execute nested action list |\n| `AT_execute_files` | Execute actions from multiple files |\n| `AT_add_package_to_executor` | Dynamically load a package into executor |\n| `AT_add_package_to_callback_executor` | Dynamically load a package into callback executor |\n| `AT_flask_mock_server_add_router` | Add route to mock server |\n| `AT_start_flask_mock_server` | Start mock server |\n\n---\n\n## CLI Usage\n\nAPITestka provides a full CLI interface:\n\n```bash\n# Execute a single JSON action file\npython -m je_api_testka -e test_actions.json\n\n# Execute all JSON files in a directory\npython -m je_api_testka -d path/to/json_dir\n\n# Execute a JSON string directly\npython -m je_api_testka --execute_str '[[\"AT_test_api_method\", {\"http_method\": \"get\", \"test_url\": \"http://httpbin.org/get\"}]]'\n\n# Create a new project with templates\npython -m je_api_testka -c MyProject\n```\n\n| Flag | Description |\n|---|---|\n| `-e`, `--execute_file` | Execute a single JSON action file |\n| `-d`, `--execute_dir` | Execute all JSON files in a directory |\n| `--execute_str` | Execute a JSON string directly |\n| `-c`, `--create_project` | Create a project directory with template files |\n\n---\n\n## Remote Automation (Socket Server)\n\nAPITestka includes a TCP socket server for remote command execution:\n\n```python\nfrom je_api_testka import start_apitestka_socket_server\n\n# Start the socket server (default: localhost:9939)\nserver = start_apitestka_socket_server(host=\"localhost\", port=9939)\n```\n\nClients can send JSON-formatted action lists via TCP, and the server will execute them and return results. Send `quit_server` to shut down the server.\n\nThe server also supports CLI arguments:\n\n```bash\npython -m je_api_testka.utils.socket_server.api_testka_socket_server localhost 9939\n```\n\n---\n\n## Project Scaffolding\n\nGenerate a project structure with keyword and executor templates:\n\n```python\nfrom je_api_testka import create_project_dir\n\ncreate_project_dir(project_path=\".\", parent_name=\"MyAPIProject\")\n```\n\nThis creates:\n\n```\nMyAPIProject/\n├── keyword/\n│   ├── keyword1.json          # Example keyword test (POST)\n│   ├── keyword2.json          # Example keyword test (GET)\n│   └── bad_keyword_1.json     # Example with package loading\n└── executor/\n    ├── executor_one_file.py   # Execute a single keyword file\n    ├── executor_folder.py     # Execute all keyword files in directory\n    └── executor_bad_file.py   # Example with dynamic package loading\n```\n\n---\n\n## GUI (Optional)\n\nAPITestka provides an optional PySide6-based GUI:\n\n```bash\npip install je_api_testka[gui]\n```\n\nThe GUI requires PySide6 6.11.0 and qt-material.\n\n---\n\n## Test Record\n\nAll API test results are automatically stored in a global `test_record_instance`:\n\n```python\nfrom je_api_testka import test_api_method_requests, test_record_instance\n\ntest_api_method_requests(\"get\", \"http://httpbin.org/get\")\ntest_api_method_requests(\"get\", \"http://invalid-url\")\n\n# Access successful test records\nprint(len(test_record_instance.test_record_list))\n\n# Access error records\nprint(len(test_record_instance.error_record_list))\n\n# Clean all records\ntest_record_instance.clean_record()\n```\n\nEach successful record contains: `status_code`, `text`, `content`, `headers`, `history`, `encoding`, `cookies`, `elapsed`, `request_time_sec`, `request_method`, `request_url`, `request_body`, `start_time`, `end_time`.\n\n---\n\n## Project Structure\n\n```\nAPITestka/\n├── je_api_testka/             # Main package\n│   ├── __init__.py            # Public API exports\n│   ├── __main__.py            # CLI entry point\n│   ├── requests_wrapper/      # requests HTTP client wrapper\n│   ├── httpx_wrapper/         # httpx HTTP client wrapper (sync + async)\n│   ├── utils/                 # Utility modules\n│   └── gui/                   # Optional PySide6 GUI\n├── test/                      # Test suite\n│   ├── test_requests/         # Tests for requests backend\n│   ├── test_httpx_sync/       # Tests for httpx sync backend\n│   ├── test_httpx_async/      # Tests for httpx async backend\n│   └── test_utils/            # Tests for utility modules\n├── docs/                      # Sphinx documentation source\n├── apitestka_driver/          # Standalone driver executables\n├── licenses/                  # License files\n├── pyproject.toml             # Build configuration\n├── requirements.txt           # Runtime dependencies\n└── dev_requirements.txt       # Development dependencies\n```\n\n---\n\n## Requirements\n\n- **Python** 3.10 or later\n- **Dependencies:** `requests`, `Flask`, `httpx`\n- **Optional (GUI):** `PySide6==6.11.0`, `qt-material`\n\n---\n\n## Development\n\n```bash\n# Clone the repository\ngit clone https://github.com/Intergration-Automation-Testing/APITestka.git\ncd APITestka\n\n# Install development dependencies\npip install -r dev_requirements.txt\n\n# Run tests\npytest\n```\n\n---\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See [licenses/APITestka_LICENSE](licenses/APITestka_LICENSE).\n\n---\n\n## Links\n\n- **Homepage:** https://github.com/Intergration-Automation-Testing/APITestka\n- **Documentation:** https://apitestka.readthedocs.io/en/latest/\n- **PyPI:** https://pypi.org/project/je_api_testka/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegration-automation%2Fapitestka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegration-automation%2Fapitestka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegration-automation%2Fapitestka/lists"}