Coder Social home page Coder Social logo

alphavantage's Introduction

Rust client for the Alpha Vantage API

A Rust wrapper for the Alpha Vantage API. It can be used to access the data from four categories:

  • Time Series Stock data
  • Fundamental Data (different financial data points)
  • Physical and Digital/Crypto Currencies
  • Technical Indicators

For more information, visit the official Alpha Vantage API Documentation. Note: According to the FAQ section every wrapper/library has to provide the original response of the Alpha Vantage API to library users. The methods of this wrapper returns a Result<JsonObject, AlphavantageError>. The JsonObject is just a serde_json::Map<String, serde_json::Value> and includes the original response as a JSON object. In case of an network or parsing error, an AlphavantageError is returned.

Usage

You can choose an HTTP client depending on your needs. Currently, reqwest and ureq are supported. ureq is the default. To use reqwest, disable the default features (see the cargo reference), and enable the reqwest-lib feature. These HTTP clients are publicly exported by this crate so you don't need to add them to your dependencies.

If for some reason another HTTP client is better suited for your purposes you can implement the RequestClient trait for this HTTP client (e. g. using a new type).

You can then construct an AlphavantageClient with AlphavantageClient::new(apikey, client) where the apikey is your Alpha Vantage API key and client is an instance of your chosen HTTP client. The AlphavantageClient implementations a trait for each of the API categories as listed above and has a method for each of the request endpoints. The below example uses the ureq HTTP client to query the Alpha Vantage API for stock symbols matching the string "test" (using the endpoint documented at here).

use alphavantage::*;

fn main() {
    let result = AlphavantageClient::new("demo", UreqClient).search_endpoint("test");
    dbg!(result);
}

alphavantage's People

Contributors

etaloof avatar

Watchers

 avatar

alphavantage's Issues

Add license

This project should be licensed under MIT.

Improve error handling

Currently, all errors are handled by panicking. A custom error type could be used to pass errors to library users. To reduce boilerplate the thiserror crate seems like a good choice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.