MongoDB C Driver


    The MongoDB C Driver, also known as “libmongoc”, is the official client library for C applications, and provides a base for MongoDB drivers in higher-level languages.

    The library is compatible with all major platforms. It depends on libbson to create and parse BSON data.


    See Installing the MongoDB C Driver (libmongoc) and BSON library (libbson).

    Connect to MongoDB Atlas

    To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:

    #include <mongoc/mongoc.h>
    main (int argc, char *argv[])
       mongoc_database_t *database;
       mongoc_client_t *client;
       mongoc_init ();
       client = mongoc_client_new(
       database = mongoc_client_get_database (client, "test");
       mongoc_database_destroy (database);
       mongoc_client_destroy (client);
       mongoc_cleanup ();
       return 0;

    See Advanced Connections for more ways to connect.


    MongoDB Compatibility

    C Driver VersionMongoDB 4.4MongoDB 4.2MongoDB 4.0MongoDB 3.6MongoDB 3.4MongoDB 3.2MongoDB 3.0MongoDB 2.6
    Version 1.17
    Version 1.16
    Version 1.15
    Version 1.14
    Version 1.13
    Version 1.12
    Version 1.11
    Version 1.10
    Version 1.9
    Version 1.8
    Version 1.7
    Version 1.6
    Version 1.5
    Version 1.4
    Version 1.3
    Version 1.2
    Version 1.1
    Version 1.0

    The driver does not support older versions of MongoDB.

    Language Compatibility

    C Driver VersionsC11C99C89
    All Versions

    How to get help