···1111[apache-2-0-url]: https://github.com/kaychaks/kiteticker-async/blob/master/LICENSE
12121313[Guide](https://kite.trade/docs/connect/v3/websocket/#websocket-streaming) |
1414-[API Docs](https://docs.rs/kiteticker-async/latest/kiteticker-async) |'
1414+[API Docs](https://docs.rs/kiteticker-async/latest/kiteticker-async)
15151616## Overview
17171818-_TODO_
1818+The official [kiteconnect-rs](https://crates.io/crates/kiteconnect) is an unmaintained project compared to the Python or Go implementations. As per this [issue](https://github.com/zerodha/kiteconnect-rs/issues/39), it will not get any further updates from the Zerodha Tech team.
1919+2020+Even though the Kite Connect REST APIs are feature-complete, the Ticker APIs are lagging. Here are some of the issues with Ticker API Rust implementation:
2121+ - It lacks a few updates, which are present in actively maintained [Python](https://github.com/zerodha/pykiteconnect) & [Go](https://github.com/zerodha/gokiteconnect) implementations.
2222+ - It does not parse and serialise quote structure to proper Rust structs and leaves it at an untyped JSON value. This is again a departure from how the same is implemented in libraries of typed languages like [Go](https://github.com/zerodha/gokiteconnect/blob/master/ticker/ticker.go) or [Java](https://github.com/zerodha/javakiteconnect/tree/master/kiteconnect/src/com/zerodhatech/models).
2323+ - The design requires the applications to handle the streaming WebSocket messages via callbacks. It is not an idiomatic Rust library design, primarily when the downstream applications rely on modern Rust async concurrency primitives using frameworks like [tokio](https://tokio.rs/).
2424+2525+This crate is an attempt to address the above issues. The primary goal is to have an async-friendly design following Rust's async library design principles championed by [tokio](https://tokio.rs/tokio/tutorial).
2626+2727+## Usage
2828+2929+Add kiteticker-async crate as a dependency in Cargo.toml
3030+3131+```
3232+[dependencies]
3333+kiteticker-async = "0.1.0"
3434+```
19352036## Example
21372222-_TODO_
3838+```rust
3939+#[tokio::main]
4040+pub async fn main() -> Result<(), String> {
4141+ let api_key = std::env::var("KITE_API_KEY").unwrap();
4242+ let access_token = std::env::var("KITE_ACCESS_TOKEN").unwrap();
4343+ let ticker = KiteTickerAsync::connect(&api_key, &access_token).await?;
4444+4545+ let token = 408065;
4646+ // subscribe to an instrument
4747+ let mut subscriber = ticker
4848+ .subscribe(&[token], Some(Mode::Full))
4949+ .await?;
5050+5151+ // await quotes
5252+ if let Ok(Some(msg)) = subscriber.next_message().await? {
5353+ match msg {
5454+ TickerMessage::Tick(ticks) => {
5555+ let tick = ticks.first().unwrap();
5656+ println!("Received tick for instrument_token {}, {}", tick.instrument_token, tick);
5757+ }
5858+ }
5959+ }
6060+6161+ Ok(())
6262+}
6363+```
23642465## Contributing
25662626-_TODO_
6767+Use [just](https://github.com/casey/just) to run the development tasks.
6868+6969+```sh
7070+$ just --list
7171+Available recipes:
7272+ build
7373+ check
7474+ doc
7575+ doc-open
7676+ doc-test api_key='' access_token=''
7777+ example api_key access_token
7878+ test api_key='' access_token=''
7979+```
8080+8181+## License
8282+8383+This project is licensed under the [Apache 2.0 License]
8484+8585+[Apache 2.0 license]: https://github.com/kaychaks/kiteticker-async/blob/master/LICENSE