twelve_data_client/apis/
etfs_api.rs

1/*
2 * Twelve Data API
3 *
4 * ## Overview  Welcome to Twelve Data developer docs — your gateway to comprehensive financial market data through a powerful and easy-to-use API. Twelve Data provides access to financial markets across over 50 global countries, covering more than 1 million public instruments, including stocks, forex, ETFs, mutual funds, commodities, and cryptocurrencies.  ## Quickstart  To get started, you'll need to sign up for an API key. Once you have your API key, you can start making requests to the API.  ### Step 1: Create Twelve Data account  Sign up on the Twelve Data website to create your account [here](https://twelvedata.com/register). This gives you access to the API dashboard and your API key.  ### Step 2: Get your API key  After signing in, navigate to your [dashboard](https://twelvedata.com/account/api-keys) to find your unique API key. This key is required to authenticate all API and WebSocket requests.  ### Step 3: Make your first request  Try a simple API call with cURL to fetch the latest price for Apple (AAPL):  ``` curl \"https://api.twelvedata.com/price?symbol=AAPL&apikey=your_api_key\" ```  ### Step 4: Make a request from Python or Javascript  Use our client libraries or standard HTTP clients to make API calls programmatically. Here’s an example in [Python](https://github.com/twelvedata/twelvedata-python) and JavaScript:  #### Python (using official Twelve Data SDK):  ```python from twelvedata import TDClient  # Initialize client with your API key td = TDClient(apikey=\"your_api_key\")  # Get latest price for Apple price = td.price(symbol=\"AAPL\").as_json()  print(price) ```  #### JavaScript (Node.js):  ```javascript const fetch = require('node-fetch');  fetch('https://api.twelvedata.com/price?symbol=AAPL&apikey=your_api_key') &nbsp;&nbsp;.then(response => response.json()) &nbsp;&nbsp;.then(data => console.log(data)); ```  ### Step 5: Perform correlation analysis between Tesla and Microsoft prices  Fetch historical price data for Tesla (TSLA) and Microsoft (MSFT) and calculate the correlation of their closing prices:  ```python from twelvedata import TDClient import pandas as pd  # Initialize client with your API key td = TDClient(apikey=\"your_api_key\")  # Fetch historical price data for Tesla tsla_ts = td.time_series( &nbsp;&nbsp;&nbsp;&nbsp;symbol=\"TSLA\", &nbsp;&nbsp;&nbsp;&nbsp;interval=\"1day\", &nbsp;&nbsp;&nbsp;&nbsp;outputsize=100 ).as_pandas()  # Fetch historical price data for Microsoft msft_ts = td.time_series( &nbsp;&nbsp;&nbsp;&nbsp;symbol=\"MSFT\", &nbsp;&nbsp;&nbsp;&nbsp;interval=\"1day\", &nbsp;&nbsp;&nbsp;&nbsp;outputsize=100 ).as_pandas()  # Align data on datetime index combined = pd.concat( &nbsp;&nbsp;&nbsp;&nbsp;[tsla_ts['close'].astype(float), msft_ts['close'].astype(float)], &nbsp;&nbsp;&nbsp;&nbsp;axis=1, &nbsp;&nbsp;&nbsp;&nbsp;keys=[\"TSLA\", \"MSFT\"] ).dropna()  # Calculate correlation correlation = combined[\"TSLA\"].corr(combined[\"MSFT\"]) print(f\"Correlation of closing prices between TSLA and MSFT: {correlation:.2f}\") ```  ### Authentication  Authenticate your requests using one of these methods:  #### Query parameter method ``` GET https://api.twelvedata.com/endpoint?symbol=AAPL&apikey=your_api_key ```  #### HTTP header method (recommended) ``` Authorization: apikey your_api_key ```  ##### API key useful information <ul> <li> Demo API key (<code>apikey=demo</code>) available for demo requests</li> <li> Personal API key required for full access</li> <li> Premium endpoints and data require higher-tier plans (testable with <a href=\"https://twelvedata.com/exchanges\">trial symbols</a>)</li> </ul>  ### API endpoints   Service | Base URL | ---------|----------|  REST API | `https://api.twelvedata.com` |  WebSocket | `wss://ws.twelvedata.com` |  ### Parameter guidelines <ul> <li><b>Separator:</b> Use <code>&</code> to separate multiple parameters</li> <li><b>Case sensitivity:</b> Parameter names are case-insensitive</li>  <ul><li><code>symbol=AAPL</code> = <code>symbol=aapl</code></li></ul>  <li><b>Multiple values:</b> Separate with commas where supported</li> </ul>  ### Response handling  #### Default format All responses return JSON format by default unless otherwise specified.  #### Null values <b>Important:</b> Some response fields may contain `null` values when data is unavailable for specific metrics. This is expected behavior, not an error.  ##### Best Practices: <ul> <li>Always implement <code>null</code> value handling in your application</li> <li>Use defensive programming techniques for data processing</li> <li>Consider fallback values or error handling for critical metrics</li> </ul>  #### Error handling Structure your code to gracefully handle: <ul> <li>Network timeouts</li> <li>Rate limiting responses</li> <li>Invalid parameter errors</li> <li>Data unavailability periods</li> </ul>  ##### Best practices <ul> <li><b>Rate limits:</b> Adhere to your plan’s rate limits to avoid throttling. Check your dashboard for details.</li> <li><b>Error handling:</b> Implement retry logic for transient errors (e.g., <code>429 Too Many Requests</code>).</li> <li><b>Caching:</b> Cache responses for frequently accessed data to reduce API calls and improve performance.</li> <li><b>Secure storage:</b> Store your API key securely and never expose it in client-side code or public repositories.</li> </ul>  ## Errors  Twelve Data API employs a standardized error response format, delivering a JSON object with `code`, `message`, and `status` keys for clear and consistent error communication.  ### Codes  Below is a table of possible error codes, their HTTP status, meanings, and resolution steps:   Code | status | Meaning | Resolution |  --- | --- | --- | --- |  **400** | Bad Request | Invalid or incorrect parameter(s) provided. | Check the `message` in the response for details. Refer to the API Documenta­tion to correct the input. |  **401** | Unauthor­ized | Invalid or incorrect API key. | Verify your API key is correct. Sign up for a key <a href=\"https://twelvedata.com/account/api-keys\">here</a>. |  **403** | Forbidden | API key lacks permissions for the requested resource (upgrade required). | Upgrade your plan <a href=\"https://twelvedata.com/pricing\">here</a>. |  **404** | Not Found | Requested data could not be found. | Adjust parameters to be less strict as they may be too restrictive. |  **414** | Parameter Too Long | Input parameter array exceeds the allowed length. | Follow the `message` guidance to adjust the parameter length. |  **429** | Too Many Requests | API request limit reached for your key. | Wait briefly or upgrade your plan <a href=\"https://twelvedata.com/pricing\">here</a>. |  **500** | Internal Server Error | Server-side issue occurred; retry later. | Contact support <a href=\"https://twelvedata.com/contact\">here</a> for assistance. |  ### Example error response  Consider the following invalid request:  ``` https://api.twelvedata.com/time_series?symbol=AAPL&interval=0.99min&apikey=your_api_key ```  Due to the incorrect `interval` value, the API returns:  ```json { &nbsp;&nbsp;\"code\": 400, &nbsp;&nbsp;\"message\": \"Invalid **interval** provided: 0.99min. Supported intervals: 1min, 5min, 15min, 30min, 45min, 1h, 2h, 4h, 8h, 1day, 1week, 1month\", &nbsp;&nbsp;\"status\": \"error\" } ```  Refer to the API Documentation for valid parameter values to resolve such errors.  ## Libraries  Twelve Data provides a growing ecosystem of libraries and integrations to help you build faster and smarter in your preferred environment. Official libraries are actively maintained by the Twelve Data team, while selected community-built libraries offer additional flexibility.  A full list is available on our [GitHub profile](https://github.com/search?q=twelvedata).  ### Official SDKs <ul> <li><b>Python:</b> <a href=\"https://github.com/twelvedata/twelvedata-python\">twelvedata-python</a></li> <li><b>R:</b> <a href=\"https://github.com/twelvedata/twelvedata-r-sdk\">twelvedata-r-sdk</a></li> </ul>  ### AI integrations <ul> <li><b>Twelve Data MCP Server:</b> <a href=\"https://github.com/twelvedata/mcp\">Repository</a> — Model Context Protocol (MCP) server that provides seamless integration with AI assistants and language models, enabling direct access to Twelve Data's financial market data within conversational interfaces and AI workflows.</li> </ul>  ### Spreadsheet add-ons <ul> <li><b>Excel:</b> <a href=\"https://twelvedata.com/excel\">Excel Add-in</a></li> <li><b>Google Sheets:</b> <a href=\"https://twelvedata.com/google-sheets\">Google Sheets Add-on</a></li> </ul>  ### Community libraries  The community has developed libraries in several popular languages. You can explore more community libraries on [GitHub](https://github.com/search?q=twelvedata). <ul> <li><b>C#:</b> <a href=\"https://github.com/pseudomarkets/TwelveDataSharp\">TwelveDataSharp</a></li> <li><b>JavaScript:</b> <a href=\"https://github.com/evzaboun/twelvedata\">twelvedata</a></li> <li><b>PHP:</b> <a href=\"https://github.com/ingelby/twelvedata\">twelvedata</a></li> <li><b>Go:</b> <a href=\"https://github.com/soulgarden/twelvedata\">twelvedata</a></li> <li><b>TypeScript:</b> <a href=\"https://github.com/Clyde-Goodall/twelve-data-wrapper\">twelve-data-wrapper</a></li> </ul>  ### Other Twelve Data repositories <ul> <li><b>searchindex</b> <i>(Go)</i>: <a href=\"https://github.com/twelvedata/searchindex\">Repository</a> — In-memory search index by strings</li> <li><b>ws-tools</b> <i>(Python)</i>: <a href=\"https://github.com/twelvedata/ws-tools\">Repository</a> — Utility tools for WebSocket stream handling</li> </ul>  ### API specification <ul> <li><b>OpenAPI / Swagger:</b> Access the <a href=\"https://api.twelvedata.com/doc/swagger/openapi.json\">complete API specification</a> in OpenAPI format. You can use this file to automatically generate client libraries in your preferred programming language, explore the API interactively via Swagger tools, or integrate Twelve Data seamlessly into your AI and LLM workflows.</li> </ul>
5 *
6 * The version of the OpenAPI document: 0.0.1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17/// struct for passing parameters to the method [`get_etfs_world`]
18#[derive(Clone, Debug, Default)]
19pub struct GetEtfsWorldParams {
20    /// Symbol ticker of etf
21    pub symbol: Option<String>,
22    /// Filter by financial instrument global identifier (FIGI)
23    pub figi: Option<String>,
24    /// Filter by international securities identification number (ISIN)
25    pub isin: Option<String>,
26    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
27    pub cusip: Option<String>,
28    /// Filter by country name or alpha code, e.g., `United States` or `US`
29    pub country: Option<String>,
30    /// Number of decimal places for floating values. Accepts value in range [0,11]
31    pub dp: Option<i64>
32}
33
34impl GetEtfsWorldParams {
35    /// Create a new builder for this parameter struct
36    pub fn builder() -> GetEtfsWorldParamsBuilder {
37        GetEtfsWorldParamsBuilder::default()
38    }
39}
40
41/// Builder for [`GetEtfsWorldParams`]
42#[derive(Clone, Debug, Default)]
43pub struct GetEtfsWorldParamsBuilder {
44    /// Symbol ticker of etf
45    symbol: Option<String>,
46    /// Filter by financial instrument global identifier (FIGI)
47    figi: Option<String>,
48    /// Filter by international securities identification number (ISIN)
49    isin: Option<String>,
50    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
51    cusip: Option<String>,
52    /// Filter by country name or alpha code, e.g., `United States` or `US`
53    country: Option<String>,
54    /// Number of decimal places for floating values. Accepts value in range [0,11]
55    dp: Option<i64>
56}
57
58impl GetEtfsWorldParamsBuilder {
59    /// Symbol ticker of etf
60    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
61        self.symbol = Some(symbol.into());
62        
63        self
64    }
65    /// Filter by financial instrument global identifier (FIGI)
66    pub fn figi(mut self, figi: impl Into<String>) -> Self {
67        self.figi = Some(figi.into());
68        
69        self
70    }
71    /// Filter by international securities identification number (ISIN)
72    pub fn isin(mut self, isin: impl Into<String>) -> Self {
73        self.isin = Some(isin.into());
74        
75        self
76    }
77    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
78    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
79        self.cusip = Some(cusip.into());
80        
81        self
82    }
83    /// Filter by country name or alpha code, e.g., `United States` or `US`
84    pub fn country(mut self, country: impl Into<String>) -> Self {
85        self.country = Some(country.into());
86        
87        self
88    }
89    /// Number of decimal places for floating values. Accepts value in range [0,11]
90    pub fn dp(mut self, dp: i64) -> Self {
91        
92        self.dp = Some(dp);
93        
94        self
95    }
96
97    /// Build the parameter struct
98    pub fn build(self) -> GetEtfsWorldParams {
99        GetEtfsWorldParams {
100            symbol: self.symbol,
101            figi: self.figi,
102            isin: self.isin,
103            cusip: self.cusip,
104            country: self.country,
105            dp: self.dp
106        }
107    }
108}
109
110/// struct for passing parameters to the method [`get_etfs_world_composition`]
111#[derive(Clone, Debug, Default)]
112pub struct GetEtfsWorldCompositionParams {
113    /// Symbol ticker of etf
114    pub symbol: Option<String>,
115    /// Filter by financial instrument global identifier (FIGI)
116    pub figi: Option<String>,
117    /// Filter by international securities identification number (ISIN)
118    pub isin: Option<String>,
119    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
120    pub cusip: Option<String>,
121    /// Filter by country name or alpha code, e.g., `United States` or `US`
122    pub country: Option<String>,
123    /// Number of decimal places for floating values. Accepts value in range [0,11]
124    pub dp: Option<i64>
125}
126
127impl GetEtfsWorldCompositionParams {
128    /// Create a new builder for this parameter struct
129    pub fn builder() -> GetEtfsWorldCompositionParamsBuilder {
130        GetEtfsWorldCompositionParamsBuilder::default()
131    }
132}
133
134/// Builder for [`GetEtfsWorldCompositionParams`]
135#[derive(Clone, Debug, Default)]
136pub struct GetEtfsWorldCompositionParamsBuilder {
137    /// Symbol ticker of etf
138    symbol: Option<String>,
139    /// Filter by financial instrument global identifier (FIGI)
140    figi: Option<String>,
141    /// Filter by international securities identification number (ISIN)
142    isin: Option<String>,
143    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
144    cusip: Option<String>,
145    /// Filter by country name or alpha code, e.g., `United States` or `US`
146    country: Option<String>,
147    /// Number of decimal places for floating values. Accepts value in range [0,11]
148    dp: Option<i64>
149}
150
151impl GetEtfsWorldCompositionParamsBuilder {
152    /// Symbol ticker of etf
153    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
154        self.symbol = Some(symbol.into());
155        
156        self
157    }
158    /// Filter by financial instrument global identifier (FIGI)
159    pub fn figi(mut self, figi: impl Into<String>) -> Self {
160        self.figi = Some(figi.into());
161        
162        self
163    }
164    /// Filter by international securities identification number (ISIN)
165    pub fn isin(mut self, isin: impl Into<String>) -> Self {
166        self.isin = Some(isin.into());
167        
168        self
169    }
170    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
171    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
172        self.cusip = Some(cusip.into());
173        
174        self
175    }
176    /// Filter by country name or alpha code, e.g., `United States` or `US`
177    pub fn country(mut self, country: impl Into<String>) -> Self {
178        self.country = Some(country.into());
179        
180        self
181    }
182    /// Number of decimal places for floating values. Accepts value in range [0,11]
183    pub fn dp(mut self, dp: i64) -> Self {
184        
185        self.dp = Some(dp);
186        
187        self
188    }
189
190    /// Build the parameter struct
191    pub fn build(self) -> GetEtfsWorldCompositionParams {
192        GetEtfsWorldCompositionParams {
193            symbol: self.symbol,
194            figi: self.figi,
195            isin: self.isin,
196            cusip: self.cusip,
197            country: self.country,
198            dp: self.dp
199        }
200    }
201}
202
203/// struct for passing parameters to the method [`get_etfs_world_performance`]
204#[derive(Clone, Debug, Default)]
205pub struct GetEtfsWorldPerformanceParams {
206    /// Symbol ticker of etf
207    pub symbol: Option<String>,
208    /// Filter by financial instrument global identifier (FIGI)
209    pub figi: Option<String>,
210    /// Filter by international securities identification number (ISIN)
211    pub isin: Option<String>,
212    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
213    pub cusip: Option<String>,
214    /// Filter by country name or alpha code, e.g., `United States` or `US`
215    pub country: Option<String>,
216    /// Number of decimal places for floating values. Accepts value in range [0,11]
217    pub dp: Option<i64>
218}
219
220impl GetEtfsWorldPerformanceParams {
221    /// Create a new builder for this parameter struct
222    pub fn builder() -> GetEtfsWorldPerformanceParamsBuilder {
223        GetEtfsWorldPerformanceParamsBuilder::default()
224    }
225}
226
227/// Builder for [`GetEtfsWorldPerformanceParams`]
228#[derive(Clone, Debug, Default)]
229pub struct GetEtfsWorldPerformanceParamsBuilder {
230    /// Symbol ticker of etf
231    symbol: Option<String>,
232    /// Filter by financial instrument global identifier (FIGI)
233    figi: Option<String>,
234    /// Filter by international securities identification number (ISIN)
235    isin: Option<String>,
236    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
237    cusip: Option<String>,
238    /// Filter by country name or alpha code, e.g., `United States` or `US`
239    country: Option<String>,
240    /// Number of decimal places for floating values. Accepts value in range [0,11]
241    dp: Option<i64>
242}
243
244impl GetEtfsWorldPerformanceParamsBuilder {
245    /// Symbol ticker of etf
246    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
247        self.symbol = Some(symbol.into());
248        
249        self
250    }
251    /// Filter by financial instrument global identifier (FIGI)
252    pub fn figi(mut self, figi: impl Into<String>) -> Self {
253        self.figi = Some(figi.into());
254        
255        self
256    }
257    /// Filter by international securities identification number (ISIN)
258    pub fn isin(mut self, isin: impl Into<String>) -> Self {
259        self.isin = Some(isin.into());
260        
261        self
262    }
263    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
264    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
265        self.cusip = Some(cusip.into());
266        
267        self
268    }
269    /// Filter by country name or alpha code, e.g., `United States` or `US`
270    pub fn country(mut self, country: impl Into<String>) -> Self {
271        self.country = Some(country.into());
272        
273        self
274    }
275    /// Number of decimal places for floating values. Accepts value in range [0,11]
276    pub fn dp(mut self, dp: i64) -> Self {
277        
278        self.dp = Some(dp);
279        
280        self
281    }
282
283    /// Build the parameter struct
284    pub fn build(self) -> GetEtfsWorldPerformanceParams {
285        GetEtfsWorldPerformanceParams {
286            symbol: self.symbol,
287            figi: self.figi,
288            isin: self.isin,
289            cusip: self.cusip,
290            country: self.country,
291            dp: self.dp
292        }
293    }
294}
295
296/// struct for passing parameters to the method [`get_etfs_world_risk`]
297#[derive(Clone, Debug, Default)]
298pub struct GetEtfsWorldRiskParams {
299    /// Symbol ticker of etf
300    pub symbol: Option<String>,
301    /// Filter by financial instrument global identifier (FIGI)
302    pub figi: Option<String>,
303    /// Filter by international securities identification number (ISIN)
304    pub isin: Option<String>,
305    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
306    pub cusip: Option<String>,
307    /// Filter by country name or alpha code, e.g., `United States` or `US`
308    pub country: Option<String>,
309    /// Number of decimal places for floating values. Accepts value in range [0,11]
310    pub dp: Option<i64>
311}
312
313impl GetEtfsWorldRiskParams {
314    /// Create a new builder for this parameter struct
315    pub fn builder() -> GetEtfsWorldRiskParamsBuilder {
316        GetEtfsWorldRiskParamsBuilder::default()
317    }
318}
319
320/// Builder for [`GetEtfsWorldRiskParams`]
321#[derive(Clone, Debug, Default)]
322pub struct GetEtfsWorldRiskParamsBuilder {
323    /// Symbol ticker of etf
324    symbol: Option<String>,
325    /// Filter by financial instrument global identifier (FIGI)
326    figi: Option<String>,
327    /// Filter by international securities identification number (ISIN)
328    isin: Option<String>,
329    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
330    cusip: Option<String>,
331    /// Filter by country name or alpha code, e.g., `United States` or `US`
332    country: Option<String>,
333    /// Number of decimal places for floating values. Accepts value in range [0,11]
334    dp: Option<i64>
335}
336
337impl GetEtfsWorldRiskParamsBuilder {
338    /// Symbol ticker of etf
339    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
340        self.symbol = Some(symbol.into());
341        
342        self
343    }
344    /// Filter by financial instrument global identifier (FIGI)
345    pub fn figi(mut self, figi: impl Into<String>) -> Self {
346        self.figi = Some(figi.into());
347        
348        self
349    }
350    /// Filter by international securities identification number (ISIN)
351    pub fn isin(mut self, isin: impl Into<String>) -> Self {
352        self.isin = Some(isin.into());
353        
354        self
355    }
356    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
357    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
358        self.cusip = Some(cusip.into());
359        
360        self
361    }
362    /// Filter by country name or alpha code, e.g., `United States` or `US`
363    pub fn country(mut self, country: impl Into<String>) -> Self {
364        self.country = Some(country.into());
365        
366        self
367    }
368    /// Number of decimal places for floating values. Accepts value in range [0,11]
369    pub fn dp(mut self, dp: i64) -> Self {
370        
371        self.dp = Some(dp);
372        
373        self
374    }
375
376    /// Build the parameter struct
377    pub fn build(self) -> GetEtfsWorldRiskParams {
378        GetEtfsWorldRiskParams {
379            symbol: self.symbol,
380            figi: self.figi,
381            isin: self.isin,
382            cusip: self.cusip,
383            country: self.country,
384            dp: self.dp
385        }
386    }
387}
388
389/// struct for passing parameters to the method [`get_etfs_world_summary`]
390#[derive(Clone, Debug, Default)]
391pub struct GetEtfsWorldSummaryParams {
392    /// Symbol ticker of etf
393    pub symbol: Option<String>,
394    /// Filter by financial instrument global identifier (FIGI)
395    pub figi: Option<String>,
396    /// Filter by international securities identification number (ISIN)
397    pub isin: Option<String>,
398    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
399    pub cusip: Option<String>,
400    /// Filter by country name or alpha code, e.g., `United States` or `US`
401    pub country: Option<String>,
402    /// Number of decimal places for floating values. Accepts value in range [0,11]
403    pub dp: Option<i64>
404}
405
406impl GetEtfsWorldSummaryParams {
407    /// Create a new builder for this parameter struct
408    pub fn builder() -> GetEtfsWorldSummaryParamsBuilder {
409        GetEtfsWorldSummaryParamsBuilder::default()
410    }
411}
412
413/// Builder for [`GetEtfsWorldSummaryParams`]
414#[derive(Clone, Debug, Default)]
415pub struct GetEtfsWorldSummaryParamsBuilder {
416    /// Symbol ticker of etf
417    symbol: Option<String>,
418    /// Filter by financial instrument global identifier (FIGI)
419    figi: Option<String>,
420    /// Filter by international securities identification number (ISIN)
421    isin: Option<String>,
422    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
423    cusip: Option<String>,
424    /// Filter by country name or alpha code, e.g., `United States` or `US`
425    country: Option<String>,
426    /// Number of decimal places for floating values. Accepts value in range [0,11]
427    dp: Option<i64>
428}
429
430impl GetEtfsWorldSummaryParamsBuilder {
431    /// Symbol ticker of etf
432    pub fn symbol(mut self, symbol: impl Into<String>) -> Self {
433        self.symbol = Some(symbol.into());
434        
435        self
436    }
437    /// Filter by financial instrument global identifier (FIGI)
438    pub fn figi(mut self, figi: impl Into<String>) -> Self {
439        self.figi = Some(figi.into());
440        
441        self
442    }
443    /// Filter by international securities identification number (ISIN)
444    pub fn isin(mut self, isin: impl Into<String>) -> Self {
445        self.isin = Some(isin.into());
446        
447        self
448    }
449    /// The CUSIP of an instrument for which data is requested. CUSIP access is activating in the <a href=\"https://twelvedata.com/account/add-ons\">Add-ons</a> section
450    pub fn cusip(mut self, cusip: impl Into<String>) -> Self {
451        self.cusip = Some(cusip.into());
452        
453        self
454    }
455    /// Filter by country name or alpha code, e.g., `United States` or `US`
456    pub fn country(mut self, country: impl Into<String>) -> Self {
457        self.country = Some(country.into());
458        
459        self
460    }
461    /// Number of decimal places for floating values. Accepts value in range [0,11]
462    pub fn dp(mut self, dp: i64) -> Self {
463        
464        self.dp = Some(dp);
465        
466        self
467    }
468
469    /// Build the parameter struct
470    pub fn build(self) -> GetEtfsWorldSummaryParams {
471        GetEtfsWorldSummaryParams {
472            symbol: self.symbol,
473            figi: self.figi,
474            isin: self.isin,
475            cusip: self.cusip,
476            country: self.country,
477            dp: self.dp
478        }
479    }
480}
481
482
483/// struct for typed errors of method [`get_etfs_world`]
484#[derive(Debug, Clone, Serialize, Deserialize)]
485#[serde(untagged)]
486pub enum GetEtfsWorldError {
487    UnknownValue(serde_json::Value),
488}
489
490/// struct for typed errors of method [`get_etfs_world_composition`]
491#[derive(Debug, Clone, Serialize, Deserialize)]
492#[serde(untagged)]
493pub enum GetEtfsWorldCompositionError {
494    UnknownValue(serde_json::Value),
495}
496
497/// struct for typed errors of method [`get_etfs_world_performance`]
498#[derive(Debug, Clone, Serialize, Deserialize)]
499#[serde(untagged)]
500pub enum GetEtfsWorldPerformanceError {
501    UnknownValue(serde_json::Value),
502}
503
504/// struct for typed errors of method [`get_etfs_world_risk`]
505#[derive(Debug, Clone, Serialize, Deserialize)]
506#[serde(untagged)]
507pub enum GetEtfsWorldRiskError {
508    UnknownValue(serde_json::Value),
509}
510
511/// struct for typed errors of method [`get_etfs_world_summary`]
512#[derive(Debug, Clone, Serialize, Deserialize)]
513#[serde(untagged)]
514pub enum GetEtfsWorldSummaryError {
515    UnknownValue(serde_json::Value),
516}
517
518
519/// The ETF full data endpoint provides detailed information about global Exchange-Traded Funds. It returns comprehensive data, including a summary, performance metrics, risk assessment, and composition details. This endpoint is ideal for users seeking an in-depth analysis of worldwide ETFs, enabling them to access key financial metrics and portfolio breakdowns.
520pub async fn get_etfs_world(configuration: &configuration::Configuration, params: GetEtfsWorldParams) -> Result<models::GetEtfsWorld200Response, Error<GetEtfsWorldError>> {
521    // Extract parameters from params struct
522    let p_query_symbol = params.symbol;
523    let p_query_figi = params.figi;
524    let p_query_isin = params.isin;
525    let p_query_cusip = params.cusip;
526    let p_query_country = params.country;
527    let p_query_dp = params.dp;
528
529    let uri_str = format!("{}/etfs/world", configuration.base_path);
530    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
531
532    if let Some(ref param_value) = p_query_symbol {
533        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
534    }
535    if let Some(ref param_value) = p_query_figi {
536        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
537    }
538    if let Some(ref param_value) = p_query_isin {
539        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
540    }
541    if let Some(ref param_value) = p_query_cusip {
542        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
543    }
544    if let Some(ref param_value) = p_query_country {
545        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
546    }
547    if let Some(ref param_value) = p_query_dp {
548        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
549    }
550    if let Some(ref user_agent) = configuration.user_agent {
551        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
552    }
553    if let Some(ref apikey) = configuration.api_key {
554        let key = apikey.key.clone();
555        let value = match apikey.prefix {
556            Some(ref prefix) => format!("{} {}", prefix, key),
557            None => key,
558        };
559        req_builder = req_builder.header("Authorization", value);
560    };
561
562    let req = req_builder.build()?;
563    let resp = configuration.client.execute(req).await?;
564
565    let status = resp.status();
566    let content_type = resp
567        .headers()
568        .get("content-type")
569        .and_then(|v| v.to_str().ok())
570        .unwrap_or("application/octet-stream");
571    let content_type = super::ContentType::from(content_type);
572
573    if !status.is_client_error() && !status.is_server_error() {
574        let content = resp.text().await?;
575        match content_type {
576            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
577            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEtfsWorld200Response`"))),
578            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEtfsWorld200Response`")))),
579        }
580    } else {
581        let content = resp.text().await?;
582        let entity: Option<GetEtfsWorldError> = serde_json::from_str(&content).ok();
583        Err(Error::ResponseError(ResponseContent { status, content, entity }))
584    }
585}
586
587/// The ETFs composition endpoint provides detailed information about the composition of global Exchange-Traded Funds. It returns data on the sectors included in the ETF, specific holding details, and the weighted exposure of each component. This endpoint is useful for users who need to understand the specific makeup and sector distribution of an ETF portfolio.
588pub async fn get_etfs_world_composition(configuration: &configuration::Configuration, params: GetEtfsWorldCompositionParams) -> Result<models::GetEtfsWorldComposition200Response, Error<GetEtfsWorldCompositionError>> {
589    // Extract parameters from params struct
590    let p_query_symbol = params.symbol;
591    let p_query_figi = params.figi;
592    let p_query_isin = params.isin;
593    let p_query_cusip = params.cusip;
594    let p_query_country = params.country;
595    let p_query_dp = params.dp;
596
597    let uri_str = format!("{}/etfs/world/composition", configuration.base_path);
598    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
599
600    if let Some(ref param_value) = p_query_symbol {
601        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
602    }
603    if let Some(ref param_value) = p_query_figi {
604        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
605    }
606    if let Some(ref param_value) = p_query_isin {
607        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
608    }
609    if let Some(ref param_value) = p_query_cusip {
610        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
611    }
612    if let Some(ref param_value) = p_query_country {
613        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
614    }
615    if let Some(ref param_value) = p_query_dp {
616        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
617    }
618    if let Some(ref user_agent) = configuration.user_agent {
619        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
620    }
621    if let Some(ref apikey) = configuration.api_key {
622        let key = apikey.key.clone();
623        let value = match apikey.prefix {
624            Some(ref prefix) => format!("{} {}", prefix, key),
625            None => key,
626        };
627        req_builder = req_builder.header("Authorization", value);
628    };
629
630    let req = req_builder.build()?;
631    let resp = configuration.client.execute(req).await?;
632
633    let status = resp.status();
634    let content_type = resp
635        .headers()
636        .get("content-type")
637        .and_then(|v| v.to_str().ok())
638        .unwrap_or("application/octet-stream");
639    let content_type = super::ContentType::from(content_type);
640
641    if !status.is_client_error() && !status.is_server_error() {
642        let content = resp.text().await?;
643        match content_type {
644            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
645            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEtfsWorldComposition200Response`"))),
646            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEtfsWorldComposition200Response`")))),
647        }
648    } else {
649        let content = resp.text().await?;
650        let entity: Option<GetEtfsWorldCompositionError> = serde_json::from_str(&content).ok();
651        Err(Error::ResponseError(ResponseContent { status, content, entity }))
652    }
653}
654
655/// The ETFs performance endpoint provides comprehensive performance data for exchange-traded funds globally. It returns detailed metrics such as trailing returns and annual returns, enabling users to evaluate the historical performance of various ETFs. This endpoint is ideal for users looking to compare ETF performance over different time periods and assess their investment potential.
656pub async fn get_etfs_world_performance(configuration: &configuration::Configuration, params: GetEtfsWorldPerformanceParams) -> Result<models::GetEtfsWorldPerformance200Response, Error<GetEtfsWorldPerformanceError>> {
657    // Extract parameters from params struct
658    let p_query_symbol = params.symbol;
659    let p_query_figi = params.figi;
660    let p_query_isin = params.isin;
661    let p_query_cusip = params.cusip;
662    let p_query_country = params.country;
663    let p_query_dp = params.dp;
664
665    let uri_str = format!("{}/etfs/world/performance", configuration.base_path);
666    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
667
668    if let Some(ref param_value) = p_query_symbol {
669        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
670    }
671    if let Some(ref param_value) = p_query_figi {
672        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
673    }
674    if let Some(ref param_value) = p_query_isin {
675        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
676    }
677    if let Some(ref param_value) = p_query_cusip {
678        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
679    }
680    if let Some(ref param_value) = p_query_country {
681        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
682    }
683    if let Some(ref param_value) = p_query_dp {
684        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
685    }
686    if let Some(ref user_agent) = configuration.user_agent {
687        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
688    }
689    if let Some(ref apikey) = configuration.api_key {
690        let key = apikey.key.clone();
691        let value = match apikey.prefix {
692            Some(ref prefix) => format!("{} {}", prefix, key),
693            None => key,
694        };
695        req_builder = req_builder.header("Authorization", value);
696    };
697
698    let req = req_builder.build()?;
699    let resp = configuration.client.execute(req).await?;
700
701    let status = resp.status();
702    let content_type = resp
703        .headers()
704        .get("content-type")
705        .and_then(|v| v.to_str().ok())
706        .unwrap_or("application/octet-stream");
707    let content_type = super::ContentType::from(content_type);
708
709    if !status.is_client_error() && !status.is_server_error() {
710        let content = resp.text().await?;
711        match content_type {
712            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
713            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEtfsWorldPerformance200Response`"))),
714            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEtfsWorldPerformance200Response`")))),
715        }
716    } else {
717        let content = resp.text().await?;
718        let entity: Option<GetEtfsWorldPerformanceError> = serde_json::from_str(&content).ok();
719        Err(Error::ResponseError(ResponseContent { status, content, entity }))
720    }
721}
722
723/// The ETFs risk endpoint provides essential risk metrics for global Exchange Traded Funds. It returns data such as volatility, beta, and other risk-related indicators, enabling users to assess the potential risk associated with investing in various ETFs worldwide.
724pub async fn get_etfs_world_risk(configuration: &configuration::Configuration, params: GetEtfsWorldRiskParams) -> Result<models::GetEtfsWorldRisk200Response, Error<GetEtfsWorldRiskError>> {
725    // Extract parameters from params struct
726    let p_query_symbol = params.symbol;
727    let p_query_figi = params.figi;
728    let p_query_isin = params.isin;
729    let p_query_cusip = params.cusip;
730    let p_query_country = params.country;
731    let p_query_dp = params.dp;
732
733    let uri_str = format!("{}/etfs/world/risk", configuration.base_path);
734    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
735
736    if let Some(ref param_value) = p_query_symbol {
737        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
738    }
739    if let Some(ref param_value) = p_query_figi {
740        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
741    }
742    if let Some(ref param_value) = p_query_isin {
743        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
744    }
745    if let Some(ref param_value) = p_query_cusip {
746        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
747    }
748    if let Some(ref param_value) = p_query_country {
749        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
750    }
751    if let Some(ref param_value) = p_query_dp {
752        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
753    }
754    if let Some(ref user_agent) = configuration.user_agent {
755        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
756    }
757    if let Some(ref apikey) = configuration.api_key {
758        let key = apikey.key.clone();
759        let value = match apikey.prefix {
760            Some(ref prefix) => format!("{} {}", prefix, key),
761            None => key,
762        };
763        req_builder = req_builder.header("Authorization", value);
764    };
765
766    let req = req_builder.build()?;
767    let resp = configuration.client.execute(req).await?;
768
769    let status = resp.status();
770    let content_type = resp
771        .headers()
772        .get("content-type")
773        .and_then(|v| v.to_str().ok())
774        .unwrap_or("application/octet-stream");
775    let content_type = super::ContentType::from(content_type);
776
777    if !status.is_client_error() && !status.is_server_error() {
778        let content = resp.text().await?;
779        match content_type {
780            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
781            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEtfsWorldRisk200Response`"))),
782            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEtfsWorldRisk200Response`")))),
783        }
784    } else {
785        let content = resp.text().await?;
786        let entity: Option<GetEtfsWorldRiskError> = serde_json::from_str(&content).ok();
787        Err(Error::ResponseError(ResponseContent { status, content, entity }))
788    }
789}
790
791/// The ETFs summary endpoint provides a concise overview of global Exchange-Traded Funds. It returns key data points such as ETF names, symbols, and current market values, enabling users to quickly assess the performance and status of various international ETFs. This summary is ideal for users who need a snapshot of the global ETF landscape without delving into detailed analysis.
792pub async fn get_etfs_world_summary(configuration: &configuration::Configuration, params: GetEtfsWorldSummaryParams) -> Result<models::GetEtfsWorldSummary200Response, Error<GetEtfsWorldSummaryError>> {
793    // Extract parameters from params struct
794    let p_query_symbol = params.symbol;
795    let p_query_figi = params.figi;
796    let p_query_isin = params.isin;
797    let p_query_cusip = params.cusip;
798    let p_query_country = params.country;
799    let p_query_dp = params.dp;
800
801    let uri_str = format!("{}/etfs/world/summary", configuration.base_path);
802    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
803
804    if let Some(ref param_value) = p_query_symbol {
805        req_builder = req_builder.query(&[("symbol", &param_value.to_string())]);
806    }
807    if let Some(ref param_value) = p_query_figi {
808        req_builder = req_builder.query(&[("figi", &param_value.to_string())]);
809    }
810    if let Some(ref param_value) = p_query_isin {
811        req_builder = req_builder.query(&[("isin", &param_value.to_string())]);
812    }
813    if let Some(ref param_value) = p_query_cusip {
814        req_builder = req_builder.query(&[("cusip", &param_value.to_string())]);
815    }
816    if let Some(ref param_value) = p_query_country {
817        req_builder = req_builder.query(&[("country", &param_value.to_string())]);
818    }
819    if let Some(ref param_value) = p_query_dp {
820        req_builder = req_builder.query(&[("dp", &param_value.to_string())]);
821    }
822    if let Some(ref user_agent) = configuration.user_agent {
823        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
824    }
825    if let Some(ref apikey) = configuration.api_key {
826        let key = apikey.key.clone();
827        let value = match apikey.prefix {
828            Some(ref prefix) => format!("{} {}", prefix, key),
829            None => key,
830        };
831        req_builder = req_builder.header("Authorization", value);
832    };
833
834    let req = req_builder.build()?;
835    let resp = configuration.client.execute(req).await?;
836
837    let status = resp.status();
838    let content_type = resp
839        .headers()
840        .get("content-type")
841        .and_then(|v| v.to_str().ok())
842        .unwrap_or("application/octet-stream");
843    let content_type = super::ContentType::from(content_type);
844
845    if !status.is_client_error() && !status.is_server_error() {
846        let content = resp.text().await?;
847        match content_type {
848            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
849            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetEtfsWorldSummary200Response`"))),
850            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetEtfsWorldSummary200Response`")))),
851        }
852    } else {
853        let content = resp.text().await?;
854        let entity: Option<GetEtfsWorldSummaryError> = serde_json::from_str(&content).ok();
855        Err(Error::ResponseError(ResponseContent { status, content, entity }))
856    }
857}
858