Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Goingecko

Coingecko API client for golang.

<p align="center">
<img src="docs/images/goingecko_logo.png" alt="goingecko" height="200" />
</p>
Expand Down
2 changes: 1 addition & 1 deletion api/coins/types/markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Market struct {
Image string `json:"image"`
CurrentPrice float64 `json:"current_price"`
MarketCap float64 `json:"market_cap"`
MarkeCcapRank int64 `json:"market_cap_rank"`
MarketCapRank int64 `json:"market_cap_rank"`
FullyDilutedValuation float64 `json:"fully_diluted_valuation"`
TotalVolume float64 `json:"total_volume"`
HighDay float64 `json:"high_24h"`
Expand Down
5 changes: 1 addition & 4 deletions http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ func (c *Client) MakeReq(ctx context.Context, url string) ([]byte, error) {
}

if code != http.StatusOK {
return nil, &APIError{
StatusCode: code,
Body: resp,
}
return nil, NewAPIError(code, resp)
}

return resp, nil
Expand Down
8 changes: 8 additions & 0 deletions http/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ type APIError struct {
func (e *APIError) Error() string {
return fmt.Sprintf("api returned status code %d", e.StatusCode)
}

// NewAPIError returns a new APIError
func NewAPIError(status int, body []byte) *APIError {
return &APIError{
StatusCode: status,
Body: body,
}
}
2 changes: 1 addition & 1 deletion http/rateLimitedClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (c *RateLimitedClient) MakeReq(ctx context.Context, url string) ([]byte, er
}
// Check if this is a 429 error (rate limit exceeded)
var apiErr *APIError
if errors.As(err, &apiErr) && apiErr.StatusCode == 429 {
if errors.As(err, &apiErr) && apiErr.StatusCode == http.StatusTooManyRequests {
if attempt < c.retryPolicy.maxRetries {
// Calculate exponential backoff delay
delay := c.retryPolicy.baseDelay * time.Duration(1<<attempt) // 2s, 4s, 8s, 16s, 32s
Expand Down