@kintone/rest
v0.0.1
Published
kintone REST API Client for JavaScript
Downloads
8
Readme
@kintone/rest
kintone REST API client for JavaScript and TypeScript generated by openapi-typescript.
[!WARNING] Experimental: This package is still under early development.
Migration
See Migration Guide
Installation
This library is distributed on npm
.
npm install @kintone/rest
You can then use require
or import
to import the library.
// CommonJS
const { createClient } = require("@kintone/rest");
// ES modules
import { createClient } from "@kintone/rest";
import { createClient, paths } from "@kintone/rest";
Browser support
TODO
Usage
Here is a sample code that retrieves app records in TypeScript.
import { createClient, paths } from "@kintone/rest";
const client = createClient<paths>({
baseUrl: "https://example.cybozu.com",
headers: {
"X-Cybozu-Authorization": process.env.KINTONE_AUTHORIZATION,
// Use API token authentication
// "X-Cybozu-API-Token": process.env.KINTONE_API_TOKEN,
// Use OAuth token authentication
// "Authorization: `Basic ${process.env.KINTONE_OAUTH_TOKEN}`,
},
});
try {
const resp = await client.GET("/k/v1/records.json", {
params: {
query: { app: 1 },
},
});
console.log(resp.data?.records);
} catch (e) {
console.error(e);
}
We recommend using TypeScript because it benefits from completions for paths, params, etc.
When you use JavaScript without their benefits, the Client can be created as follows:
import { createClient } from "@kintone/rest";
const client = createClient({
baseUrl: "https://example.cybozu.com",
headers: {
"X-Cybozu-Authorization": process.env.KINTONE_AUTHORIZATION,
},
});
Contribution Guide
See CONTRIBUTING.md