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 🙏

© 2026 – Pkg Stats / Ryan Hefner

kobo-sdk

v2.5.0

Published

A TypeScript SDK for seamlessly interacting with the [KoboToolbox](https://www.kobotoolbox.org/) API, abstracting its complexities. **Optimized for TypeScript, with full type definitions.**

Readme

Kobo-SDK npm

A TypeScript SDK for seamlessly interacting with the KoboToolbox API, abstracting its complexities. Optimized for TypeScript, with full type definitions.

Table of Contents

Installation

npm install kobo-sdk

Usage

Initialization

import {KoboClient} from 'kobo-sdk'

const sdk = new KoboClient({
  urlv1: 'https://kc.kobotoolbox.org',
  urlv2: 'https://kf.kobotoolbox.org',
  token: '<YOUR PRIVATE TOKEN>',
})

Constructor Parameters

| Parameter | Required | Description | |------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| | urlv1 | ✅ | Alias kc_url. KoboToolbox provides two API versions; this one is specifically used for submitting data to a form, as there is no equivalent endpoint in v2. | | urlv2 | ✅ | Alias kf_url. | | token | ✅ | Private API token, available in your KoboToolbox account settings. | | ApiClientClass | ❌ | Uses Axios by default. This parameter allows for a custom HTTP client. | | log | ❌ | Logs output to the console by default. |

Kobo Servers Index

| Server | V1 (kc) | V2 (kf) | |--------|-------------------------------|----------------------------| | EU | https://kc-eu.kobotoolbox.org | https://eu.kobotoolbox.org | | Global | https://kc.kobotoolbox.org | https://kf.kobotoolbox.org | | DRC | https://kc-kobo.drc.ngo | https://kobo.drc.ngo/ |

Insert New Submission

Only the question name (without the begin_group path) is used as a key when submitting data.
The Kobo API expects grouped questions in a nested structure, but this function automatically handles the formatting.
If submission fails, it retries up to 5 times by default, which can be adjusted using the retries parameter.

await sdk.v1.submission.submitXml({
  formId: 'aM29e4jscqujByADmvDLrr',
  attachments: [{
    name: 'filename as indicated in the answers',
    url: 'URL to the file. Altenarively you can use `path` instead of `url` to select a local file.',
  }],
  data: {
    question_text: 'answer',
    question_integer_variant1: 1,
    question_integer_variant2: '1',
    question_select_multiple: 'option1 option2',
    question_select_one: 'option1',
    question_begin_repeat: [
      {question: 'answer1'},
      {
        question: 'answer2',
        question_nested_repeat: [{question_nested: 'answer'}],
      },
    ],
  },
})

Update Submissions

Only the question name (without the begin_group path) is used as a key when submitting data. The Kobo API expects $xpath as a key, including begin_groups but this function automatically handles the formatting.

If submission fails, it retries up to 5 times by default, which can be adjusted using the retries parameter.

[!NOTE] The Kobo API fails if it receives too many updates in a short time, but this function automatically splits requests into smaller chunks and queues calls, ensuring updates are throttled at a pace the Kobo API can handle.

await sdk.v2.submission.update({
  formId: 'aM29e4jscqujByADmvDLrr',
  submissionIds: ['1', '2'],
  data: {
    question_text: 'New answer',
    question_select_multiple: 'option1 option2 option3',
  },
})

Fetch Submissions

Supports filtering _submission_time by range, limit, and offset.
The Kobo API limits responses to 30,000 submissions per request to prevent timeouts, but this function automatically splits API calls into chunks and merges results, allowing retrieval of any number of submissions seamlessly.

sdk.v2.submission.get({
  formId: 'aM29e4jscqujByADmvDLrr',
  filters: {
    start: new Date(2024, 0, 1),
    end: new Date(2024, 0, 1),
    offset: 10,
    limit: 5e4,
  }
})

[!IMPORTANT] The function removes paths from keys and extracts answers from metadata. To retrieve the raw API response, use sdk.v2.submission.getRaw instead.

Get form permissions

const form = await sdk.v2.form.get('aM29e4jscqujByADmvDLrr')
const permissions = sdk.v2.form.getPermissionSummary(form)
// > [{userName: 'user1', permissions: ['add_submissions delete_submissions manage_asset validate_submissions view_asset view_submissions']}]

Under-the-Hood Features Summary

Submission

  • Implements the /v1/submission.xml endpoint, as JSON submissions cause bugs.
  • Automatically retrieves formhub/uuid.
  • Generates instanceID.
  • Formats the request body to match Kobo's complex nested structure.
  • Supports automatic retries.

Update

  • Controls update pacing to prevent server rejection.
  • Formats the request body using $xpath as keys.

Fetching

  • Manages data reconciliation when fetching over 30,000 submissions.
  • Provides a simple API for start and end query parameters.

TypeScript Support

We highly recommend using this SDK with TypeScript instead of JavaScript for full type support and to save yourself from unnecessary frustration. If you're not a developer or unfamiliar with TypeScript, don’t worry, the type system will guide you along the way.

autocomplete-parameters.png autocomplete-response.png

Contributing

Contributions are welcome! Feel free to submit a PR or open an issue.