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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kintone/rest-api-client

v5.5.1

Published

Kintone REST API client for JavaScript

Downloads

22,715

Readme

kintone-rest-api-client

npm version Node.js version License

API client for Kintone REST API. It supports both browser environment (Kintone customization & plugin) and Node.js environment.

Installation

1. Install with npm

This library is distributed on npm.

npm install @kintone/rest-api-client

You can then use require or import to import the library.

// CommonJS
const { KintoneRestAPIClient } = require("@kintone/rest-api-client");
// ES modules
import { KintoneRestAPIClient } from "@kintone/rest-api-client";

2. Load UMD files from CDN (for browser environment)

[!IMPORTANT] To avoid cascading failures from the CDN, we recommend using the npm package and bundling it to your plugin/customization.

You can also load Universal Module Definition (UMD) files directly from Cybozu CDN:

  • https://cybozu.dev/ja/kintone/sdk/library/cybozu-cdn/#kintone-rest-api-client

Regarding restrictions and availability, please check Cybozu CDN Policy:

  • https://cybozu.dev/ja/policy/cybozu-cdn-policy/

After loading the UMD file, you can use KintoneRestAPIClient in your environment. In Kintone customization, please add the UMD file URL in the "JavaScript and CSS Customization" setting of your app.

Browsers support

| Edge | Firefox | Chrome | Safari | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Latest version | Latest version | Latest version | Latest version |

Usage

Here is a sample code that retrieves app records.

const client = new KintoneRestAPIClient({
  baseUrl: "https://example.cybozu.com",
  // Use password authentication
  auth: {
    username: process.env.KINTONE_USERNAME,
    password: process.env.KINTONE_PASSWORD,
  },
  // Use API token authentication
  // auth: { apiToken: process.env.KINTONE_API_TOKEN }
  // Use OAuth token authentication
  // auth: { oAuthToken: process.env.KINTONE_OAUTH_TOKEN }

  // Use session authentication if `auth` is omitted (in browser only)
});

client.record
  .getRecords({ app: "1" })
  .then((resp) => {
    console.log(resp.records);
  })
  .catch((err) => {
    console.log(err);
  });

Global

| Name | Type | Description | | ------- | :----: | :------------------------------------------------: | | version | String | Provides the used version of KintoneRestAPIClient. |

Parameters for KintoneRestAPIClient

| Name | Type | Required | Description | | -------------------------- | :--------------------------------------------------------------: | :-------------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | baseUrl | String | ConditionallyRequired | The base URL for your Kintone environment.It must start with https. (e.g. https://example.kintone.com) Required in Node.js environment. If you omit it in browser environment, location.origin will be used.The protocol of baseUrl must be https except when hostname is localhost. | | auth | Object | ConditionallyRequired | The object for authentication. See Authentication. | | guestSpaceId | Number or String | | The guest space ID. If you are dealing with guest space or apps in guest space, please specify this. | | basicAuth | Object | | If your Kintone environment uses Basic authentication, please specify its username and password. | | basicAuth.username | String | | The username of Basic authentication. | | basicAuth.password | String | | The password of Basic authentication. | | httpsAgent | Object | | This parameter is available only in Node.js environment.The custom HTTPS agent to be used when request.The agent should be compatible with https.Agent. | | clientCertAuth | Object | | This parameter is available only in Node.js environment.When httpsAgent parameter is given, this parameter is unavailable.If your Kintone environment uses Client Certificate authentication, please specify the certificate file and password. | | clientCertAuth.pfx | Buffer | | The client certificate file. Required, unless you specify pfxFilePath. | | clientCertAuth.pfxFilePath | String | | The path to client certificate file. Required, unless you specify pfx. | | clientCertAuth.password | String | | The password of client certificate. | | proxy | Object or false | | This parameter is available only in Node.js environment.If you use a proxy, please specify its configuration.To disable proxy and ignore proxy environment variables, please specify false. | | proxy.protocol | String | | The protocol of the proxy server. Default is http. | | proxy.host | String | | The host of the proxy server. | | proxy.port | Number | | The port of the proxy server. | | proxy.auth | Object | | If the proxy server requires Basic authentication, please specify its username and password. | | proxy.auth.username | String | | The username of Basic authentication for the proxy server. | | proxy.auth.password | String | | The password of Basic authentication for the proxy server. | | userAgent | String | | This parameter is available only in Node.js environment.A User-Agent HTTP header | | featureFlags | Object | | Feature flags that you can configure. See Feature flags. | | socketTimeout | Number | | This parameter is available only in Node.js environment.The socket timeout in milliseconds. |

Authentication

The client supports three authentication methods:

  1. Password authentication
  2. API token authentication
  3. OAuth authentication
  4. Session authentication

The required parameters inside auth are different by the methods. The client determines which method to use by passed parameters.

1. Parameters for Password authentication

| Name | Type | Required | Description | | -------- | :----: | :------: | ----------- | | username | String | Yes | | password | String | Yes |

2. Parameters for API token authentication

| Name | Type | Required | Description | | -------- | :----------------: | :------: | ------------------------------------------------------- | | apiToken | String or String[] | Yes | You can pass multiple api tokens as an array of string. |

3. Parameters for OAuth authentication

| Name | Type | Required | Description | | ---------- | :----: | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | oAuthToken | String | Yes | An OAuth access token you get through the OAuth process flow. |

4. Session authentication

Supported in browser environment only. If you omit auth parameter, the client uses Session authentication.

Session authentication is available in Garoon customization.

Feature flags

| Name | Type | Default | Description | | ---------------------- | :-----: | :-----: | --------------------------------------------------------------- | | enableAbortSearchError | boolean | false | An option of whether to throw KintoneAbortSearchError or not. |

Error Handling

See Error Handling

TypeScript

See TypeScript Definitions

References

Contribution Guide

License