Spot Collections

There are some use cases that call for strong consistency across all regions. For example, a financial application might need to show users' account balances. When users make a deposit, they want to see the result of this deposit reflected immediately when they view their balance (otherwise they may fear their money has been lost!). There should never appear to be more or less money in aggregate in the bank than there really is.

When performing read operations, here you want to read the latest copy of your data in global order. It provides the ability to read the latest change to your data across rows, regions and continents.


Let's assume your

  • Tenant name is and
  • User password is guest.

Driver download

pyC8 requires Python 3.5+. Python 3.6 or higher is recommended

To install pyC8, simply run

    $ pip3 install pyC8

or, if you prefer to use conda:

    conda install -c conda-forge pyC8

or pipenv:

    pipenv install --pre pyC8

Once the installation process is finished, you can begin developing applications in Python.

With Yarn or NPM

    yarn add jsc8
    npm install jsc8

If you want to use the driver outside of the current directory, you can also install it globally using the `--global` flag:

    npm install --global jsc8

From source,

    git clone
    cd jsC8
    npm install
    npm run dist

Code Sample

from c8 import C8Client
import pprint

if __name__ == '__main__':

  # Variables - URLs
  global_url = ""
  region_urls = [

  # Variables - DB
  email = ""
  password = "guest"
  geo_fabric = "_system"
  collection_name = "accounts"
  read_query = "FOR account IN accounts RETURN account"

  # Variables - Data
  data = [
    {"firstname": "Peter", "lastname": "Parker", "City": "NewYork"},
    {"firstname": "Bruce", "lastname": "Wayne", "City": "Gotham"},
    {"firstname": "Clark", "lastname": "Kent", "City": "Manhatten"},
    {"firstname": "Ned", "lastname": "Stark", "City": "Winterfell"},
    {"firstname": "Tywin", "lastname": "Lannister", "City": "Kings Landing"},
  pp = pprint.PrettyPrinter(indent=4)

  # Step1: Open connection to GDN. You will be routed to closest region.
  print("1. CONNECT: federation: {},  user: {}".format(global_url, email))
  client = C8Client(protocol='https', host=global_url, port=443)
  tenant = client.tenant(email, password)
  fabric = tenant.useFabric(geo_fabric)

  # Step2: Create a collection if not exists
  print("2. CREATE_COLLECTION: region: {},  collection: {}".format(global_url, collection_name))
  if fabric.has_collection(collection_name):
      collection = fabric.collection(collection_name)
      collection = fabric.create_collection(collection_name, spot_collection=True)

  # Step3: Insert data into collection.
  print("3. INSERT_DATA: region: {}, collection: {}".format(global_url, collection_name))

  # Step4: Read Data
  print("4. READ_DATA: region: {}, collection: {}".format(global_url, collection_name))
  cursor = fabric.c8ql.execute(read_query)
  docs = [document for document in cursor]

  # Step5: Read Data from other regions.
  for region_url in region_urls:
    print("\n DATA_MOBILITY: Reading from region: {}".format(region_url))
    clientx = C8Client(protocol='https', host=region_url, port=443)
    tenantx = clientx.tenant(email, password)
    fabricx = tenantx.useFabric(geo_fabric)
    cursorx = fabricx.c8ql.execute(read_query)
    docs = [document for document in cursorx]

  # Step5: Delete Data
  print("5. DELETE_DATA: region: {}, collection: {}".format(global_url, collection_name))
'use strict'

const jsc8 = require('jsc8')

// Variables - DB
const global_url = ""
const region_urls = [
const client = new jsc8(global_url)
const guest_password = "guest"
const geo_fabric = "_system"
const guest_email = ""
const collection_name = "accounts"

const read_query = "FOR account IN accounts RETURN account"

let collection_address = null

// Variables - Data
const data = [
  {"firstname": "Peter", "lastname": "Parker", "City": "NewYork"},
  {"firstname": "Bruce", "lastname": "Wayne", "City": "Gotham"},
  {"firstname": "Clark", "lastname": "Kent", "City": "Manhatten"},
  {"firstname": "Ned", "lastname": "Stark", "City": "Winterfell"},
  {"firstname": "Tywin", "lastname": "Lannister", "City": "Kings Landing"},

async function login(){
  console.log(`\n 1. CONNECT: federation: ${global_url}`);
  await client.login(guest_email, guest_password);
  await client.useFabric(geo_fabric);

async function createCollection() {
  console.log("\n 2. CREATE_COLLECTION")

     console.log("Creating the collection accounts...");
      collection_address = client.collection(collection_name)
      let exists_coll = await collection_address.exists()
      if (exists_coll === false) {
            await collection_address.create({isSpot: true})


    catch (e) {
    await console.log("Collection creation did not succeed due to " + e)

async function insertData() {

  console.log(`\n 3. INSERT_DATA in region ${global_url}`)


async function readData(){
  console.log(`\n 4. READ_DATA in region ${global_url}`)
  let cursor = await client.query(read_query);
  let result = await cursor.all()

async function readDataFromAllRegions(){
   for (let i = 0; i < region_urls.length; i++) { 
      let regionclient = new jsc8(region_urls[i])
      console.log(`\n 5. READ_DATA: Reading from region : ${region_urls[i]}`);
      await regionclient.login(guest_email, guest_password);
      await regionclient.useFabric(geo_fabric);
      let cursor = await client.query(read_query);
      let result = await cursor.all()

async function deleteData(){
  console.log("\n 6. DELETE_DATA")
  await collection_address.truncate()

(async function(){
  await login();
  await createCollection();
  await insertData();
  await readData();
  await readDataFromAllRegions();
  await deleteData();