Code Monkey home page Code Monkey logo

coingecko-java's People

Contributors

bigscoop avatar eclaesson avatar fabianpol avatar flamingo1332 avatar focamacho avatar jansoren avatar mariusbaisan avatar philipinho avatar vorburger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coingecko-java's Issues

Issue With getCoinHistoryById

Hello, I'm running into an issue when attempting to get historical data. The following line is producing errors:

CoinHistoryById bitcoinHistory = client.getCoinHistoryById("bitcoin","03-11-2021", false);

Here are the errors produced:

Exception in thread "main" com.litesoftwares.coingecko.exception.CoinGeckoApiException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type long from String "4557.92307692308": not a valid Long value
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 4953] (through reference chain: com.litesoftwares.coingecko.domain.Coins.CoinHistoryById["community_data"]->com.litesoftwares.coingecko.domain.Coins.CoinData.CommunityData["reddit_accounts_active_48h"])
at com.litesoftwares.coingecko.CoinGeckoApi.executeSync(CoinGeckoApi.java:44)
at com.litesoftwares.coingecko.impl.CoinGeckoApiClientImpl.getCoinHistoryById(CoinGeckoApiClientImpl.java:103)
at com.litesoftwares.coingecko.examples.myTest.main(myTest.java:23)
Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type long from String "4557.92307692308": not a valid Long value
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 4953] (through reference chain: com.litesoftwares.coingecko.domain.Coins.CoinHistoryById["community_data"]->com.litesoftwares.coingecko.domain.Coins.CoinData.CommunityData["reddit_accounts_active_48h"])
at com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1676)
at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:932)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer._parseLong(NumberDeserializers.java:584)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer.deserialize(NumberDeserializers.java:557)
at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer.deserialize(NumberDeserializers.java:535)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1719)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1244)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:33)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
at com.litesoftwares.coingecko.CoinGeckoApi.executeSync(CoinGeckoApi.java:31)
... 2 more

Process finished with exit code -1

Thank you for your time!

/coins/markets order field with hour_24_desc or hour_24_asc has no effecthour

image
When I tested the market interface on the official website, I found that sorting by hour_24_asc and hour_24_desc did not seem to work. The order of the two fields price_change_24h and price_change_percentage_24h in the interface return value is still confusing. I want to know which field is sorted by hour_24, if I want to sort by 24h increase and decrease, what should I do?

Call to get coin's OHLC (Open High Low Close)

Hi!
I am having some problems with the call to get OHLC of a given coin.

Since I didn't find this method in this project I tried to implement it following the current project style,
but I get the following error: CoinGeckoApiError(code=500, message=Internal Server Error)

I also tried to execute the call via URL from the Browser and it returns the requested values, so I think I've done something wrong in the Implementation.

Call By URL: https://api.coingecko.com/api/v3/coins/bitcoin/ohlc?vs_currency=usd&days=1

Code added in CoinGeckoApiService.java
s1

Code added in CoinGeckoApiClient.java
s2

Code added in CoinGeckoApiClientImpl.java
s3

Code used in a main to Test the implementation
s4

Error obtained
s5

Program won't terminate when running getPrice()

Here is what I am doing in my code:

public void getCoinValue() {
     CoinGeckoApiClient cg = new CoinGeckoApiClientImpl();
     Map<String, Map<String, Double>> res = cg.getPrice("bitcoin", Currency.USD);
     Double price = res.get(name).get("usd");

     System.out.println(price)
}

When I comment out the API call my program terminates correctly. Am I supposed to close the API connection or something, and if so how?

Thank you

Handle HTTP 429 error

Can you handle the 429 rate limited.

When you reached the rate limite coingeck doesn't handle the response as json response.

The response is HTML can you handle this error?
image

Improve this else in (com.litesoftwares.coingecko.CoinGeckoApi)

public T executeSync(Call call) {
try {
Response response = call.execute();
if (response.isSuccessful()) {
return response.body();
} else {
try {
CoinGeckoApiError apiError = getCoinGeckoApiError(response);
apiError.setCode(response.code());
throw new CoinGeckoApiException(apiError);
} catch (IOException e) {
throw new CoinGeckoApiException(response.toString(), e);
}
}
} catch (IOException e) {
throw new CoinGeckoApiException(e);
}
}

