/// <summary> /// You can retrieve metadata for a specified time-series database. /// <a href="https://docs.quandl.com/docs/in-depth-usage#section-get-metadata-for-a-time-series-database">Reference</a> /// </summary> /// <param name="databaseCode">Code identifying the database to which the dataset belongs.</param> /// <param name="returnFormat">Return format</param> /// <param name="token">Cancellation token</param> /// <returns>Metadata for a specified time-series database</returns> public async Task <Stream> GetDatabaseMetadataAsync(string databaseCode, ReturnFormat returnFormat, CancellationToken token = default(CancellationToken)) { try { return(await $"{Constant.HostUri}/databases/{databaseCode}.{returnFormat.ToEnumMemberValue()}" .SetQueryParam("api_key", _apiKey) .GetAsync(token) .ReceiveStream() .ConfigureAwait(false)); } catch (FlurlHttpException ex) { throw ex.ToQuandlException(); } }
/// <summary> /// You can filter on both rows and columns by appending both filter types to your API request. /// <a href="https://docs.quandl.com/docs/in-depth-usage-1#section-filter-rows-and-columns">Reference</a> /// </summary> /// <param name="datatableCode">Short code for datatable</param> /// <param name="returnFormat">Return format</param> /// <param name="rowFilterCriteria">Criteria to filter row, value is ampersand-seperated.</param> /// <param name="columnFilterCriteria">Criteria to filter column, value is comma-seperated.</param> /// <param name="export">Good for large queries; the data requested will be packaged into a zip file for download.</param> /// <param name="perPage">The number of results per page that can be returned, to a maximum of 10,000 rows. (Large tables will be displayed over several pages.)</param> /// <param name="cursorId">Each API call returns a unique cursor ID that identifies the next page of the table. Including the cursor ID in your API call will allow you to page through the table. A null cursor ID means that the current page will be the last page of the table. For more on downloading entire tables, click here.</param> /// <param name="token">Cancellation token</param> /// <returns>Filtered table</returns> public async Task <Stream> GetAsync(string datatableCode, ReturnFormat returnFormat, string rowFilterCriteria = null, string columnFilterCriteria = null, bool?export = null, int?perPage = null, int?cursorId = null, CancellationToken token = default(CancellationToken)) { try { return(await $"{Constant.HostUri}/datatables/{datatableCode}.{returnFormat.ToEnumMemberValue()}" .SetQueryParamForEach(Filter.Parse(rowFilterCriteria)) .SetQueryParam("qopts.columns", columnFilterCriteria) .SetQueryParam("qopts.export", export) .SetQueryParam("qopts.per_page", perPage) .SetQueryParam("qopts.cursor_id", cursorId) .SetQueryParam("api_key", _apiKey) .GetAsync(token) .ReceiveStream() .ConfigureAwait(false)); } catch (FlurlHttpException ex) { throw ex.ToQuandlException(); } }
/// <summary> /// You can slice, transform and otherwise customize your time-series dataset prior to download by appending various optional parameters to your query. /// <a href="https://docs.quandl.com/docs/in-depth-usage#section-get-filtered-time-series-data">Reference</a> /// </summary> /// <param name="databaseCode">Code identifying the database to which the dataset belongs.</param> /// <param name="datasetCode">Code identifying the dataset.</param> /// <param name="returnFormat">Return format</param> /// <param name="limit">Use limit=n to get the first n rows of the dataset. Use limit=1 to get just the latest row.</param> /// <param name="columnIndex">Request a specific column. Column 0 is the date column and is always returned. Data begins at column 1.</param> /// <param name="startDate">Retrieve data rows on and after the specified start date.</param> /// <param name="endDate">Retrieve data rows up to and including the specified end date.</param> /// <param name="order">Return data in ascending or descending order of date. Default is desc.</param> /// <param name="collapse">Change the sampling frequency of the returned data. Default is none; i.e., data is returned in its original granularity.</param> /// <param name="transform">Perform elementary calculations on the data prior to downloading. Default is none. Calculation options are described below.</param> /// <param name="token">Cancellation token</param> /// <returns>Data from a specified time-series</returns> public async Task <Stream> GetDataAsync(string databaseCode, string datasetCode, ReturnFormat returnFormat, int?limit = null, int?columnIndex = null, DateTime?startDate = null, DateTime?endDate = null, Order?order = null, Collapse?collapse = null, Transform?transform = null, CancellationToken token = default(CancellationToken)) { try { return(await $"{Constant.HostUri}/datasets/{databaseCode}/{datasetCode}/data.{returnFormat.ToEnumMemberValue()}" .SetQueryParam("limit", limit) .SetQueryParam("column_index", columnIndex) .SetQueryParam("start_date", startDate?.ToString("yyyy-MM-dd")) .SetQueryParam("end_date", endDate?.ToString("yyyy-MM-dd")) .SetQueryParam("order", order.ToEnumMemberValue()) .SetQueryParam("collapse", collapse.ToEnumMemberValue()) .SetQueryParam("transform", transform.ToEnumMemberValue()) .SetQueryParam("api_key", _apiKey) .GetAsync(token) .ReceiveStream() .ConfigureAwait(false)); } catch (FlurlHttpException ex) { throw ex.ToQuandlException(); } }