Git Product home page Git Product logo

coincap4j's Introduction

   _____      _        _____           _  _       _ 
  / ____|    (_)      / ____|         | || |     | |
 | |     ___  _ _ __ | |     __ _ _ __| || |_    | |
 | |    / _ \| | '_ \| |    / _` | '_ \__   _|   | |
 | |___| (_) | | | | | |___| (_| | |_) | | || |__| |
  \_____\___/|_|_| |_|\_____\__,_| .__/  |_| \____/ 
                             | |                
                             |_|                

CoinCap4J is a Java wrapper around the api provided by https://github.com/CoinCapDev/CoinCap.io

To use Coin4J simply call:

    CoinCap4j cc4j = CoinCap4j.instance();

Each method returning coincap data return an Eitherobject, which has the following interface:

	public <T> T map(Function<? super L, ? extends T> lFunc, Function<? super R, ? extends T> rFunc);
	
	/**
	 * Checks if there is a left value.
	 * @return
	 */
	public boolean isLeftPresent();
	/**
	 * Returns the left value if present or null if not present.
	 * @return
	 */
	public L getLeft();
	/**
	 * Returns the left value if present or passed value if not present.
	 * @param valueIfNotPresent
	 * @return
	 */
	public L getLeft(L valueIfNotPresent);
	
	/**
	 * Checks if there is a left value.
	 * @return
	 */
	public boolean isRightPresent();
	/**
	 * Returns the right value if present or null if not present.
	 * @return
	 */
	public R getRight();
	/**
	 * Returns the right value if present or passed value if not present.
	 * @param valueIfNotPresent
	 * @return
	 */
	public R getRight(R valueIfNotPresent);

	public <T> Either<T, R> mapLeft(Function<? super L, ? extends T> lFunc);

	public <T> Either<L, T> mapRight(Function<? super R, ? extends T> lFunc);

	public void apply(Consumer<? super L> lFunc, Consumer<? super R> rFunc);
  • Following is a list of api endpoint and their corresponding method calls:
        // http://coincap.io/coins
    public Either<List<String>, Exception> getCoinsListShort();

        // http://coincap.io/map
    public Either<List<CoinMap>, Exception> getCoinsMap();

        // http://coincap.io/front
    public Either<List<FrontCoinData>, Exception> getFrontCoinData();

       // http://coincap.io/global
    public Either<GlobalData, Exception> getGlobalData();
      
      // http://coincap.io/page/:coin
    public Either<Coin, Exception> getCoin(String symbol);

      // for getting multiple coins
    public List<Either<Coin, Exception>> getCoins(List<String> coins);

    // for getting the history of a coin http://coincap.io/history/:coin you use

    HistoryBuilder hb = cc4j.history(coin);
    // for the period you basically call:
    hb.day()
    hb.week()
    hb.month()
    hb.quaterly()
    hb.halfYear()
    hb.year()

    // for accessing socket data you can use one of the following methods on the CoinCap4J instance
    public void trades(Consumer<JSONObject> dataConsumer) throws URISyntaxException
    public void tradesData(Consumer<Either<TradeData, Exception>> dataConsumer) throws URISyntaxException

coincap4j's People

Contributors

aleksandaraleksandrov avatar

Watchers

Amir Omidi avatar  avatar

Forkers

nexaios abramdy

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.