getCoinMarketChartRangeById bugged

Command getCoinMarketChartRangeById() is not working for any input other than "bitcoin".
e.g.
CoinGeckoApiClient client = new CoinGeckoApiClientImpl();
client.getCoinMarketChartRangeById("bitcoin", "eur",
String.valueOf(1412577232), String.valueOf(1422577232));

works as intended.

However

client.getCoinMarketChartRangeById("ethereum", "eur",
String.valueOf(1412577232), String.valueOf(1422577232));

returns empty fields.

This also applies to the "try it out" examples of the CoinGecko API doc webpage.

Override default client timeout

Hi,

It is possible to have custom timeout value available?

(Make it as configurable from property....)

com.litesoftwares.coingecko.exception.CoinGeckoApiException: java.net.SocketTimeoutException: timeout
at com.litesoftwares.coingecko.CoinGeckoApi.executeSync(CoinGeckoApi.java:62)
at com.litesoftwares.coingecko.impl.CoinGeckoApiClientImpl.getCoinMarkets(CoinGeckoApiClientImpl.java:73)
at com.litesoftwares.coingecko.examples.CoinsExample.main(CoinsExample.java:86)
Caused by: java.net.SocketTimeoutException: timeout
at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:678)
at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:686)
at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.java:154)
at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.java:136)
at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.java:115)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:43)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
at okhttp3.RealCall.execute(RealCall.java:81)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:188)
at com.litesoftwares.coingecko.CoinGeckoApi.executeSync(CoinGeckoApi.java:37)
... 2 more

Caused by: com.fasterxml.jackson.databind.JsonMappingException: timeout (through reference chain: java.util.ArrayList[107])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:390)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:361)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:371)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2033)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1458)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:122)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:217)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
at com.litesoftwares.coingecko.CoinGeckoApi.executeSync(CoinGeckoApi.java:37)
... 72 more
Caused by: java.net.SocketTimeoutException: timeout
at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:678)
at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:686)
at okhttp3.internal.http2.Http2Stream$FramingSource.read(Http2Stream.java:409)
at okhttp3.internal.connection.Exchange$ResponseBodySource.read(Exchange.java:286)
at okio.RealBufferedSource.read(RealBufferedSource.java:51)
at okio.RealBufferedSource.exhausted(RealBufferedSource.java:61)
at okio.InflaterSource.refill(InflaterSource.java:102)
at okio.InflaterSource.read(InflaterSource.java:62)
at okio.GzipSource.read(GzipSource.java:80)
at okio.RealBufferedSource.read(RealBufferedSource.java:51)
at okio.ForwardingSource.read(ForwardingSource.java:35)
at retrofit2.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:290)
at okio.RealBufferedSource$1.read(RealBufferedSource.java:447)
at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.base/java.io.InputStreamReader.read(InputStreamReader.java:185)
at okhttp3.ResponseBody$BomAwareReader.read(ResponseBody.java:263)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._loadMore(ReaderBasedJsonParser.java:255)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parseNumber2(ReaderBasedJsonParser.java:1533)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parseFloat(ReaderBasedJsonParser.java:1372)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parsePosNumber(ReaderBasedJsonParser.java:1347)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextFieldName(ReaderBasedJsonParser.java:974)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:331)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:355)
... 83 more

com.litesoftwares.coingecko.domain.Coins.CoinMarkets["fully_diluted_valuation"] wrong type

The value type of field fully_diluted_valuation should be double:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Numeric value (660670687127652139008) out of range of long (-9223372036854775808 - 9223372036854775807) at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 116882] (through reference chain: java.util.ArrayList[127]->com.litesoftwares.coingecko.domain.Coins.CoinMarkets["fully_diluted_valuation"]) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:390) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:349) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1822) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:326) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:355) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322) at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2033) at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1458) at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32) at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23) at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:122) at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:217) at retrofit2.OkHttpCall.execute(OkHttpCall.java:180) at com.litesoftwares.coingecko.CoinGeckoApi.executeSync(CoinGeckoApi.java:38) ... 10 more

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.