Getting started

Create your first Context Document


The Context SDK provides a powerful and flexible way to interact with Context, enabling developers to manage domains and documents programmatically. With this SDK, you can create, modify, and manage domains and their associated documents using Context's API.


To start using the Context SDK in your TypeScript project, install it via npm:

npm install @contextprotocol/sdk

Quick Start

This section walks you through setting up a basic connection and performing common operations with the Context SDK.

Setting Up Your Connection

First, import the SDK and create an instance of the Context:

import { Context } from '@contextprotocol/sdk';

const ctx = new Context();

Initialising the SDK

Firstly, please register at and create an API key. Once you have obtained your API key, you will be able to initialize the SDK using this key.

aawait ctx.init({ apiKey });


To get information about a domain:

const domain = await ctx.domain("domain_name");

To get information about a domain:

const yourDomain = await ctx.domain();


Retrieve all documents within a domain or a specific document:

const document = await domain.document("document_path"); // Get a specific document
const documentInVersionXYZ = await domain.document("document_path?v=X.Y.Z"); // Get a specific version of a document

Retriving the document data:

const documentData = await;

Retrieving a document version list:

const documentVersions = await document.versions();

Get a specific version of a document:

const documentVersion = await document.version("X.Y.Z");

Creating a document in a domain

Steps to create a new document under a domain:

  1. Create a data object.

const data: any = YOUR_AWESOME_JSON_DATA;
const templates: string[] = ["{domain_name}/template_path"]; // Optional
  1. Create a new document under the domain:

const newDocument = await domain.createDocument("document_path", data, templates);

Adding a template to a document

Adding a template to a document:

await domain.addTemplate("template_path");

Creating a template

Context uses JSON schemas to validate the documents. You can generate your schema using a Typescript interface as follows:

const myDataType = `interface User{
    name: string;
    age: number;
const schema = generateJsonSchema(dataName, myDataType);
const template = await domain.createTemplate("template_path", schema);

Public Methods


Retrieving all Domain Information

const allDomainsInfo = await;
const allDomainsInfo = await{offset: 1, limit: 10});


Retrieving all documents from public API

const allDocuments = await ctx.public.documents();
const allDocuments = await ctx.public.documents({offset: 1, limit: 10, name: "document_name", domain: "domain_name"});

Create your first Domain

We are scheduled to launch on Mainnet in the coming weeks. If you are interested in becoming one of our early users, we encourage you to create your initial domain on Testnet using our application.

For inquiries about creating a premium and verified domain, please contact us at

Last updated