{"id":6443,"library":"redfish","title":"Redfish Python Library","description":"The Redfish Python Library, developed by the DMTF, is a reference implementation enabling Python developers to communicate with Redfish-conformant APIs. It simplifies interactions by performing basic HTTP operations (GET, POST, PUT, PATCH, DELETE) on Redfish services. The library is actively maintained, currently at version 3.3.5, with new releases typically occurring every few months.","status":"active","version":"3.3.5","language":"en","source_language":"en","source_url":"https://github.com/DMTF/python-redfish-library","tags":["redfish","DMTF","server management","API client","REST"],"install":[{"cmd":"pip install redfish","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Used for JSON Patch operations, conditional on Python version.","package":"jsonpatch","optional":false},{"reason":"Used for JSONPath expression parsing and queries.","package":"jsonpath_ng","optional":false},{"reason":"Used for JSON Pointer operations.","package":"jsonpointer","optional":false},{"reason":"Underlying HTTP library for making requests.","package":"requests","optional":false},{"reason":"Utility belt for advanced requests usage.","package":"requests-toolbelt","optional":false},{"reason":"Enables HTTP communication over UNIX domain sockets for requests.","package":"requests-unixsocket","optional":false}],"imports":[{"note":"The DMTF's `redfish` library uses `redfish.redfish_client` (a function) to create a client instance, not the `RedfishClient` class which is often found in the separate, non-coexistent HPE `python-ilorest-library`.","wrong":"from redfish.rest.v1 import RedfishClient","symbol":"redfish_client","correct":"import redfish\nclient = redfish.redfish_client(...)"}],"quickstart":{"code":"import redfish\nimport os\n\n# Replace with your Redfish service details or use environment variables\nLOGIN_HOST = os.environ.get('REDFISH_HOST', 'https://192.168.1.100')\nLOGIN_ACCOUNT = os.environ.get('REDFISH_USERNAME', 'admin')\nLOGIN_PASSWORD = os.environ.get('REDFISH_PASSWORD', 'password')\n\ntry:\n    # Create a Redfish object\n    REDFISH_OBJ = redfish.redfish_client(\n        base_url=LOGIN_HOST,\n        username=LOGIN_ACCOUNT,\n        password=LOGIN_PASSWORD,\n        default_prefix='/redfish/v1/'\n    )\n\n    # The client automatically logs in upon creation by default.\n    # You can explicitly call login() if check_connectivity=False was used during client creation.\n    # REDFISH_OBJ.login()\n\n    # Perform a GET operation on the Service Root\n    response = REDFISH_OBJ.get('/redfish/v1/')\n    if response.status == 200:\n        print(\"Successfully connected to Redfish Service Root:\")\n        print(response.dict)\n    else:\n        print(f\"Failed to connect to Redfish Service Root: {response.status} - {response.text}\")\n\n    # Example: Get system information\n    systems_uri = response.dict.get('Systems', {}).get('@odata.id')\n    if systems_uri:\n        systems_response = REDFISH_OBJ.get(systems_uri)\n        if systems_response.status == 200:\n            print(\"\\nSystems information:\")\n            # Print the first system's summary if available\n            if systems_response.dict and 'Members' in systems_response.dict and len(systems_response.dict['Members']) > 0:\n                first_system_uri = systems_response.dict['Members'][0].get('@odata.id')\n                if first_system_uri:\n                    first_system_response = REDFISH_OBJ.get(first_system_uri)\n                    if first_system_response.status == 200:\n                        print(first_system_response.dict)\n                    else:\n                        print(f\"Failed to get first system details: {first_system_response.status}\")\n            else:\n                print(\"No systems found.\")\n        else:\n            print(f\"Failed to get systems: {systems_response.status}\")\n    else:\n        print(\"Systems collection URI not found in Service Root.\")\n\nexcept redfish.rest.v1.redfish_exception.ServerDownOrUnreachableError as e:\n    print(f\"Error: Redfish service is down or unreachable: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    # Ensure to log out the session\n    if 'REDFISH_OBJ' in locals() and REDFISH_OBJ:\n        try:\n            REDFISH_OBJ.logout()\n            print(\"\\nLogged out successfully.\")\n        except Exception as e:\n            print(f\"Error during logout: {e}\")","lang":"python","description":"This quickstart initializes a Redfish client, attempts to connect to the Redfish Service Root, and then fetches details about the first system if available. It demonstrates basic client creation, GET requests, and proper session logout. Credentials should be provided via environment variables for production use."},"warnings":[{"fix":"Upgrade to Python 3.x or pin the library version to `redfish<3.0.0`.","message":"Python 2.x support was dropped in version 3.0.0. Users on Python 2 must use `redfish<3.0.0`.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure the OpenStack 'python-redfish' package is uninstalled (`pip uninstall python-redfish`) before installing the DMTF 'redfish' library.","message":"The OpenStack 'python-redfish' module uses a conflicting package name. This library (DMTF's 'redfish') cannot coexist with it in the same environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to version 3.3.2 or newer to prevent header leakage across client instances.","message":"Before version 3.3.2, HTTP headers set on one `redfish_client` instance could unintentionally propagate to other instances due to a bug.","severity":"gotcha","affected_versions":"<3.3.2"},{"fix":"Upgrade to version 3.3.0 or newer. Be aware of potential warnings if your Redfish service exhibits this behavior.","message":"In version 3.3.0, a workaround was added for Redfish services that incorrectly omit the 'Location' header during session login, which previously led to login failures or warnings. Services with this quirk may now work, but users might still see warnings if the workaround is triggered.","severity":"gotcha","affected_versions":"<3.3.0"},{"fix":"Review any custom JSONPath-related logic if you encounter unexpected behavior after upgrading to 3.3.5, though direct public API impact is minimal.","message":"The library switched its internal JSONPath implementation from `jsonpath_rw` to `jsonpath_ng` in version 3.3.5. While primarily an internal change, advanced users or those with custom logic deeply integrated with specific `jsonpath_rw` behaviors might observe subtle differences.","severity":"gotcha","affected_versions":"3.3.5"},{"fix":"Always call `REDFISH_OBJ.logout()` when you are finished interacting with the Redfish service, preferably within a `finally` block or context manager if available.","message":"Redfish sessions created with the library may persist on the server until they time out if `logout()` is not explicitly called. Although the client's destructor includes a logout, explicit calls are recommended for robust session management.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}