{"id":1612,"library":"opsgenie-sdk","title":"Opsgenie Python SDK","description":"The Opsgenie Python SDK provides a client for interacting with the Opsgenie REST API, enabling programmatic management of alerts, incidents, heartbeats, and account settings. The current version is 2.1.5, and the library generally maintains a frequent release cadence for bug fixes and dependency updates, especially within the 2.x series.","status":"active","version":"2.1.5","language":"en","source_language":"en","source_url":"https://github.com/opsgenie/opsgenie-python-sdk","tags":["opsgenie","api-client","alerting","incident-management","devops"],"install":[{"cmd":"pip install opsgenie-sdk","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"HTTP client for API requests; critical for network communication and has had security updates.","package":"urllib3"}],"imports":[{"symbol":"Configuration","correct":"from opsgenie_sdk import Configuration"},{"symbol":"ApiClient","correct":"from opsgenie_sdk import ApiClient"},{"symbol":"AlertApi","correct":"from opsgenie_sdk import AlertApi"},{"symbol":"CreateAlertRequest","correct":"from opsgenie_sdk import CreateAlertRequest"},{"symbol":"IncidentApi","correct":"from opsgenie_sdk import IncidentApi"},{"symbol":"CreateIncidentRequest","correct":"from opsgenie_sdk import CreateIncidentRequest"},{"symbol":"AlertResponder","correct":"from opsgenie_sdk import AlertResponder"},{"note":"ApiException is located within the opsgenie_sdk.rest submodule.","wrong":"from opsgenie_sdk import ApiException","symbol":"ApiException","correct":"from opsgenie_sdk.rest import ApiException"}],"quickstart":{"code":"import opsgenie_sdk\nimport os\n\nconfiguration = opsgenie_sdk.Configuration()\n# Configure API key authorization: OpsgenieAPIKey\n# Replace 'YOUR_API_KEY' or set OG_API_KEY environment variable\nconfiguration.api_key['Authorization'] = os.environ.get('OG_API_KEY', 'YOUR_API_KEY')\nconfiguration.api_key_prefix['Authorization'] = 'GenieKey'\n\n# create an instance of the API client\napi_client = opsgenie_sdk.ApiClient(configuration)\nalert_api = opsgenie_sdk.AlertApi(api_client)\n\n# Create an alert request body\nbody = opsgenie_sdk.CreateAlertRequest(\n    message='Test Alert from Python SDK Checklist.day',\n    description='This is a test alert created via the Python SDK quickstart.',\n    priority='P3',\n    alias='checklist_sdk_test_alert',\n    entity='Test Service',\n    tags=['checklist', 'sdk'],\n    details={'source': 'python-sdk-quickstart'},\n    source='Python SDK Quickstart'\n)\n\ntry:\n    api_response = alert_api.create_alert(body=body)\n    print('Alert created successfully:')\n    print(f'  ID: {api_response.alert.id}')\n    print(f'  Alias: {api_response.alert.alias}')\n    print(f'  Status: {api_response.status}')\nexcept opsgenie_sdk.rest.ApiException as e:\n    print(f\"Exception when calling AlertApi->create_alert: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the Opsgenie SDK, configure API key authentication, and create a basic alert. Ensure you have an Opsgenie API key set as an environment variable `OG_API_KEY` or replace 'YOUR_API_KEY' directly in the code."},"warnings":[{"fix":"Rewrite integration code following the new API documentation (e.g., https://docs.opsgenie.com/docs/opsgenie-python-api-v2-1) and upgrade to version 2.0.1 or newer.","message":"The SDK underwent a complete re-implementation with version 2.0.1. All imports, class names, and API interaction patterns changed significantly from the 0.x.x series.","severity":"breaking","affected_versions":"All versions prior to 2.0.1"},{"fix":"Upgrade to opsgenie-sdk version 2.1.5 or newer to ensure you are using a patched `urllib3` dependency.","message":"Older versions of the SDK (prior to 2.1.5) may depend on vulnerable versions of `urllib3` (below 1.26.5), which is susceptible to Denial Of Service (DoS) issues. The SDK itself fixed this by updating its `urllib3` dependency.","severity":"gotcha","affected_versions":"< 2.1.5"},{"fix":"Refer to the official documentation or API schema for exact field names in specific API calls, especially for the Incident API. Newer patch releases might have addressed some of these inconsistencies.","message":"When working with the Incident API in early 2.x versions (e.g., 2.0.x), there were inconsistencies in field names. For example, `teamId` was required to be `ownerTeam`, and `details` should be `extraProperties` in some contexts.","severity":"gotcha","affected_versions":"2.0.x"},{"fix":"No action required unless your application explicitly relied on `numpy` being installed as a transitive dependency of `opsgenie-sdk`. Ensure your project's `requirements.txt` explicitly lists any direct dependencies.","message":"The `numpy` dependency was removed in version 2.1.1. While this is generally a positive change for reducing dependencies, users upgrading from earlier `2.x.x` versions might notice `numpy` is no longer installed automatically.","severity":"gotcha","affected_versions":"< 2.1.1"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}