Skip to main content
https://img.shields.io/pypi/v/redfish.svg?maxAge=2592000 https://img.shields.io/github/release/DMTF/python-redfish-library.svg?maxAge=2592000 https://img.shields.io/badge/License-BSD%203--Clause-blue.svg https://img.shields.io/pypi/pyversions/redfish.svg?maxAge=2592000

Description

As of version 3.0.0, Python2 is no longer supported. If Python2 is required, redfish<3.0.0 can be specified in a requirements file.

REST (Representational State Transfer) is a web based software architectural style consisting of a set of constraints that focuses on a system’s resources. The Redfish library performs GET, POST, PUT, PATCH and DELETE HTTP operations on resources within a Redfish service. Go to the wiki for more details.

Installing

pip install redfish

The asynchronous client has an optional aiohttp dependency:

pip install redfish[aiohttp]

Building from zip file source

python setup.py sdist --formats=zip (this will produce a .zip file)
cd dist
pip install redfish-x.x.x.zip

Requirements

Ensure the system does not have the OpenStack “python-redfish” module installed on the target system. This module is using a conflicting package name that this library already uses. The module in question can be found here: https://pypi.org/project/python-redfish/

Required external packages:

jsonpatch<=1.24 ; python_version == '3.4'
jsonpatch ; python_version >= '3.5'
jsonpath_ng
jsonpointer
requests
requests-toolbelt
requests-unixsocket

The optional asynchronous client requires aiohttp>=3.9.0.

If installing from GitHub, you may install the external packages by running:

pip install -r requirements.txt

Usage

A set of examples is provided under the examples directory of this project. In addition to the directives present in this paragraph, you will find valuable implementation tips and tricks in those examples.

Import the relevant Python module

For a Redfish conformant application import the relevant Python module.

For Redfish conformant application:

import redfish

Create a Redfish object

The Redfish object contains three required parameters:

  • base_url: The address of the Redfish service (with scheme). Example: https://192.168.1.100. For Unix sockets, use the scheme http+unix://, followed by the percent-encoded filepath to the socket.

  • username: The username for authentication.

  • password: The password for authentication.

There are several optional parameters:

  • default_prefix: The path to the Redfish service root. This is only used for initial connection and authentication with the service. The default value is /redfish/v1/.

  • sessionkey: The session key to use with subsequent requests. This can be used to bypass the login step. The default value is None.

  • cafile: The file path to the CA certificate that issued the Redfish service’s certificate. The default value is None.

  • timeout: The number of seconds to wait for a response before closing the connection. The default value is None.

  • max_retry: The number of retries to perform an operation before giving up. The default value is 10.

  • proxies: A dictionary containing protocol to proxy URL mappings. The default value is None. See Using proxies.

  • check_connectivity: A boolean value to determine whether the client immediately attempts a connection to the base_url. The default is True.

To create a Redfish object, call the redfish_client method:

REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
                      password=login_password, default_prefix='/redfish/v1/')

Login to the service

After creating the REDFISH_OBJ, perform the login operation to authenticate with the service. The auth parameter allows you to specify the login method. Possible values are:

  • session: Creates a Redfish session with a session token.

  • basic: Uses HTTP Basic authentication for all requests.

REDFISH_OBJ.login(auth="session")

Perform a GET operation

A simple GET operation can be performed to obtain the data present in any valid path. An example of GET operation on the path “/redfish/v1/Systems/1” is shown below:

response = REDFISH_OBJ.get("/redfish/v1/Systems/1")

Perform a POST operation

A POST operation can be performed to create a resource or perform an action. An example of a POST operation on the path “/redfish/v1/Systems/1/Actions/ComputerSystem.Reset” is shown below:

body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/Systems/1/Actions/ComputerSystem.Reset", body=body)

Notes about HTTP methods and arguments

The previous sections showed example GET and POST requests. The following is a list of the different methods supported:

  • get: Performs an HTTP GET operation to retrieve a resource from a URI.

  • head: Performs an HTTP HEAD operation to retrieve response headers from a URI, but no body.

  • post: Performs an HTTP POST operation to perform an action or create a new resource.

  • put: Performs an HTTP PUT operation to replace an existing resource.

  • patch: Performs an HTTP PATCH operation to update an existing resource.

  • delete: Performs an HTTP DELETE operation to remove a resource.

