
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@kintone/rest-api-client
Advanced tools
KintoneRestAPIClient
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";
This library also provides two Universal Module Definition (UMD) files:
After loading this, you can use KintoneRestAPIClient
directly.
In Kintone customization, please add this URL in "JavaScript and CSS Customization" setting of your app.
NOTE: The UMD links are using the latest
tag to point to the latest version of the library. This pointer is unstable, it shifts as we release new versions. You should consider pointing to a specific version, such as 1.0.0
.
Here is a sample code that retrieves records of an app.
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 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);
});
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. |
auth | Object | Conditionally Required | The object for authentication. See Authentication. |
guestSpaceId | Number or String | The guest space ID. If you are dealing with apps that are in guest spaces, 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. |
The client supports three authentication methods:
The required parameters inside auth
are different by the methods.
The client determines which method to use by passed parameters.
Name | Type | Required | Description |
---|---|---|---|
username | String | Yes | |
password | String | Yes |
Name | Type | Required | Description |
---|---|---|---|
apiToken | String or String[] | Yes | You can pass multiple api tokens as an array of string. |
Supported in browser environment only.
If you omit auth
parameter, the client uses Session authentication.
When the API request responds with a status code other than 200, the client raises KintoneRestAPIError
.
KintoneRestAPIError
has the following properties:
Name | Type | Description |
---|---|---|
id | String | The ID of the error. |
code | String | The code of the error, to specify the type of error it is. |
status | Number | The HTTP status of the response. |
headers | Object | The HTTP headers of the response. |
message | String | The error message. |
bulkRequestIndex | Number or undefined | The index of the failed request when executing bulkRequest and one of the requests fails. This value is undefined otherwise. |
FAQs
Kintone REST API client for JavaScript
The npm package @kintone/rest-api-client receives a total of 11,356 weekly downloads. As such, @kintone/rest-api-client popularity was classified as popular.
We found that @kintone/rest-api-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.