๐ Singapore LTA Datamall async first Rust client. lta-rs is used to interact with lta-datamall
[dependencies]
lta = { version = "0.7.0" }
You can get your API key from here
use lta::{LTAResult, LTAClient, Client, Traffic, TrafficRequests};
#[tokio::main]
async fn main() -> LTAResult<()> {
let api_key = std::env::var("API_KEY").expect("API_KEY not found!");
let client = LTAClient::with_api_key(api_key)?;
let erp_rates = Traffic::get_erp_rates(&client, None).await?;
println!("{:?}", erp_rates);
Ok(())
}
Feature | Description |
---|---|
default (i.e no features added ) |
Uses reqwest under the hood |
reqwest-blocking |
Uses reqwest::blocking under the hood |
ureq-blocking |
Uses ureq under the hood |
fastfloat |
Enables the fastfloat impl for parsing floats (uses SIMD) |
non-blocking-traits |
Exports traits that can be use to impl non-blocking clients |
blocking-traits |
Exports traits that can be use to impl blocking clients |
Using ureq
only
[dependencies]
lta = { version = "0.7.0", default-features = false, features = ["ureq-blocking"]}
Implementing another blocking backend
[dependencies]
lta = { version = "0.7.0", default-features = false, features = ["blocking-traits"]}
Implementing another async backend
[dependencies]
lta = { version = "0.7.0", default-features = false, features = ["non-blocking-traits"]}
Backend | Status | Github CI Run ![]() |
---|---|---|
reqwest | Official โ | Yes โ ๏ธ |
reqwest blocking | Official โ ๏ธ | Yes โ๏ธ |
ureq | Official โ ๏ธ | Yes โ๏ธ |
surf | TBA โญ ๏ธ | No โญ |
Example | Description |
---|---|
bus_timing.rs | How to get bus timing (async used) |
reqwest_blocking.rs | How to use reqwest blocking feature |
ureq_blocking.rs | How to use ureq backend |
custom_client.rs | How to create custom backend clients |
- Reuse
LTAClient<T>
as it holds a connection pool internally - Reduce the number of times you call the API, take a look at
Update Freq
in the documentation and prevent yourself from getting blacklisted. Use a caching mechanism.
- You can get help via GitHub issues. I will try my best to respond to your queries ๐
Changelog can be found here
- Rust compiler 1.56
Q: Is this library being actively developed?
A: Project is currently in maintenance mode. Won't really have any new features. Just bug fixes, minor upgrades etc.
Q: What are the APIs available?
A: All of the APIs are implemented. Take a look at the official LTA docs.
Q: Where do I get the official docs from lta?
A: You can get them here
lta-rs is licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
For Singapore based users, you can donate using paylah!