MongoDB C Driver

A Cross Platform MongoDB Client Library for C

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.


Latest release:


Example: Count documents in a collection

#include <mongoc.h>
#include <bcon.h>
#include <stdio.h>

static void
print_query_count (mongoc_collection_t *collection, bson_t *query)
   bson_error_t error;
   int64_t count;

   count = mongoc_collection_count (
      collection, MONGOC_QUERY_NONE, query, 0, 0, NULL, &error);

   if (count < 0) {
      fprintf (stderr, "Count failed: %s\n", error.message);
   } else {
      printf ("%" PRId64 " documents counted.\n", count);

How To Ask For Help

For help using the driver: MongoDB Users Mailing List.

To file a bug or feature request: MongoDB Jira Issue Tracker.

Documentation for Older Versions

libmongoc releases

libbson releases