{"id":4278,"library":"testrail-api","title":"TestRail API Python Wrapper","description":"testrail-api is a Python wrapper for the TestRail API, enabling programmatic interaction with TestRail instances for managing test cases, runs, results, and more. It is actively maintained with frequent minor releases, typically addressing new TestRail API features, bug fixes, and Python version compatibility. The current version is 1.13.6.","status":"active","version":"1.13.6","language":"en","source_language":"en","source_url":"https://github.com/tolstislon/testrail-api","tags":["testrail","api","testing","qa","test-management"],"install":[{"cmd":"pip install testrail-api","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The main class is directly importable from the top-level package, not from a nested module.","wrong":"from testrail_api.testrail_api import TestRailAPI","symbol":"TestRailAPI","correct":"from testrail_api import TestRailAPI"}],"quickstart":{"code":"import os\nfrom testrail_api import TestRailAPI\n\n# Ensure these environment variables are set:\n# TR_BASE_URL (e.g., 'https://yourinstance.testrail.io/')\n# TR_USER (e.g., 'user@example.com')\n# TR_PASSWORD_OR_API_KEY (API key is recommended)\n\nTR_BASE_URL = os.environ.get('TR_BASE_URL', '')\nTR_USER = os.environ.get('TR_USER', '')\nTR_PASSWORD_OR_API_KEY = os.environ.get('TR_PASSWORD_OR_API_KEY', '')\n\nif not all([TR_BASE_URL, TR_USER, TR_PASSWORD_OR_API_KEY]):\n    print(\"Please set TR_BASE_URL, TR_USER, and TR_PASSWORD_OR_API_KEY environment variables.\")\n    exit(1)\n\ntry:\n    client = TestRailAPI(\n        base_url=TR_BASE_URL,\n        user=TR_USER,\n        password=TR_PASSWORD_OR_API_KEY,\n    )\n\n    # Example: Get all projects\n    projects = client.projects.get_projects()\n    print(f\"Successfully connected. Found {len(projects)} projects.\")\n    if projects:\n        print(f\"First project: {projects[0]['name']}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the TestRail API client using environment variables for credentials and fetch a list of projects. Ensure you replace the placeholder values or set your environment variables correctly."},"warnings":[{"fix":"Upgrade Python to 3.9 or higher, or explicitly install `testrail-api<1.13.4`.","message":"Python 3.8 support was removed in version 1.13.4. Users on Python 3.8 or older must upgrade their Python environment to 3.9+ or pin the library version to `<1.13.4`.","severity":"breaking","affected_versions":">=1.13.4"},{"fix":"Always pass your TestRail API key value to the `password` parameter when initializing `TestRailAPI`.","message":"When using an API Key for authentication (recommended by TestRail), the key should be passed to the `password` argument, not `api_key` or another field. TestRail's API documentation refers to this as the 'password' for HTTP Basic Auth.","severity":"gotcha","affected_versions":"All"},{"fix":"Wrap API calls in `try...except` blocks to catch potential `TestRailError` exceptions or other HTTP client errors and implement custom retry logic if necessary beyond the library's defaults.","message":"While the library includes custom exception retry handling (since 1.11.0), applications should still implement robust error handling for TestRail API rate limits (HTTP 429 Too Many Requests) and other server-side errors to ensure stability.","severity":"gotcha","affected_versions":"All"},{"fix":"Consult the library documentation for available bulk or paginated methods when fetching large collections of resources.","message":"For retrieving large datasets of suites or users, prefer the recently added bulk methods (`get_suites`, `get_users` with `offset`/`limit` parameters or dedicated bulk methods like `get_suites_bulk`, `get_users_bulk` if available) to avoid hitting API rate limits or performance issues associated with many individual requests.","severity":"gotcha","affected_versions":">=1.13.5"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}