{"id":8392,"library":"ovh","title":"OVHcloud API Client","description":"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.","status":"active","version":"1.2.0","language":"en","source_language":"en","source_url":"https://github.com/ovh/python-ovh.git","tags":["ovhcloud","api-client","cloud","automation","infrastructure","oauth"],"install":[{"cmd":"pip install ovh","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Python 3.7+ is required for ovh versions 1.0.0 and above.","package":"python","optional":false},{"reason":"Recommended for pretty-printing tabular data in some examples provided by OVHcloud.","package":"tabulate","optional":true}],"imports":[{"symbol":"Client","correct":"import ovh\nclient = ovh.Client(...)"}],"quickstart":{"code":"import os\nimport ovh\n\n# Best practice: load credentials from environment variables or ovh.conf\n# Alternatively, embed directly (less recommended for production)\nendpoint = os.environ.get('OVH_ENDPOINT', 'ovh-eu') # e.g., 'ovh-eu', 'ovh-ca'\napplication_key = os.environ.get('OVH_APPLICATION_KEY', 'YOUR_APP_KEY')\napplication_secret = os.environ.get('OVH_APPLICATION_SECRET', 'YOUR_APP_SECRET')\nconsumer_key = os.environ.get('OVH_CONSUMER_KEY', 'YOUR_CONSUMER_KEY')\n\ntry:\n    client = ovh.Client(\n        endpoint=endpoint,\n        application_key=application_key,\n        application_secret=application_secret,\n        consumer_key=consumer_key,\n    )\n\n    # Example: Get current user details\n    me = client.get('/me')\n    print(f\"Hello, {me['firstname']} {me['lastname']}!\")\n\n    # Example: List your dedicated servers (requires appropriate rights)\n    # servers = client.get('/dedicated/server')\n    # print(f\"Your dedicated servers: {servers}\")\n\nexcept ovh.exceptions.APIError as e:\n    print(f\"API Error: {e.code} - {e.message}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.7+ or pin the library version to `ovh~=0.6.0` if unable to upgrade Python.","message":"Version 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.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Pass Python dictionaries or keyword arguments directly to `client.post()` or `client.put()`. The library handles the JSON serialization.","message":"When 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Embedding 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).","severity":"gotcha","affected_versions":"All"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Pass the dictionary or keyword arguments directly to the method: `client.post('/path', param1='value1', param2='value2')` or `client.post('/path', **my_dict_params)`.","cause":"Attempting to manually `json.dumps()` a Python dictionary when passing it as a parameter to `client.post()` or `client.put()`.","error":"TypeError: {'my_param': 'value'} is not JSON serializable"},{"fix":"Double-check your `application_secret` and `consumer_key`. Ensure your system's clock is synchronized. Verify that the `consumer_key` has the required access rights for the API path you are trying to call. Refer to `https://api.ovh.com/createToken/` to review and generate credentials.","cause":"Incorrect `application_secret` or `consumer_key`, a timestamp skew between your system and the API, or the consumer key lacking necessary permissions for the requested API endpoint.","error":"ovh.exceptions.APIError: 403 Forbidden - Invalid signature"},{"fix":"Verify that your `endpoint` (e.g., 'ovh-eu') is correct. Ensure all required authentication parameters (`application_key`, `application_secret`, `consumer_key`) are provided and valid, either in code, `ovh.conf`, or environment variables.","cause":"General misconfiguration of the client, such as an incorrect `endpoint` or missing required authentication parameters.","error":"ovh.exceptions.APIError: 400 Bad Request - Low HTTP request failed error"}]}