yxhoo-transit 0.4.4

A client for Yxhoo! Transit (Japan) unofficial API
Documentation

yxhoo-transit

crates.io docs.rs downloads license CI

日本語 README

A Rust client for Yxhoo! Transit (Japan) unofficial API. This crate provides functions to suggest places and search for transit routes using Yxhoo! Transit.

Usage

Add this to your Cargo.toml:

[dependencies]

yxhoo-transit = "0.4"

Features

  • http-reqwest (default): Use reqwest as the HTTP client.
  • http-wreq: Use wreq as the HTTP client.
  • schemars: Enable JsonSchema derives for public types.

Example

use yxhoo_transit::{suggest_places, transit, args::{TransitArgs, DateKind}};

#[tokio::main]
async fn main() {
    // Suggest places
    let suggestions = suggest_places("新宿").await.unwrap();
    println!("{:?}", suggestions);

    // Transit search
    let args = TransitArgs {
        from: "新宿".into(),
        to: "渋谷".into(),
        date: chrono::Local::now().into(),
        date_kind: DateKind::DepartureTime,
        rank: 1,
        ..Default::default()
    };
    let result = transit(&args).await.unwrap();
    println!("{:?}", result);
}

License

Apache-2.0