kintone REST API Request

 

Introduction

The kintone REST API Request allows you to run kintone REST APIs from your JavaScript code.
You'll find that you are limited to several actions when just completely relying on the JavaScript API - for example, you'll need to use the kintone REST API if you need to retrieve data of all the records inside your app.
This is where you will use the kintone REST API Request, to run the REST API.

kintone REST API Requestkintone.api()

REST APIs with the GET, POST, PUT, DELETE method can be used.

Function

kintone.api(pathOrUrl, method, params, opt_callback, opt_errback)

Request Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
pathOrUrl String Yes The path of the kintone REST API, or the URL obtained with kintone.api.url .
If the URL of the API is https://{subdomain}.kintone.com/k/v1/xxx.json, then specify the parameter as /k/v1/xxx. If the app is to be used inside a guest space, specify the parameter as kintone.api.url("/k/v1/xxx", true).
method String Yes The HTTP method. Specify one of the following: GET / POST / PUT / DELETE.
params Object Yes The parameters to be used with the API, specified as an object.
opt_callback Function Optional The callback function called when the API succeeds.
The parameter for this function is an object.
If ignored, a kintone.Promise object will be returned that can be fulfilled with the parameter passed to the callback.
opt_errback Function Optional The callback function called when the API fails.
The parameter for this function is a JSON response. If the JSON response cannot be parsed, an unparsed string will be given.
If the callback is ignored, a kintone.Promise object will be returned that can be rejected with the parameter passed to the errback.

Response

A kintone.Promise object will be returned if the callback parameter is ignored. Otherwise, there will be no response

Sample Request

Sample Request using Promises

Limitations

File upload/downloads cannot be run. You will need to retrieve the CSRF token, and run an HTTP request.

Get URLkintone.api.url()

Returns a URL from a shortened API path.

Function

kintone.api.url(path,opt_detectGuestSpace)

Request Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
path String Yes The kintone REST API path string beginning with /.
If the URL of the API is https://{subdomain}.kintone.com/k/v1/xxx.json, then specify the parameter as /k/v1/xxx.
opt_detectGuestSpace Boolean Optional If this is set to true, and is used in a guest space app, the URI of the guest space will be returned. Default is false.

Response

A URL string.

Sample Response

Sample Request

Get URL (including query)kintone.api.urlForGet()

Returns a URL including a query string, from an API path and parameters.

Function

kintone.api.urlForGet(path, params,opt_detectGuestSpace)

Request Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
path String Yes The kintone REST API path string beginning with /.
If the URL of the API is https://{subdomain}.kintone.com/k/v1/xxx.json, then specify the parameter as /k/v1/xxx.
params Object Yes The parameters to be used with the API, specified as an object.
opt_detectGuestSpace Boolean Optional If this is set to true, and is used in a guest space app, the URI of the guest space will be returned. Default is false.

Response

A URL string including a query string, with URL encoded parameters.

Sample Response

Sample Request

Get CSRF Tokenkintone.getRequestToken()

Retrieves a CSRF token to be used for file downloads/uploads.
This can be used for all APIs that have an HTTP method of POST, PUT and DELETE. APIs with an HTTP method of GET do not need a CSRF token.

Function

kintone.getRequestToken()

Request Parameters

None

Response

A string.

Available Period

86400 seconds (1 day) from the last access.

Sample Response

Sample Request

Sample for APIs using Query Strings

Sample for APIs using JSON

Request headers needed with the APIs

Header Content
X-Requested-With XMLHttpRequest
Content-Type application/json
Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!