Registry / http-networking / ovh
library1.2.0pypypi✓ verified 82d ago

The `ovh` Python library is the official module for interacting with OVHcloud APIs. It provides a thin wrapper that handles the complexities of credential creation and request signing. The library is currently at version 1.2.0 and is actively maintained, with new releases incorporating features and compatibility updates for modern Python versions. It is designed to simplify automation and management of OVHcloud services.

pip install ovh
INSTALL
IMPORT
SIG · OVH
O
ovh
http-networkingpythonv1.2.0
Install
2.3s avg
Import
681ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.723s · 23MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.3s · import 0.640s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from ovh import Client
import ovh
APIError
from ovh import APIError
import ovh
API_READ_WRITE
from ovh import API_READ_WRITE
import ovh

This quickstart demonstrates how to initialize the OVHcloud API client using environment variables for credentials (recommended for security). It then makes a simple call to retrieve the current user's information. Replace placeholder keys with your actual OVHcloud Application Key, Application Secret, and Consumer Key. Remember to obtain your Consumer Key via the OVHcloud API console or the `request_consumerkey` helper after creating your application.

import os import ovh # Best practice: load credentials from environment variables or ovh.conf # Alternatively, embed directly (less recommended for production) endpoint = os.environ.get('OVH_ENDPOINT', 'ovh-eu') # e.g., 'ovh-eu', 'ovh-ca' application_key = os.environ.get('OVH_APPLICATION_KEY', 'YOUR_APP_KEY') application_secret = os.environ.get('OVH_APPLICATION_SECRET', 'YOUR_APP_SECRET') consumer_key = os.environ.get('OVH_CONSUMER_KEY', 'YOUR_CONSUMER_KEY') try: client = ovh.Client( endpoint=endpoint, application_key=application_key, application_secret=application_secret, consumer_key=consumer_key, ) # Example: Get current user details me = client.get('/me') print(f"Hello, {me['firstname']} {me['lastname']}!") # Example: List your dedicated servers (requires appropriate rights) # servers = client.get('/dedicated/server') # print(f"Your dedicated servers: {servers}") except ovh.exceptions.APIError as e: print(f"API Error: {e.code} - {e.message}") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingVersion 1.0.0 and later of `python-ovh` dropped support for Python 2.7, 3.4, and 3.5. Users running these older Python versions must use `python-ovh` version 0.6.x or earlier.
fix
Upgrade your Python environment to 3.7+ or pin the library version to `ovh~=0.6.0` if unable to upgrade Python.
affects: >=1.0.0
gotchaWhen making `POST` or `PUT` requests, the Python client automatically serializes parameters to JSON. Do NOT manually use `json.dumps()` on your payload, as this will lead to a `TypeError` or an `Invalid JSON object` error.
fix
Pass Python dictionaries or keyword arguments directly to `client.post()` or `client.put()`. The library handles the JSON serialization.
affects: All
gotchaEmbedding API keys directly in your code is a security risk and lacks flexibility. OVHcloud recommends using configuration files (`ovh.conf`) or environment variables for managing credentials across different environments (e.g., development, production).
fix
Store `application_key`, `application_secret`, and `consumer_key` in an `ovh.conf` file in your working directory or as environment variables (e.g., `OVH_APPLICATION_KEY`). The client automatically reads these if not provided explicitly.
affects: All
gotchaThe `consumer_key` (CK) is specific to an application *and* a user account. It is obtained through a 3-step OAuth-like process involving requesting a new CK, redirecting the user to a validation URL, and the user authenticating to grant access. A hardcoded CK will only work if pre-authorized.
fix
For scripts requiring user authorization, implement the `request_consumerkey` flow. For personal use or pre-authorized applications, ensure the CK is valid and has the necessary permissions. Visit `https://api.ovh.com/createToken/` to manage application and consumer keys.
affects: All
Upgrade
Version history
1.2.0latest on PyPI · released Jul 23, 2024
Audit
Dependencies
pythonrequiredPython 3.7+ is required for ovh versions 1.0.0 and above.
tabulateoptionalRecommended for pretty-printing tabular data in some examples provided by OVHcloud.
Agent activity
21 hits · last 30 days
node
20
Amazon
1
Resources
ovh — pip install ovh · libregistry