API (qbraid.api)

init_job(vendor_job_id, device, circuits, shots)

Initialize data dictionary for new qbraid job and create associated MongoDB job document.

get_job_data(qbraid_job_id[, update])

Update a new MongoDB job document.


Base class for errors raised in the qbraid.api module


Base class for errors raised authorizing user


Base class for errors raised while setting a user configuartion


Exception re-raising a RequestException.

PostForcelistRetry([total, connect, read, ...])

Custom urllib3.Retry class that performs retry on POST errors in the force list.

class QbraidSession(user_email=None, api_key=None, refresh_token=None, id_token=None, base_url=None, retries_total=5, retries_connect=3, backoff_factor=0.5)[source]

Custom session with handling of request urls and authentication.

This is a child class of requests.Session. It handles qbraid authentication with custom headers, has SSL verification disabled for compatibility with lab, and returns all responses as jsons for convenience in the sdk.

  • user_email (Optional[str]) – qBraid / JupyterHub User.

  • api_key (Optional[str]) – Authenticated qBraid API key.

  • refresh_token (Optional[str]) – Authenticated qBraid refresh-token.

  • id_token (Optional[str]) – Authenticated qBraid id-token.

  • base_url (Optional[str]) – Base URL for the session’s requests.

  • retries_total (int) – Number of total retries for the requests.

  • retries_connect (int) – Number of connect retries for the requests.

  • backoff_factor (float) – Backoff factor between retry attempts.

__init__(user_email=None, api_key=None, refresh_token=None, id_token=None, base_url=None, retries_total=5, retries_connect=3, backoff_factor=0.5)[source]


__init__([user_email, api_key, ...])


Closes all adapters and as such the session

delete(url, **kwargs)

Sends a DELETE request.

get(url, **kwargs)

Sends a GET request.


Returns the appropriate connection adapter for the given URL.


Returns the config value of specified config.


Receives a Response.

head(url, **kwargs)

Sends a HEAD request.

merge_environment_settings(url, proxies, ...)

Check the environment and merge it with some settings.

mount(prefix, adapter)

Registers a connection adapter to a prefix.

options(url, **kwargs)

Sends a OPTIONS request.

patch(url[, data])

Sends a PATCH request.

post(url[, data, json])

Sends a POST request.


Constructs a PreparedRequest for transmission and returns it.

put(url[, data])

Sends a PUT request.

rebuild_auth(prepared_request, response)

When being redirected we may want to strip authentication from the request to avoid leaking credentials.

rebuild_method(prepared_request, response)

When being redirected we may want to change the method of the request based on certain specs or browser behavior.

rebuild_proxies(prepared_request, proxies)

This method re-evaluates the proxy configuration by considering the environment variables.

request(method, url, **kwargs)

Construct, prepare, and send a Request.

resolve_redirects(resp, req[, stream, ...])

Receives a Response.

save_config([user_email, api_key, ...])

Create qbraidrc file.

send(request, **kwargs)

Send a given PreparedRequest.

should_strip_auth(old_url, new_url)

Decide whether Authorization header should be removed when redirecting



Return the qbraid api url.


Return the session user email.


Return the api key.


Return the session refresh token.