title: How do I programmatically import data into Gnome Contacts?
body: <p>I would like to import my contacts into <a href="https://wiki.gnome.org/Apps/Contacts" rel="nofollow noreferrer">Gnome Contacts</a> via Python or command-line. I am willing to do some programming, but I am unable to find the necessary documentation.</p>
  
  <p>Gnome Contacts uses the <a href="https://wiki.gnome.org/Projects/Folks" rel="nofollow noreferrer">libfolks</a> library, which includes a <code>folks-import</code> utility, but there is no man page and the output of <code>folks-import --help</code> is not very helpful:</p>
  
  <pre><code>Usage:
    folks-import [OPTION…] — import meta-contact information to libfolks
  
  Help Options:
    -h, --help            Show help options
  
  Application Options:
    -s, --source=name     Source backend name (default: ‘pidgin’)
    --source-filename     Source filename (default: specific to source backend)
  
  </code></pre>
  
  <p>Contacts are stored locally in <code>~/.local/share/evolution/addressbook/system/contacts.db</code> which is a SQLite3 database, so I could write directly to this file. However I would prefer not to without good documentation, particularly as the database appears to embed binary and <a href="https://en.wikipedia.org/wiki/VCard" rel="nofollow noreferrer">vCard</a> data.</p>
  
  <p>On Ubuntu 18.04, you can install Gnome Contacts and libfolks tools via:</p>
  
  <pre><code>sudo apt install gnome-contacts folks-tools
  </code></pre>
  
  <p>You can inspect the local contact database via:</p>
  
  <pre><code>sqlite3 ~/.local/share/evolution/addressbook/system/contacts.db .dump
  </code></pre>
  
  <p>Related answers that did not solve my problem:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/44534544">How can I access gnome-contacts or its data from gjs</a></li>
  <li><a href="https://stackoverflow.com/questions/18222884">How to get Empathy contact list in GNOME shell extensions?</a></li>
  <li><a href="https://stackoverflow.com/questions/10151433">Getting list of contacts with Gnome-Shell JS interface</a></li>
  <li><a href="https://stackoverflow.com/a/28724233">python GTK3 limit label width</a></li>
  <li><a href="https://askubuntu.com/questions/947641">Where does system-address-book pull data from?</a></li>
  </ul>