Skip to content

Quickstart Nodejs

Requirement

  • Node.js (Version 8.9.3 or later)
  • npm (Version 5.5.1 or later)

How to use

cd your-project
npm init
npm install --save @kintone/kintone-js-sdk

Code example

Get record sample

Source code

const kintone = require('@kintone/kintone-js-sdk');

let kintoneAuthWithAPIToken = (new kintone.Auth()).setApiToken('MY_TOKEN');
let kintoneConnection = new kintone.Connection('your.FQDN.tld', kintoneAuthWithAPIToken);

let kintoneRecord = new kintone.Record(kintoneConnection);

let appID = {your_app_id};
let recordID = {record_id_that_will_be_retrived};
kintoneRecord.getRecord(appID, recordID)
    .then((rsp) => {
        console.log(rsp);
    })
    .catch((err) => {
        // The promise function always reject with KintoneAPIExeption
        console.log(err.get());
    });

Response success

{
    "record":{
        // record data should be here
    }
}

Response error

{
    id: '{ID}',
    code: '{CODE}',
    message: '{Message string}',
    errors: '{JSON String}'
}

Get record sample with Async

Source code


    const kintone = require('@kintone/kintone-js-sdk');

    let kintoneAuthWithAPIToken = (new kintone.Auth()).setApiToken('MY_TOKEN');
    let kintoneConnection = new kintone.Connection('your.FQDN', kintoneAuthWithAPIToken);

    let kintoneRecord = new kintone.Record(kintoneConnection);

    let appID = {your_app_id};
    let recordID = {record_id_that_will_be_retrived};
    let getRecord = async () => {
        try {
            let recordResult = await kintoneRecord.getRecord(appID, recordID);
            console.log(recordResult);
        } catch (error) {
            // The promise function always reject with KintoneAPIExeption
            console.log(error.get());
        }
    }
    getRecord();

Response success

    {
        "record":{
            // record data should be here
        }
    }

Response error

    { 
        id: '{ID}',
        code: '{CODE}',
        message: '{Message string}',
        errors: '{JSON String}'
    }