Skip to main content

Official API wrapper

Project description

Python & OVH APIs

Lightweight wrapper around OVH’s APIs. Handles all the hard work including credential creation and requests signing.

PyPi Version Build Status Coverage Status
# -*- encoding: utf-8 -*-

import ovh

# Instantiate. Visit
# to get your credentials
client = ovh.Client(
    application_key='<application key>',
    application_secret='<application secret>',
    consumer_key='<consumer key>',

# Print nice welcome message
print "Welcome", client.get('/me')['firstname']


The python wrapper works with Python 2.6+ and Python 3.2+.

The easiest way to get the latest stable release is to grab it from pypi using pip.

pip install ovh

Alternatively, you may get latest development version directly from Git.

pip install -e git+

Example Usage

Use the API on behalf of a user

1. Create an application

To interact with the APIs, the SDK needs to identify itself using an application_key and an application_secret. To get them, you need to register your application. Depending the API you plan to use, visit:

Once created, you will obtain an application key (AK) and an application secret (AS).

2. Configure your application

The easiest and safest way to use your application’s credentials is to create an ovh.conf configuration file in application’s working directory. Here is how it looks like:

; general configuration: default endpoint

; configuration specific to 'ovh-eu' endpoint
; uncomment following line when writing a script application
; with a single consumer key.

Depending on the API you want to use, you may set the endpoint to:

  • ovh-eu for OVH Europe API
  • ovh-ca for OVH North-America API
  • soyoustart-eu for So you Start Europe API
  • soyoustart-ca for So you Start North America API
  • kimsufi-eu for Kimsufi Europe API
  • kimsufi-ca for Kimsufi North America API
  • runabove-ca for RunAbove API

See Configuration for more information on available configuration mechanisms.


When using a versioning system, make sure to add ovh.conf to ignored files. It contains confidential/security-sensitive informations!

3. Authorize your application to access a customer account

To allow your application to access a customer account using the API on your behalf, you need a consumer key (CK).

Here is a sample code you can use to allow your application to access a customer’s informations:

# -*- encoding: utf-8 -*-

import ovh

# create a client using configuration
client = ovh.Client()

# Request RO, /me API access
ck = client.new_consumer_key_request()
ck.add_rules(ovh.API_READ_ONLY, "/me")

# Request token
validation = ck.request()

print "Please visit %s to authenticate" % validation['validationUrl']
raw_input("and press Enter to continue...")

# Print nice welcome message
print "Welcome", client.get('/me')['firstname']
print "Btw, your 'consumerKey' is '%s'" % validation['consumerKey']

Returned consumerKey should then be kept to avoid re-authenticating your end-user on each use.


To request full and unlimited access to the API, you may use add_recursive_rules:

# Allow all GET, POST, PUT, DELETE on /* (full API)
ck.add_recursive_rules(ovh.API_READ_WRITE, '/')

Install a new mail redirection

e-mail redirections may be freely configured on domains and DNS zones hosted by OVH to an arbitrary destination e-mail using API call POST /email/domain/{domain}/redirection.

For this call, the api specifies that the source adress shall be given under the from keyword. Which is a problem as this is also a reserved Python keyword. In this case, simply prefix it with a ‘_’, the wrapper will automatically detect it as being a prefixed reserved keyword and will subsitute it. Such aliasing is only supported with reserved keywords.

# -*- encoding: utf-8 -*-

import ovh


# create a client
client = ovh.Client()

# Create a new alias'/email/domain/%s/redirection' % DOMAIN,
print "Installed new mail redirection from %s to %s" % (SOURCE, DESTINATION)

Grab bill list

Let’s say you want to integrate OVH bills into your own billing system, you could just script around the /me/bills endpoints and even get the details of each bill lines using /me/bill/{billId}/details/{billDetailId}.

This example assumes an existing Configuration with valid application_key, application_secret and consumer_key.

# -*- encoding: utf-8 -*-

import ovh

# create a client
client = ovh.Client()

# Grab bill list
bills = client.get('/me/bill')
for bill in bills:
    details = client.get('/me/bill/%s' % bill)
    print "%12s (%s): %10s --> %s" % (

Enable network burst in SBG1

‘Network burst’ is a free service but is opt-in. What if you have, say, 10 servers in SBG-1 datacenter? You certainely don’t want to activate it manually for each servers. You could take advantage of a code like this.

This example assumes an existing Configuration with valid application_key, application_secret and consumer_key.

# -*- encoding: utf-8 -*-

import ovh

# create a client
client = ovh.Client()

# get list of all server names
servers = client.get('/dedicated/server/')

# find all servers in SBG-1 datacenter
for server in servers:
    details = client.get('/dedicated/server/%s' % server)
    if details['datacenter'] == 'sbg1':
        # enable burst on server
        client.put('/dedicated/server/%s/burst' % server, status='active')
        print "Enabled burst for %s server located in SBG-1" % server

List application authorized to access your account

Thanks to the application key / consumer key mechanism, it is possible to finely track applications having access to your data and revoke this access. This examples lists validated applications. It could easily be adapted to manage revocation too.

This example assumes an existing Configuration with valid application_key, application_secret and consumer_key.

# -*- encoding: utf-8 -*-

import ovh
from tabulate import tabulate

# create a client
client = ovh.Client()

credentials = client.get('/me/api/credential', status='validated')

# pretty print credentials status
table = []
for credential_id in credentials:
    credential_method = '/me/api/credential/'+str(credential_id)
    credential = client.get(credential_method)
    application = client.get(credential_method+'/application')

        '[%s] %s' % (application['status'], application['name']),
print tabulate(table, headers=['ID', 'App Name', 'Description',
                               'Token Creation', 'Token Expiration', 'Token Last Use'])

Before running this example, make sure you have the tabulate library installed. It’s a pretty cool library to pretty print tabular data in a clean and easy way.

>>> pip install tabulate

Open a KVM (remote screen) on a dedicated server

Recent dedicated servers come with an IPMI interface. A lightweight control board embedded on the server. Using IPMI, it is possible to get a remote screen on a server. This is particularly useful to tweak the BIOS or troubleshoot boot issues.

Hopefully, this can easily be automated using a simple script. It assumes Java Web Start is fully installed on the machine and a consumer key allowed on the server exists.

# -*- encoding: utf-8 -*-
import ovh
import sys
import time
import tempfile
import subprocess

# check arguments
if len(sys.argv) != 3:
    print "Usage: %s SERVER_NAME ALLOWED_IP_V4" % sys.argv[0]

server_name = sys.argv[1]
allowed_ip = sys.argv[2]

# create a client
client = ovh.Client()

# create a KVM'/dedicated/server/'+server_name+'/features/ipmi/access', ipToAllow=allowed_ip, ttl=15, type="kvmipJnlp")

# open the KVM, when ready
while True:
        # use a named temfile and feed it to java web start
        with tempfile.NamedTemporaryFile() as f:

Running is only a simple command line:

# Basic
python $(curl

# Use a specific consumer key


You have 3 ways to provide configuration to the client:
  • write it directly in the application code
  • read environment variables or predefined configuration files
  • read it from a custom configuration file

Embed the configuration in the code

The straightforward way to use OVH’s API keys is to embed them directly in the application code. While this is very convenient, it lacks of elegance and flexibility.

Example usage:

client = ovh.Client(
    application_key='<application key>',
    application_secret='<application secret>',
    consumer_key='<consumer key>',

Environment vars and predefined configuration files

Alternatively it is suggested to use configuration files or environment variables so that the same code may run seamlessly in multiple environments. Production and development for instance.

This wrapper will first look for direct instanciation parameters then OVH_ENDPOINT, OVH_APPLICATION_KEY, OVH_APPLICATION_SECRET and OVH_CONSUMER_KEY environment variables. If either of these parameter is not provided, it will look for a configuration file of the form:

; general configuration: default endpoint

; configuration specific to 'ovh-eu' endpoint

The client will successively attempt to locate this configuration file in

  1. Current working directory: ./ovh.conf
  2. Current user’s home directory ~/.ovh.conf
  3. System wide configuration /etc/ovh.conf

This lookup mechanism makes it easy to overload credentials for a specific project or user.

Example usage:

client = ovh.Client()

Custom configuration file

You can also specify a custom configuration file. With this method, you won’t be able to inherit values from environment.

Example usage:

client = ovh.Client(config_file='/my/config.conf')

Passing parameters

You can call all the methods of the API with the necessary arguments.

If an API needs an argument colliding with a Python reserved keyword, it can be prefixed with an underscore. For example, from argument of POST /email/domain/{domain}/redirection may be replaced by _from.

With characters invalid in python argument name like a dot, you can:

# -*- encoding: utf-8 -*-

import ovh

params = {}
params['date.from'] = '2014-01-01'
params[''] = '2015-01-01'

# create a client
client = ovh.Client()

# pass parameters using **'/me/bills', **params)


This wrapper uses standard Python tools, so you should feel at home with it. Here is a quick outline of what it may look like. A good practice is to run this from a virtualenv.

Get the sources

git clone
cd python-ovh
python develop

You’ve developed a new cool feature ? Fixed an annoying bug ? We’d be happy to hear from you !

Run the tests

Simply run nosetests. It will automatically load its configuration from setup.cfg and output full coverage status. Since we all love quality, please note that we do not accept contributions with test coverage under 100%.

pip install -r requirements-dev.txt
nosetests # 100% coverage is a hard minimum

Build the documentation

Documentation is managed using the excellent Sphinx system. For example, to build HTML documentation:

cd python-ovh/docs
make html

Supported APIs

OVH Europe

OVH North America

So you Start Europe

So you Start North America

Kimsufi Europe

Kimsufi North America


3-Clause BSD

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
ovh-0.4.4.tar.gz (551.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page