Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently developing an app, in C++, that will sync it's data with Ubuntu One, but I can't find any documentation online that explains how to do this. I found Ryan Paul's Ars Technica article that provides an excellent introduction to doing this in Python while mentioning that there exists a library that will facilitate this in C, but it doesn't provide an hint as to where this C-based solution can be found. I've Googled around for a bit, but no-one seems to be talking about developing apps that take advantage of Ubuntu One sync.

Does anyone know where I can information on this C-based interface?

share|improve this question
up vote 9 down vote accepted

Ubuntu One provides data synchronisation through desktopcouch, which is a local version of CouchDB which is automatically synced with Ubuntu One and all your machines. Some documentation for the cloud and Python APIs is available at, which may be useful if you want to build web apps or mobile apps which work with the same data as your Ubuntu C++ app.

The C/C++ API isn't yet on the developer site (it will be soon!), so here's a summary which should be enough to get started.

For C/C++, you have couchdb-glib and desktopcouch-glib. couchdb-glib provides the generic CouchDB API, and desktopcouch-glib just provides one object, which creates a Session object with all that is needed for connecting to Ubuntu One's desktopcouch.


DesktopcouchSession *dc = desktopcouch_session_new ();

DesktopcouchSession is a subclass of CouchdbSession, so once you get one instance of it, you can use the methods in CouchdbSession to access the underlying CouchDB instance:

GSList              *couchdb_session_list_databases (CouchdbSession *session, 
                                                     GError **error);
CouchdbDatabase     *couchdb_session_get_database (CouchdbSession *session, 
                                                   const char *dbname, 
                                                   GError **error);
gboolean             couchdb_session_create_database (CouchdbSession *session, 
                                                      const char *dbname, 
                                                      GError **error);
gboolean             couchdb_session_delete_database (CouchdbSession *session, 
                                                      const char *dbname, 
                                                      GError **error);

With those methods you manage databases, and with get_database and create_database you get an instance of a CouchdbDatabase object, which allows you to manage the documents in the databases:

GSList       *couchdb_database_get_all_documents (CouchdbDatabase *database, 
                                                  GError **error);
gboolean      couchdb_database_put_document (CouchdbDatabase *database,
                                             CouchdbDocument *document,
                                             GError **error);
gboolean      couchdb_database_delete_document (CouchdbDatabase *database, 
                                                CouchdbDocument *document, 
                                                GError **error);

As you can see, for managing the documents themselves, there's another object, CouchdbDocument. Also, there are subclasses of this one for managing specific types of documents, like CouchdbDocumentContact (for contacts).

You can get the complete API reference by installing the #libcouchdb-glib-doc Install libcouchdb-glib-doc package. Installing #libdesktopcouch-glib-dev Install libdesktopcouch-glib-dev should pull in all the libraries you need.

The API gives you access to CouchDB, so of course you'll need to know how CouchDB itself works, and how you store data in it. The short answer is: data is stored in JSON documents, and extracted by document ID or with pre-computed views. is the CouchDB book which explains Couch's method of data storage in more detail.

If you have questions, do please ping me (aquarius) or rodrigo on #ubuntuone on freenode. I'd be more than happy to talk with you about what you're planning to do and good ways to model that data in the Ubuntu One data storage system.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.