Site API


The Gandi Site API provides a set of remote requests to manage your sites. Gandi sites are created using a website builder Provider. Our API actually uses basekit.

Connect to the API server

The Gandi Site API is provided through a set of XML-RPC calls:

>>> import xmlrpc.client
>>> api = xmlrpc.client.ServerProxy('')
>>> apikey = 'my 24-character API key'
>>> # Now you can call API methods.
>>> # You must authenticate yourself by passing
>>> # the API key as the first method's argument
>>> version =


In Python, use the xmlrpcclient module from the standard library.

// Library installed from PEAR
require_once 'XML/RPC2/Client.php';

// The first step is to connect to the API
$version_api = XML_RPC2_Client::create(
    array( 'prefix' => 'version.', 'sslverify' => True )

// Warning !
// PEAR::XML_RPC2 checks the SSL certificate with Curl
// Curl has its own CA bundle so you may :
// * disable the 'sslverify' option: leads to security issue
// * enable the 'sslverify' option (default) and add the Gandi
// SSL certificate to the Curl bundle: best choice for security
// See:

$apikey = 'my 24-character API key';

// Now you can call API method
// You must authenticate yourself by passing the API key
// as the first method's argument
$result = $version_api->info($apikey);

// Warning !
// PEAR::XML_RPC2 has known bugs on methods calls
// See
// You may use this call instead of the above one :
// $result = $version_api->__call("info", $apikey);

// dump the result


In PHP 5, use the XML_RPC2 package from pear.

XML_RPC2 works with ‘prefix’ in order to bind to namespace. The ‘prefix’ isn’t editable, so you have to instanciante a client by namespace.

> var xmlrpc = require('xmlrpc')
> var api = xmlrpc.createSecureClient({
...  host: '',
...  port: 443,
...  path: '/xmlrpc/'
... })
> var apikey = 'my 24-character API key'
> // Now you can call API methods.
> // You must authenticate yourself by passing the API key
> // as the first method's argument
> api.methodCall('', [apikey], function (error, value) {
...  console.dir(value)
... })


With NodeJS, use the npm xmlrpc package.

use XML::RPC;

my $api = XML::RPC->new('');

my $apikey = 'my 24-character API key';

# Now you can call API methods.
# You must authenticate yourself by passing the API key
# as the first method's argument
my $version = $api->call( '', $apikey );


With perl, use the cpan xml::rpc package.

require 'xmlrpc/client'

server = XMLRPC::Client.new2('')

apikey = 'my 24-character API key'

# Now you can call API methods.
# You must authenticate yourself by passing the API key
# as the first method's argument
version ="", apikey)


With ruby, use the xmlrpc/client module from the standard library. Ruby does not support gzip by default, the ZlibParserDecorator is used to enabled with Ruby >1.9.

For older ruby version, neither set the http_header_extra nor the parser.


To avoid RuntimeError with ruby >= 1.9, add:

