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()
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()
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()
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 |