@kintone/rest-api-client
TypeScript icon, indicating that this package has built-in type declarations

5.6.0 • Public • Published

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:

Regarding restrictions and availability, please check 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
Edge
Firefox
Firefox
Chrome
Chrome
Safari
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 Conditionally
Required
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 Conditionally
Required
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.

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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.6.04,181latest

Version History

VersionDownloads (Last 7 Days)Published
5.6.04,181
5.5.2257
5.5.145
5.5.0217
5.4.01
5.3.05
5.2.09
5.1.028
5.0.8105
5.0.712
5.0.615
5.0.528
5.0.429
5.0.31
5.0.20
5.0.1228
5.0.018
4.1.1100
4.1.095
4.0.32
4.0.23
4.0.11
4.0.011
3.3.15120
3.3.140
3.3.132
3.3.120
3.3.110
3.3.100
3.3.927
3.3.80
3.3.70
3.3.614
3.3.529
3.3.40
3.3.30
3.3.21
3.3.18
3.3.00
3.2.344
3.2.22
3.2.14
3.2.01
3.1.160
3.1.151
3.1.140
3.1.124
3.1.117
3.1.1012
3.1.912
3.1.80
3.1.70
3.1.61
3.1.53
3.1.410
3.1.30
3.1.22
3.1.112
3.1.02
3.0.01
2.0.38129
2.0.371
2.0.364
2.0.355
2.0.341
2.0.334
2.0.322
2.0.311
2.0.301
2.0.291
2.0.281
2.0.271
2.0.261
2.0.250
2.0.240
2.0.230
2.0.220
2.0.210
2.0.201
2.0.190
2.0.180
2.0.170
2.0.161
2.0.153
2.0.142
2.0.130
2.0.120
2.0.1110
2.0.100
2.0.90
2.0.80
2.0.72
2.0.66
2.0.50
2.0.40
2.0.30
2.0.20
2.0.10
2.0.01
1.13.03
1.12.40
1.12.31
1.12.20
1.12.10
1.12.00
1.11.20
1.11.10
1.11.00
1.10.01
1.9.00
1.8.21
1.8.11
1.8.00
1.7.20
1.7.12
1.7.00
1.6.04
1.5.21
1.5.10
1.5.01
1.4.22
1.4.10
1.4.01
1.3.00
1.2.09
1.1.08
1.0.00
0.3.01
0.2.00
0.1.00
0.0.10

Package Sidebar

Install

npm i @kintone/rest-api-client

Weekly Downloads

5,924

Version

5.6.0

License

MIT

Unpacked Size

5.68 MB

Total Files

348

Last publish

Collaborators

  • tasshi