XMLRPC::Config.module_eval {
    const_set(:ENABLE_NIL_PARSER, true)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <xmlrpc.h>
#include <xmlrpc_client.h>

#define CLIENT_NAME             "Documentation Client"
#define CLIENT_VERSION          "0.1"

#define SERVER_URL              ""

int     client_connect(xmlrpc_env *);
void    client_check_fault(xmlrpc_env *);

main(int argc, char **argv)
        xmlrpc_env      env;
        xmlrpc_value    *apikey, *rv;


        apikey = xmlrpc_build_value(&env, "(s)", "my 24-character API key");
        rv = xmlrpc_client_call_params(&env, SERVER_URL, "", apikey);



        return (0);

client_connect(xmlrpc_env *env)
        struct xmlrpc_clientparms clientp;
        struct xmlrpc_curl_xportparms curlp;

        curlp.network_interface = NULL;         /* use curl's default */
        curlp.ssl_verifypeer = 1;               /* Gandi API CA must be present */
        curlp.ssl_verifyhost = 2;
        curlp.user_agent = CLIENT_USERAGENT;    /* XML-RPC requirement */

        clientp.transport = "curl";
        clientp.transportparmsP = &curlp;
        clientp.transportparm_size = XMLRPC_CXPSIZE(user_agent);

        xmlrpc_client_init2(env, XMLRPC_CLIENT_NO_FLAGS, CLIENT_NAME,
            CLIENT_VERSION, &clientp, XMLRPC_CPSIZE(transportparm_size));

        return (1);

client_check_fault(xmlrpc_env *env)
        if (env->fault_occurred) {
                fprintf(stderr, "XML-RPC Fault: %s (%d)\n", env->fault_string,


With C, use the xmlrpc-c library.

Site Management

Working with domains not registered at Gandi

If you are not using the Gandi DNS or you did not register your domain at Gandi, you can also run a Site instance hosted at Gandi. Gandi must verify that the domain is your own by checking you have administration privilege on it. To perform that, Gandi will check DNS record on the vhost you want to bind to a site.

>>> site_spec = {
    'name': 'My Site',
    'package': 'professional',
    'vhosts': ['', ''],
    '--dry-run': True}
>>> ops =, site_spec)
[{'attr': ['', 'vhost=2e5d8f0899053fffcd3ecf4ac5a6433b'],
  'field': 'vhosts',
  'field_type': None,
  'reason': 'You must put a TXT value in your zone'}]

The DNS zone must be altered in this fashion to store the new record:

10800 IN TXT "vhost=2e5d8f0899053fffcd3ecf4ac5a6433b"

List all your sites

To obtain a list of the sites you own, just call the site.list() method:

>>> api = xmlrpc.client.ServerProxy('')

Count your sites

To count the sites you own, just call the site.count() method:


Get info on a site

Retrieve info on your first instance with method method:

>>>, 1)

Create a site

To create a site, use the site.create() method.

The method accepts a dictionnary of values describing the new site, such as
  • website name
  • provider used
  • a list of virtual hosts
  • the website duration
>>> site_spec = {
    'name': 'My Site',
    'provider': 'basekit_whitelabel',
    'vhosts': [''],
    'duration': '3m'}
>>> op =, site_spec)
>>> op['type']

After issuing the site creation order to the Gandi Site API, an Operation will be created on the server-side. You will have to wait for the Operation to finish before you can edit your website.

>>> import time
>>> while op['step'] not in('DONE', 'ERROR'):
        op =, op['id'])
>>> op['step']
>>> site_id =, {'name': 'My Site'})[0]['id']

Edit the web site

Once site.create() has succeeded and the site is created, you may retrieve an edition url via the method

It will redirect you to a UI you may use to edit your site.

>>>, site_id)['edit_url']

Manage Virtual Hosts

During a website creation it is mandatory to provide it with a list of virtual host URLs.

Every Provider comes with a parking domain where you can declare a subdomain to host your website. There are a few restrictions about the name, but the main one is: the subdomain is unique. first-in, first-served.

You can bind your site on any number of virtual host URLs using the vhosts key in this API (see SiteCreate, SiteUpdate or SiteReturn). You can host your web site on gandi domains without having to alter DNS entries and with any domain names (see site-api-dns-check).

Furthermore, the vhosts orders is important to set or retrieve the preferred vhost. The preferred vhost is used for SEO and is also retrieved in the SiteListReturn.

How to add the virtualhost “” to the previous site:

# add the virtual host to the domain
>>> vhosts = ['', '']
>>> op =, site_id, {'vhosts': vhosts})
>>> ops[0]['type']


It is required to keep the site attached to the Provider domain in order to edit the site.

Upgrade to another offer

Sites can be upgraded from one offer/package to another but they can not be downgraded from one offer to another, this is a limitation to keep in mind.

You can access the offers using the methods catalog.list() or site.package.list():

>>> # Check the current site offers prices
>>> api.catalog.list(key, {'product': {'type': 'site'}})
>>> # Retrieve list of offers from basekit_whitelabel
>>>, {'provider': 'basekit_whitelabel'})

To obtain the next offer in a package you can also use the ‘>name’ filter

>>> package =, {'provider': 'basekit_whitelabel', '>name': 'personal'})[0]
>>> package
{'name': 'professional', 'provider': 'basekit_whitelabel'}

You can also get a quote for this operation.

>>> descr = "{provider}_{name}".format(**package)
>>> api.catalog.list(key, {"product": {"type": "site", "description": descr}, "action": {"name": "update"}})

See the Gandi Catalog API for more usage.

Use of the site.update() is free for every except when upgrading from a package to another.

Delete a site

To delete an instance, use the site.delete() method:

>>> op =, site_id)
>>> op['type']