Each of the previous methods allows for the following arguments:

  • path: Required. String. The URI in which to invoke the operation.

    • Example: "/redfish/v1/Systems/1"

  • args: Dictionary. Query parameters to supply with the request.

    • The key-value pairs in the dictionary are the query parameter name and the query parameter value to supply.

    • Example: {"$select": "Reading,Status"}

  • body: Dictionary, List, Bytes, or String. The request body to provide with the request.

    • Not supported for get, head, or delete methods.

    • The data type supplied will dictate the encoding.

    • A dictionary is the most common usage, which results in a JSON body.

    • Example: {"ResetType": "GracefulShutdown"}

    • A list is used to supply multipart forms, which is useful for multipart HTTP push updates.

    • Bytes is used to supply an octet stream.

    • A string is used to supply an unstructed body, which may be used in some OEM cases.

  • headers: Dictionary. Additional HTTP headers to supply with the request.

    • The key-value pairs in the dictionary are the HTTP header name and the HTTP header value to supply.

    • Example: {"If-Match": etag_value}

  • timeout: Number. The number of seconds to wait for a response before closing the connection for this request.

    • Overrides the timeout value specified when the Redfish object is created for this request.

    • This can be useful when a particular URI is known to take a long time to respond, such as with firmware updates.

    • The default value is None, which indicates the object-defined timeout is used.

  • max_retry: Number. The number of retries to perform an operation before giving up for this request.

    • Overrides the max retry value specified when the Redfish object is created for this request.

    • This can be useful when a particular URI is known to take multiple retries.

    • The default value is None, which indicates the object-defined max retry count is used.

Asynchronous client

The additive asynchronous API uses aiohttp and does not change the existing synchronous client. The caller must provide an aiohttp.ClientSession and remains responsible for closing it. This allows an application to control connection pooling, TLS trust, proxy behavior, and session lifetime in one place.

The asynchronous client supports Redfish session authentication and HTTP Basic authentication. Authentication is explicit: call login after creating the client and logout when finished. login uses Redfish session authentication by default, matching the synchronous client. Redfish authentication requires HTTPS. For compatibility with nonconforming services, session login uses the standard session collection URI and emits a warning if the service root incorrectly responds with HTTP 401.

The asynchronous context manager creates and terminates a Redfish session. It does not close the caller’s aiohttp.ClientSession:

import aiohttp

from redfish.aio import AsyncRedfishClient


async def get_service_root():
    async with aiohttp.ClientSession() as session:
        async with AsyncRedfishClient(
            base_url="https://bmc.example",
            username="user",
            password="password",
            session=session,
            timeout=10,
        ) as client:
            return await client.get_service_root()

To use HTTP Basic authentication, call await client.login(auth="basic") and ensure await client.logout() is called when finished. Basic login configures the authentication header; the service validates the credentials when the client performs its next request. An existing Redfish session can be supplied with the session_key argument and, when available, its resource URI with session_location. Supplying the location allows logout to terminate that session.

If session login reports that the account password must change, login raises RedfishPasswordChangeRequiredError with the account URI in password_change_uri while retaining the restricted session. The caller can use that client to change the password and then call logout. The asynchronous context manager instead cleans up a restricted session before propagating this exception because a failed __aenter__ call cannot return the client to the context body.

If an authenticated GET or HEAD receives HTTP 401, the client re-establishes an expired Redfish session once when credentials are available. State-changing requests are never retried automatically. Callers can therefore decide whether it is safe to repeat a failed POST, PUT, PATCH, or DELETE.

Requests do not follow redirects, and advertised resource, action, and session targets are accepted only when they resolve to the configured Redfish origin. Authentication headers provided by the caller cannot replace the client’s configured Basic credentials or session token. These rules prevent credentials from being sent to another origin.

get, head, post, put, patch, and delete are coroutines with the same path, args, body, headers, and timeout concepts as the synchronous methods. The returned response is fully read and cached before the coroutine returns, so it can be inspected after the underlying aiohttp response closes.

The optional request timeout bounds each HTTP request. TLS verification is controlled entirely by the injected ClientSession. Configure that session with an appropriate CA certificate or SSL context for a Redfish service using a private or self-signed certificate.

Working with tasks

POST, PATCH, PUT, and DELETE operations may result in a task, describing an operation with a duration greater than the span of a single request. The action message object that is_processing will return a task that can be accessed reviewed when polled with monitor. An example of a POST operation with a possible task is shown below.

