API and Dashboard
TypeScript SDK

TypeScript SDK

This guide provides information on how to integrate and use the Paradym (REST API) SDK to interact with the Paradym API (opens in a new tab) seamlessly. Designed to simplify API requests, this SDK enables developers to leverage Paradym's features, enabling you to focus on building your TypeScript applications.

Getting Started

First, you need to add the Paradym SDK dependency to your project. You can do this using your package manager of choice:

npm install @paradym/sdk
# or 
yarn add @paradym/sdk
# or
pnpm install @paradym/sdk

Usage

Initialize Client

Before you can start making API requests, you need to initialize the SDK client with your API key. You can find your API key in the Paradym Dashboard (opens in a new tab). It is recommend to configure your API Key as an environment variable, and provide it dynamically on startup of your application.

import { Paradym } from '@paradym/sdk';
 
const paradym = new Paradym({
    apiKey: "YOUR_API_KEY"
});

API Overview

The SDK is designed to provide an organized and intuitive interface for interacting with our API endpoints. The structure of the SDK categorizes these endpoints into specific services, ensuring that each endpoint is easily accessible through a clear and logical hierarchy.

Each API request from the Paradym API reference (opens in a new tab) is mapped to a corresponding service class within the SDK. This mapping ensures that users can easily translate API reference endpoints to SDK service classes.

Available Services
Templates
Credentials
SD-JWT VC Templates (opens in a new tab)
Anoncreds Templates (opens in a new tab)
Presentations (opens in a new tab)
OpenID4VC
Issuance (opens in a new tab)
Verification (opens in a new tab)
DIDComm
Issuance (opens in a new tab)
Verification (opens in a new tab)
Messaging (opens in a new tab)
Connections (opens in a new tab)
Invitations (opens in a new tab)
Revocation (opens in a new tab)
Issuance (opens in a new tab)
DIDs (opens in a new tab)
Projects (opens in a new tab)
Project Profile (opens in a new tab)
Webhooks (opens in a new tab)

Examples

Here are some examples demonstrating how to use the SDK for different functionalities.

Create a Credential Template

Credential templates define the structure and details of the credentials you will issue.

To create a SD-JWT Verifiable Credential template, use the following code. Make sure to change the <projectId> and provide your API key:

  import { Paradym } from '@paradym/sdk';
 
  const paradym = new Paradym({
      apiKey: "YOUR_API_KEY"
  });
 
  const template = await paradym.templates.credentials.sdJwtVc.createCredentialTemplate({
    projectId: '<projectId>',
    requestBody: { 
      name: "My SD-JWT VC template", 
      description: "This is a description", 
      issuer: "did:web", 
      background: { 
        color: "#FFFFFF", 
        url: "https://example.com/image.png" 
      }, 
      text: { 
        color: "#000000" 
      }, 
      validFrom: "2024-04-11", 
      validUntil: { 
        start: "validFrom", 
        future: { years: 5 } 
      }, 
      type: "UniversityCard", 
      revocable: false, 
      attributes: { 
        myAttribute: { 
          type: "string", 
          name: "My attribute", 
          description: "This is an attribute", 
          required: true, 
          alwaysDisclosed: false 
        } 
      } 
    }
  });

Create an Issuance Offer

Issuance offers are used to start the process of issuing credentials to users. Here is how you can create an issuance offer:

import { Paradym } from '@paradym/sdk';
 
const paradym = new Paradym({
    apiKey: "YOUR_API_KEY"
});
 
const openId4VcIssuance = await paradym.openId4Vc.issuance.createOffer({
  projectId: '<projectId>',
  requestBody: {
    credentials: [{
      credentialTemplateId: '<credentialTemplateId>',
      attributes: {
        name: "John Doe"
      },
    }]
  }
});

Create a SD-JWT Presentation Template

Presentation templates define how credentials should be presented. To create a presentation template for SD-JWT credentials, use the following code:

import { Paradym } from '@paradym/sdk';
 
const paradym = new Paradym({
    apiKey: "YOUR_API_KEY"
});
 
const sdJwtPresentationTemplate = await paradym.templates.presentations.createPresentationTemplate({
    projectId: '<projectId>',
    requestBody: {
        credentials: [
            {
                description: 'This is a description',
                name: 'My SD-JWT VC credential',
                format: 'sd-jwt-vc',
                type: 'https://metadata.paradym.id/types/28dc88-UniversityCard',
                attributes: {
                    myAttribute1: {
                        type: 'string',
                        value: 'myValue',
                    },
                    myAttribute2: {
                        type: 'number',
                        minimum: 1,
                        maximum: 10,
                    },
                    myAttribute3: {
                        type: 'boolean',
                        value: true,
                    },
                },
            },
        ],
        description: 'This is a description',
        name: 'My SD-JWT VC presentation',
    },
});

Create a SD-JWT Verification Request

Verification requests are used to verify the authenticity of presented credentials. Here is how to create a verification request:

import { Paradym } from '@paradym/sdk';
 
const paradym = new Paradym({
    apiKey: "YOUR_API_KEY"
});
 
const openId4VcVerification = await paradym.openId4Vc.verification.createRequest({
  projectId: '<projectId>',
  requestBody: {
    presentationTemplateId: '<presentationTemplateId>',
  }
});

Create DIDComm Connection Invitation

The Paradym SDK also supports DID communication, allowing for secure and decentralized interactions between entities. Here's an example of setting up DID communication:

import { Paradym } from '@paradym/sdk';
 
const paradym = new Paradym({
    apiKey: "YOUR_API_KEY"
});
 
const didcommInvitation = await paradym.didcomm.invitations.createConnectionInvitation({
  projectId: "<projectId>",
  requestBody: {
    reusable: false,
    goal: {
      description: "I would like to create a connection for chatting",
      code: "p2p-messaging"
    }
  }
})

Create DIDComm Issuance Offer

import { Paradym } from '@paradym/sdk';
 
const paradym = new Paradym({
    apiKey: "YOUR_API_KEY"
});
 
const didcommIssuanceOffer = await paradym.didcomm.issuance.createOffer({
  projectId: "<projectId>",
  requestBody: {
    didcommInvitation: {
      createConnection: true,
      did: "did:web"
    },
    goal: {
      code: "someCode",
      description: "someDescription"
    },
    credential: {
      credentialTemplateId: "<credentialTemplateId>",
      attributes: {
        name: "John",
        age: 25
      }
    }
  }
})

That's it! 🚀

If you have any suggestions, remarks or questions, join the Paradym Community (opens in a new tab) and let us know. Happy building!