Create a Key-Value Store
This page explains how to create a new Key-Value Store collection.
- Web Console
- Python SDK
- JavaScript SDK
Follow these instructions to create a new collection using the GDN console web UI.
- Click Data > Collections. 
- Click New Collection. 
- Click Key-Value Store. 
- Enter information about the collection and then click Create. - Collection Name - Required. A unique name to distinguish the collection. Spaces are not allowed.
- Collection stream - Enable streams for all locations for this collection.
- Strong consistency - Enable strong consistency on this collection. For more information, refer to Strong consistency.
- Group ID - Enable the Group ID field in key-value documents.
- Expiration - Enable expiration. This allows key-value documents to be removed at a certain date and time.
- Blob storage - (If enabled on your account.) Allows you to store blob files in the collection.
 
This code example shows how to create a collection for saving key-value pairs.
  from c8 import C8Client
  key = "<your-api-key>"
  collection_name = "students"
  # Create a connection to GDN
  client = C8Client(protocol='https', host='play.paas.macrometa.io', port=443,
  apikey=key)
  # Create a new collection if it does not exist
  if client.has_collection(collection_name):
      print("Collection exists")
  else:
      client.create_collection_kv(name=collection_name)
This code example shows how to create a collection for saving key-value pairs.
  // Add this snippet in main function
  let coll = await client.getKVCollections();
  console.log("Existing collections: ", coll.result);
  try{
      await client.createKVCollection(collectionName);
      console.log("Collection created successfully");
  }
  catch(e){
      console.log("Collection creation did not succeed due to " + e);
  }