body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/Systems/1/Actions/ComputerSystem.Reset", body=body)
if(response.is_processing):
    task = response.monitor(REDFISH_OBJ)

    while(task.is_processing):
        retry_time = task.retry_after
        task_status = task.dict['TaskState']
        time.sleep(retry_time if retry_time else 5)
        task = response.monitor(REDFISH_OBJ)

Logout the created session

Ensure you perform a logout operation when done interacting with the Redfish service. If this step isn’t performed, the session will remain active until the Redfish service decides to close it.

REDFISH_OBJ.logout()

The logout operation deletes the current sesssion from the service. The redfish_client object destructor includes a logout statement.

Using proxies

There are two methods for using proxies: configuring environment variables or directly providing proxy information.

Environment variables

You can use a proxy by specifying the HTTP_PROXY and HTTPS_PROXY environment variables. Hosts to be excluded from the proxy can be specified using the NO_PROXY environment variable.

export HTTP_PROXY="http://192.168.1.10:8888"
export HTTPS_PROXY="http://192.168.1.10:8888"

Directly provided

You can use a proxy by building a dictionary containing the proxy information and providing it to the proxies argument when creating the redfish_client object. The key-value pairs of the dictionary contain the protocol and the proxy URL for the protocol.

proxies = {
    'http': 'http://192.168.1.10:8888',
    'https': 'http://192.168.1.10:8888',
}
REDFISH_OBJ = redfish.redfish_client(base_url=login_host, username=login_account, \
                      password=login_password, proxies=proxies)

SOCKS proxy support

An additional package is required to use SOCKS proxies.

pip install -U requests[socks]

Once installed, the proxy can be configured using environment variables or directly provided like any other proxy. For example:

export HTTP_PROXY="socks5h://localhost:8123"
export HTTPS_PROXY="socks5h://localhost:8123"

Release Process

Before the first release, configure a PyPI Trusted Publisher for the DMTF/python-redfish-library repository, the main.yml workflow, and the pypi environment. Configure the pypi GitHub environment with a required reviewer so that publishing to PyPI requires explicit approval.

  1. Go to the “Actions” page.

  2. Select the “Update Version and Create Release” workflow.

  3. Click “Run workflow”, fill out the version and change entries, and run the workflow. It updates the version and changelog, pushes the changes to main, and creates the tagged GitHub release.

  4. The workflow queues “Publish to PyPI” at the release tag. Review and approve its pending deployment to the pypi environment.

  5. The publishing workflow verifies the tagged release metadata, builds the distributions, and publishes them to PyPI using Trusted Publishing.

Release files for redfish 3.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redfish 3.4.0
File Size Uploaded
redfish-3.4.0.tar.gz 50.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redfish 3.4.0
File Interpreter ABI Platform
redfish-3.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 101.5 kB

Release files / redfish-3.4.0.tar.gz

Download URL redfish-3.4.0.tar.gz
Size 50.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7f0c206c831b29f217c8d8c4a2f8fb0baa90240ad4ba825b908818f5318c3d11
BLAKE2b-256 checksum
How to use checksums
1962e1fe180a48d6acf142746166eb53a17fa80a7cdcf98f74f0248573e75849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release files / redfish-3.4.0-py3-none-any.whl

Download URL redfish-3.4.0-py3-none-any.whl
Size 51.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5d532f54731aa105178d4509db6fdd90fac87a98b662a589f78ca60fa8ec82a
BLAKE2b-256 checksum
How to use checksums
131e258b9b3e036f135200037c5dfc3eacad9c0631bdfa38c6d1f0bc97e86287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.4.0 This release

2 release files

3.3.9

2 release files

3.3.8

2 release files

3.3.7

2 release files

3.3.6

2 release files

3.3.5

2 release files

3.3.4

2 release files

3.3.3

2 release files

3.3.2

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.9

2 release files

3.2.8

2 release files

3.2.7

2 release files

3.2.6

2 release files

3.2.5

2 release files

3.2.4

2 release files

3.2.2

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.9

2 release files

3.1.8

2 release files

3.1.7

2 release files

3.1.6

2 release files

3.1.5

2 release files

3.1.4

2 release files

3.1.3

1 release file

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.9

2 release files

2.1.8

1 release file

2.1.7

1 release file

2.1.6

1 release file

2.1.5

1 release file

2.1.4

1 release file

2.1.3

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.9

1 release file

2.0.8

1 release file

2.0.7

1 release file

2.0.6

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page