Struct quandl_v3::prelude::BatchQuery [] [src]

pub struct BatchQuery<A, T> where
    T: DeserializeOwned + Clone + Sync + Send + 'static,
    A: ApiCall<T> + Clone + Sync + Send + 'static, 
{ /* fields omitted */ }

Builder pattern run multiple queries in batch.

The data is downloaded from the Quandl servers asynchronously. It does so by returning an Iterator which return the Result from each individual query in the order they are fed to the query and queries methods.

When batch downloading, it is important to keep Quandl's API limits in mind. Please read the documentation for methods limit and concurrent_calls for more information.

Methods

impl<A, T> BatchQuery<A, T> where
    T: DeserializeOwned + Clone + Sync + Send + 'static,
    A: ApiCall<T> + Clone + Sync + Send + 'static, 
[src]

Construct a new (empty) BatchQuery with default state.

Assume that every API keys has already been used the specified number of times.

This is an hackish way to send a big batch query underway immediately even if some API keys have been used a small number of times (e.g. for testing purposes). This is obviously suboptimal and a future version of this library might provide stateful API keys which hold information about their usage and can be saved/retrieved from disk to always be used as efficiently as possible.

Specify some download rate limits for this batch query.

From the beginning of 2017, some heavy restrictions applies to non-premium API keys, namely:

  • Up to 300 API calls can be made with a single key within 10 seconds.
  • Up to 2,000 API calls can be made with a single key within 10 minutes (600 seconds).
  • Up to 50,000 API calls can be made with a single key within a day (86,400 seconds).

For premium keys the limits are as follow:

  • Up to 5,000 API calls can be made with a single key within 10 minutes (600 seconds).
  • Up to 720,000 API calls can be made with a single key within a day (86,400 seconds).

Not using an API key at all yield the most restrictive access:

  • Up to 20 API calls by 10 minutes (600 seconds).
  • Up to 50 API calls within a day (86,400 seconds).

This method allow to specify those limits in a future-proof fashion (the limits could change at any time and this library does not handle it for this reason).

For example, if not using any key, you would use this method as follow:

extern crate quandl_v3;

use quandl_v3::Result;
use quandl_v3::prelude::*;

fn main() {
    let mut batch_query = BatchQuery::new();

    batch_query
        .query(DatabaseMetadataQuery::new("ICE"))
        .query(DatabaseMetadataQuery::new("WIKI"))
        .limit(20, 600)
        .limit(50, 86_400);

    let result: Vec<_> = batch_query.run().collect();
}

Add a single query to this batch.

Add a slice of queries to this batch.

Specify the maximum number of threads to use.

By default the number of logical cores is used. The number of threads specified must be bigger than 0.

Whether to allow concurrent calls to the API with a single key.

This usage of the Quandl API is forbidden for non-premium keys but allowed for premium users. Thus this method should only be called on your batch if you are strictly using premium keys.

Execute the batch query and return an iterator which asynchronously fetch the data.