npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

kingsign-api-client

v1.1.3

Published

Official JavaScript/TypeScript client for the Kingsign API

Readme

Kingsign API Client

Official JavaScript/TypeScript client for the Kingsign API. This package provides a simple and intuitive way to interact with the Kingsign document signing platform.

Installation

npm install kingsign-api-client

Quick Start

import { KingsignClient } from 'kingsign-api-client';

// Create a client instance
const client = new KingsignClient({
  apiKey: 'your-api-key-here',
  apiUrl: 'https://api.kingsign.com' // optional, defaults to production
});

// Use the client to interact with the API
try {
  const templates = await client.getTemplates();
  console.log('Templates:', templates);
} catch (error) {
  console.error('API Error:', error);
}

Configuration

The KingsignClient constructor accepts a configuration object with the following options:

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | apiKey | string | ✅ | - | Your Kingsign API key (automatically determines workspace) | | apiUrl | string | ❌ | 'https://api.kingsign.com' | Base URL for the API | | timeout | number | ❌ | 30000 | Request timeout in milliseconds | | headers | Record<string, string> | ❌ | {} | Additional headers to include |

API Methods

Document Management

Create Document

Creates a new document from a template with field assignments.

const document = await client.createDocument({
  template_id: 'template-123',
  title: 'Employment Contract',
  description: 'Please review and sign',
  fields: [
    {
      field_id: 'field-456',
      contact: {
        name: 'John Doe',
        email: '[email protected]',
        phone: '+1234567890'
      }
    }
  ]
});

Get Document

Retrieves a specific document by ID.

const document = await client.getDocument('document-123');

Get Documents

Retrieves all documents in the workspace.

const documents = await client.getDocuments();
// With optional query parameters
const pendingDocuments = await client.getDocuments({ status: 'pending' });

Template Management

Get Template

Retrieves a specific template by ID.

const template = await client.getTemplate('template-123');

Get Templates

Retrieves all templates in the workspace.

const templates = await client.getTemplates();
// With optional query parameters
const activeTemplates = await client.getTemplates({ archived: false });

Contact Management

Create Contact

Creates a new contact in the workspace.

const contact = await client.createContact({
  name: 'John Doe',
  email: '[email protected]',
  phone: '+1234567890'
});

Get Contact

Retrieves a specific contact by ID.

const contact = await client.getContact('contact-123');

Get Contacts

Retrieves all contacts in the workspace.

const contacts = await client.getContacts();
// With optional query parameters
const contactsByEmail = await client.getContacts({ email: '[email protected]' });

Complete Example

import { KingsignClient, CreateDocumentData } from 'kingsign-api-client';

const client = new KingsignClient({
  apiKey: 'your-api-key-here'
});

async function workflow() {
  try {
    // 1. Get available templates
    const templates = await client.getTemplates();
    console.log('Available templates:', templates);

    // 2. Create a contact
    const contact = await client.createContact({
      name: 'Jane Smith',
      email: '[email protected]',
      phone: '+1234567890'
    });
    console.log('Created contact:', contact);

    // 3. Create a document from a template
    if (templates.length > 0) {
      const createDocumentData: CreateDocumentData = {
        template_id: templates[0]._id,
        title: 'Employment Agreement',
        description: 'Please review and sign this employment agreement',
        fields: [
          {
            field_id: 'signature-field-1',
            contact: {
              name: 'Jane Smith',
              email: '[email protected]'
            }
          }
        ]
      };

      const document = await client.createDocument(createDocumentData);
      console.log('Created document:', document);
    }

    // 4. Get all documents
    const documents = await client.getDocuments();
    console.log('All documents:', documents);

  } catch (error) {
    console.error('Error:', error);
  }
}

workflow();

Error Handling

The client automatically transforms API errors into a consistent format:

try {
  const document = await client.getDocument('non-existent-id');
} catch (error) {
  if (error.name === 'ApiError') {
    console.error(`API Error ${error.code}: ${error.message}`);
    console.error('Details:', error.data);
  } else {
    console.error('Network or other error:', error);
  }
}

Types

The package includes comprehensive TypeScript definitions for all interfaces:

import { 
  // Client configuration
  KingsignClientConfig,
  
  // API responses
  ApiResponse, 
  ApiError,
  
  // Document types
  Document, 
  DocumentWithFields,
  CreateDocumentData,
  CreateDocumentResponse,
  DocumentStatus,
  
  // Template types
  Template,
  TemplateWithFields,
  
  // Contact types
  Contact,
  CreateContactData,
  
  // API actions
  ApiAction
} from 'kingsign-api-client';

Advanced Usage

Accessing the Axios Instance

For advanced use cases, you can access the underlying Axios instance:

const axiosInstance = client.getAxiosInstance();
// Use axiosInstance for custom requests

Getting Configuration

You can retrieve the current client configuration:

const config = client.getConfig();
console.log('API URL:', config.apiUrl);
console.log('Timeout:', config.timeout);

Development

To build the package locally:

npm install
npm run build

License

MIT License - see LICENSE file for details.

Support

For support and questions, please contact the Kingsign team or create an issue in the repository.