Expand description
A client library of Kintone REST APIs for Rust.
DISCLAIMER: this OSS is my own personal work and does not have any relationship with Cybozu Inc. or any other organization which I belong to.
WARNING: This library is under development and is likely to undergo incompatible changes in the future.
§Usage
This library provides a fluent API for interacting with Kintone REST APIs using method chaining. All API functions return request builders that can be configured with additional parameters and then sent to the Kintone server.
§Basic Example
Here’s a simple example that retrieves a record from a Kintone app and displays it:
use kintone::client::{Auth, KintoneClient};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a client with your Kintone base URL and API token
let base_url = "https://your-domain.cybozu.com";
let api_token = "your-api-token".to_owned();
let client = KintoneClient::new(base_url, Auth::api_token(api_token));
// Get a single record by ID
let response = kintone::v1::record::get_record(123, 456) // app_id: 123, record_id: 456
.send(&client)?;
println!("Retrieved record:");
for (field_code, field_value) in response.record.fields() {
println!(" '{}' = {:?}", field_code, field_value);
}
// Get multiple records with filtering
let response = kintone::v1::record::get_records(123)
.query("status = \"Active\"")
.fields(&["name", "email", "status"])
.send(&client)?;
for record in response.records {
println!("Record:");
for (field_code, field_value) in record.fields() {
println!(" '{}' = {:?}", field_code, field_value);
}
}
Ok(())
}
§Supported APIs
The library currently supports the following Kintone REST API endpoints:
v1::record
: Record management APIsv1::record::get_record
,v1::record::get_records
,v1::record::add_record
,v1::record::add_records
,v1::record::update_record
,v1::record::update_records
,v1::record::delete_records
,v1::record::bulk_request
,v1::record::update_assignees
,v1::record::update_status
,v1::record::get_comments
,v1::record::add_comment
,v1::record::delete_comment
,v1::record::create_cursor
,v1::record::get_records_by_cursor
,v1::record::delete_cursor
v1::file
: File management APIsv1::space
: Space management APIsv1::app
: App management APIs
§Builder Pattern and Method Chaining
Each API function follows the same pattern: create a request builder, optionally configure it
with additional parameters using method chaining, and then call .send(&client)
to execute the request.
let response = kintone::v1::record::get_records(app_id) // Returns a request builder
.query("status = \"Active\"") // Optional parameter: query filter
.fields(&["name", "email"]) // Optional parameter: field selection
.send(&client)?; // Execute the request
This builder pattern allows us to add optional parameters to our APIs while maintaining
backward compatibility. You can call multiple methods on the builder to configure your
request, and only the final .send(&client)
call actually sends the request to the server.
Note: If you forget to call .send(&client)
, the compiler will help you catch this mistake
with a helpful warning:
unused `kintone::v1::space::AddThreadCommentRequest` that must be used
This happens because all request builders are marked with #[must_use]
, so you’ll
quickly notice if you accidentally create a request without sending it. The compiler
warning ensures you won’t miss this important step!
§Examples
For more detailed examples and usage patterns, check out the examples
directory in this repository.
Each example demonstrates how to use specific API endpoints and can be run directly to test the functionality.
The examples use environment variables for configuration:
KINTONE_BASE_URL
: Your Kintone domain URL (e.g.,https://your-domain.cybozu.com
)KINTONE_API_TOKEN
: Your API token for authenticationKINTONE_USERNAME
: Your username for KintoneKINTONE_PASSWORD
: Your password for Kintone
You can run an example like this:
export KINTONE_BASE_URL=https://your-domain.cybozu.com
export KINTONE_API_TOKEN=your-token
export KINTONE_USERNAME=your-username
export KINTONE_PASSWORD=your-password
cargo run --example get_record
Modules§
- client
- Kintone HTTP Client
- error
- Error Types
- middleware
- Middleware System for Kintone Client
- model
- Kintone Data Models
- v1
- Kintone REST API v1