Expand description
gBizINFO REST API (v2) の Rust クライアント。
gBizINFO は経済産業省が提供する法人情報サイトで、法人として登記されている約400万社を対象に、 法人番号・法人名・本社所在地に加え、届出・認定、表彰、財務、特許、調達、補助金、職場情報などの 法人活動情報を取得できる。
§セットアップ
API トークンを Web API利用申請で取得し、
GbizInfoClient::new に渡す。
§使い方
use gbiz_info_api::{GbizInfoClient, HojinSearchQuery, UpdateInfoQuery};
let client = GbizInfoClient::new("YOUR_API_TOKEN");
// 法人検索
let res = client
.search(&HojinSearchQuery::new().name("トヨタ自動車").limit(10))
.await?;
for info in res.into_hojin_infos() {
println!("{}", info.name.unwrap_or_default());
}
// 法人番号を指定して基本情報を取得
let res = client.hojin("1180301018771").await?;
// メタデータ(出典元・最終更新日等)付きで財務情報を取得
let res = client.finance("1180301018771").metadata_flg(true).await?;
// 期間内に追加/更新された法人基本情報を取得(ページング付き)
let res = client
.update_info(&UpdateInfoQuery::new("20260401", "20260430"))
.await?;§エラーハンドリング
すべての API 呼び出しは Result<_, GbizError> を返す。
HTTP ステータスエラーはレスポンスボディ付きの GbizError::Status になる。
match client.hojin("0000000000000").await {
Ok(res) => { /* ... */ }
Err(err) if err.is_not_found() => eprintln!("法人が見つかりません"),
Err(GbizError::Status { status, body }) => eprintln!("API エラー {status}: {body}"),
Err(err) => eprintln!("通信エラー等: {err}"),
}§対応エンドポイント
GbizInfoClient のメソッド | エンドポイント | レスポンス |
|---|---|---|
search | GET /v2/hojin | SearchResponse |
hojin | GET /v2/hojin/{corporate_number} | HojinResponse |
certification | GET /v2/hojin/{corporate_number}/certification | HojinChildResponse |
commendation | GET /v2/hojin/{corporate_number}/commendation | HojinChildResponse |
corporation | GET /v2/hojin/{corporate_number}/corporation | HojinChildResponse |
finance | GET /v2/hojin/{corporate_number}/finance | HojinChildResponse |
patent | GET /v2/hojin/{corporate_number}/patent | HojinChildResponse |
procurement | GET /v2/hojin/{corporate_number}/procurement | HojinChildResponse |
subsidy | GET /v2/hojin/{corporate_number}/subsidy | HojinChildResponse |
workplace | GET /v2/hojin/{corporate_number}/workplace | HojinChildResponse |
update_info | GET /v2/hojin/updateInfo | UpdateInfoHojinResponse |
update_info_certification | GET /v2/hojin/updateInfo/certification | UpdateInfoChildResponse |
update_info_commendation | GET /v2/hojin/updateInfo/commendation | UpdateInfoChildResponse |
update_info_corporation | GET /v2/hojin/updateInfo/corporation | UpdateInfoChildResponse |
update_info_finance | GET /v2/hojin/updateInfo/finance | UpdateInfoChildResponse |
update_info_patent | GET /v2/hojin/updateInfo/patent | UpdateInfoChildResponse |
update_info_procurement | GET /v2/hojin/updateInfo/procurement | UpdateInfoChildResponse |
update_info_subsidy | GET /v2/hojin/updateInfo/subsidy | UpdateInfoChildResponse |
update_info_workplace | GET /v2/hojin/updateInfo/workplace | UpdateInfoChildResponse |
§関連リンク
Re-exports§
pub use client::DetailRequest;pub use client::GbizInfoClient;pub use client::GbizInfoClientBuilder;pub use client::DEFAULT_BASE_URL;pub use error::GbizError;pub use query::HojinSearchQuery;pub use query::UpdateInfoQuery;pub use types::*;