| Crates.io | twelve_data_inav |
| lib.rs | twelve_data_inav |
| version | 0.5.4 |
| created_at | 2025-12-31 03:04:23.669408+00 |
| updated_at | 2026-01-01 00:43:50.065168+00 |
| description | [DEPRECATED] Use twelve-data-client instead. Simple Rust API for accessing the Twelve Data HTTP API (https://twelvedata.com) |
| homepage | https://github.com/alex12058/twelve_data_inav |
| repository | https://github.com/alex12058/twelve_data_inav |
| max_upload_size | |
| id | 2013793 |
| size | 163,411 |
⚠️ DEPRECATED: This crate is deprecated in favor of twelve-data-client, which is auto-generated from the official Twelve Data OpenAPI specification and provides comprehensive API coverage with automatic builder pattern generation. Note: CSV format support is not yet available in the new client. If you require CSV responses, continue using this crate.
This is a Rust client for the https://twelvedata.com API.
Fork Notice: This is a fork of metlos/twelve_data with additional features:
DataResponse<T> wrapper for unified JSON/CSV handlingAt this moment in time, it is by no means complete, only a couple of APIs useful for getting the stock price is implemented.
Add this to your Cargo.toml:
[dependencies]
twelve_data_inav = "0.5"
reqwest = "0.13.1"
tokio = { version = "1", features = ["full"] }
Enable the axum feature for web framework integration:
[dependencies]
twelve_data_inav = { version = "0.5", features = ["axum"] }
use twelve_data_inav::{TwelveData, core::TimeSeriesRequest, Interval};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("TWELVE_DATA_API_KEY")?;
let client = TwelveData::new(&api_key, Box::new(reqwest::Client::new()));
// Request time series data
let request = TimeSeriesRequest::builder()
.symbol("AAPL".into())
.interval(Interval::Day)
.output_size(10)
.build()?;
let response = client.time_series(request).await?;
let data = response.parse()?;
println!("Symbol: {}", data.meta.unwrap().symbol);
for quote in data.values {
println!("Date: {}, Close: ${}", quote.datetime, quote.close);
}
Ok(())
}
use twelve_data_inav::{
TwelveData,
core::TimeSeriesRequest,
Interval,
OutputFormat,
CommonQueryParameters
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("TWELVE_DATA_API_KEY")?;
let client = TwelveData::new(&api_key, Box::new(reqwest::Client::new()));
// Request CSV format
let request = TimeSeriesRequest::builder()
.symbol("AAPL".into())
.interval(Interval::Day)
.output_size(5)
.common(
CommonQueryParameters::builder()
.format(OutputFormat::CSV)
.build()?
)
.build()?;
let response = client.time_series(request).await?;
if response.is_csv() {
// Option 1: Parse CSV to structs
let data = response.parse_csv()?;
println!("Got {} values", data.values.len());
// Option 2: Get raw CSV string
// let csv_text = response.raw();
}
Ok(())
}
use twelve_data_inav::{TwelveData, core::QuoteRequest, Interval};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("TWELVE_DATA_API_KEY")?;
let client = TwelveData::new(&api_key, Box::new(reqwest::Client::new()));
let request = QuoteRequest::builder()
.symbol("TSLA".into())
.interval(Interval::Day)
.build()?;
let response = client.quote(request).await?;
let quote = response.parse()?;
println!("Symbol: {}", quote.symbol);
println!("Current Price: ${}", quote.close);
println!("Change: ${} ({}%)", quote.change, quote.percent_change);
Ok(())
}
axum feature for web framework integrationcsv, CSV, json, JSON, etc.time_series() - Historical OHLCV dataquote() - Real-time quote dataprice() - Current pricelogo() - Company logo URLFor detailed API documentation, run:
cargo doc --open
See CSV_USAGE.md for examples of working with CSV responses.