{"library":"reportportal-client","title":"ReportPortal Python Client","description":"The reportportal-client is a Python client library for integrating test automation results with ReportPortal v5. It provides functionalities to manage launches, test items, and logs, including attachments. The current version is 5.7.4, and the library generally sees frequent minor updates, often several per month.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install reportportal-client"],"cli":null},"imports":["from reportportal_client import RPClient","from reportportal_client import RPLogHandler","from reportportal_client import RPLogger","from reportportal_client.helpers import timestamp"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport subprocess\nfrom mimetypes import guess_type\nimport logging\n\nfrom reportportal_client import RPClient, RPLogger, RPLogHandler\nfrom reportportal_client.helpers import timestamp\n\n# Configure logging for the client itself (optional, but good practice)\nlogging.basicConfig(level=logging.DEBUG)\n\n# ReportPortal configuration from environment variables\nendpoint = os.environ.get('RP_ENDPOINT', 'http://localhost:8080/api/v1')\nproject = os.environ.get('RP_PROJECT', 'default_personal')\napi_key = os.environ.get('RP_API_KEY', 'YOUR_API_KEY') # Get from your ReportPortal User Profile\nlaunch_name = 'Example Launch'\nlaunch_doc = 'Basic example of using reportportal-client.'\n\n# Set up ReportPortal logger\nlogging.setLoggerClass(RPLogger)\nrp_logger = logging.getLogger(__name__)\nrp_logger.setLevel(logging.INFO)\nrp_logger.addHandler(RPLogHandler(endpoint=endpoint, project=project, api_key=api_key, launch_uuid=None))\n\ntry:\n    # Initialize RPClient\n    client = RPClient(endpoint=endpoint, project=project, api_key=api_key)\n    # Start log upload thread (for async mode)\n    client.start()\n\n    # Start a new launch\n    launch = client.start_launch(\n        name=launch_name,\n        start_time=timestamp(),\n        description=launch_doc,\n        attributes=[{'key': 'client', 'value': 'python'}, {'value', 'example'}]\n    )\n    launch_uuid = launch.uuid\n    rp_logger.info(f'Launch started with UUID: {launch_uuid}')\n\n    # Start a test item (e.g., a test case or suite)\n    test_item = client.start_test_item(\n        name='Test Case 1',\n        description='First Test Case',\n        start_time=timestamp(),\n        attributes=[{'key': 'suite', 'value': 'smoke'}],\n        item_type='STEP',\n        launch_uuid=launch_uuid\n    )\n    test_item_uuid = test_item.uuid\n    rp_logger.info(f'Test Item started with UUID: {test_item_uuid}')\n\n    # Log messages\n    client.log(time=timestamp(), message='Hello from ReportPortal Client!', level='INFO', launch_uuid=launch_uuid, item_uuid=test_item_uuid)\n    rp_logger.warning('This is a warning log using the standard Python logger.', attachment={\n        'name': 'warning.txt',\n        'data': b'This is an attached text file content.',\n        'mime': 'text/plain'\n    })\n\n    # Simulate a subprocess call and attach output\n    try:\n        output = subprocess.check_output(['ls', '-l'], stderr=subprocess.STDOUT)\n        client.log(time=timestamp(), message='ls -l output', level='DEBUG', launch_uuid=launch_uuid, item_uuid=test_item_uuid, attachment={\n            'name': 'ls_output.txt',\n            'data': output,\n            'mime': 'text/plain'\n        })\n    except subprocess.CalledProcessError as e:\n        client.log(time=timestamp(), message=f'Command failed: {e.output.decode()}', level='ERROR', launch_uuid=launch_uuid, item_uuid=test_item_uuid)\n\n    # Finish the test item\n    client.finish_test_item(item_uuid=test_item_uuid, end_time=timestamp(), status='PASSED', launch_uuid=launch_uuid)\n    rp_logger.info(f'Test Item {test_item_uuid} finished.')\n\n    # Finish the launch\n    client.finish_launch(launch_uuid=launch_uuid, end_time=timestamp(), status='PASSED')\n    rp_logger.info(f'Launch {launch_uuid} finished.')\n\nexcept Exception as e:\n    rp_logger.error(f'An error occurred: {e}')\nfinally:\n    # It's crucial to call terminate() to ensure all pending requests are sent to ReportPortal\n    client.terminate()\n    rp_logger.info('Client terminated, all pending logs sent.')","lang":"python","description":"This quickstart demonstrates the basic usage of the ReportPortal Python client, including starting and finishing a launch, creating test items (steps), logging messages, and attaching files. It also shows how to integrate the client with Python's standard logging module using `RPLogger` and `RPLogHandler`. Environment variables are used for ReportPortal configuration (RP_ENDPOINT, RP_PROJECT, RP_API_KEY) for secure execution. The `client.terminate()` call in the finally block is essential for asynchronous operations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"5.7.4","pypi_latest":"5.7.4","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":4.5,"avg_import_s":1.18,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.09,"mem_mb":16.5,"disk_size":"30.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.2,"import_time_s":0.75,"mem_mb":16.5,"disk_size":"33M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.34,"mem_mb":18.6,"disk_size":"33.5M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.3,"import_time_s":1.13,"mem_mb":18.7,"disk_size":"36M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.41,"mem_mb":18.5,"disk_size":"25.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.3,"import_time_s":1.37,"mem_mb":18.5,"disk_size":"28M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.4,"mem_mb":19.3,"disk_size":"25.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.6,"import_time_s":1.39,"mem_mb":19.3,"disk_size":"27M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.98,"mem_mb":16.3,"disk_size":"30.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"reportportal-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":6.1,"import_time_s":0.91,"mem_mb":16.3,"disk_size":"33M"}]}}