Skip to content

Conversation

@HermanKoii
Copy link
Owner

@HermanKoii HermanKoii commented Jun 5, 2025

Implement CoinGecko API Client with Cryptocurrency Data Retrieval

Description

Task

Create a coin gekko api

Acceptance Criteria

  • API can fetch a list of cryptocurrencies
  • API can retrieve details for a specific cryptocurrency
  • API handles errors gracefully
  • Implementation uses TypeScript
  • Unit tests provide comprehensive coverage

Summary of Work

CoinGecko API Client Implementation

Overview

This pull request implements a robust CoinGecko API client that allows fetching cryptocurrency data with comprehensive error handling and type safety.

Key Features

  • Fetch list of cryptocurrencies with customizable limit
  • Retrieve detailed information for a specific cryptocurrency
  • Full TypeScript type definitions
  • Error handling for network and data retrieval issues

Implementation Details

  1. CoinGekkoApi class with two primary methods:
    • getCoinList(limit?: number):
      • Retrieves top cryptocurrencies sorted by market cap
      • Default limit of 100 coins
      • Supports customizable limit
    • getCoinById(id: string):
      • Fetches detailed information for a specific cryptocurrency
      • Returns null for non-existent coins
      • Validates input coin ID

Technical Specifications

  • Uses axios for HTTP requests
  • TypeScript interface CoinData for type-safe data handling
  • Default CoinGecko API base URL with configurable option
  • Comprehensive error logging

Testing Approach

  • Unit tests cover successful data retrieval
  • Error scenarios tested, including:
    • Network failures
    • Non-existent coin lookups
    • Invalid input validation

Acceptance Criteria

✅ Fetch list of cryptocurrencies
✅ Retrieve individual cryptocurrency details
✅ Proper error handling
✅ TypeScript type definitions
✅ Comprehensive unit test coverage

Changes Made

  • Created CoinGekkoApi class in src/index.ts
  • Implemented getCoinList method to fetch cryptocurrency list
  • Implemented getCoinById method to fetch specific cryptocurrency details
  • Added TypeScript interface for CoinData
  • Created comprehensive unit tests in src/index.spec.ts

Tests

  • Verify getCoinList returns correct cryptocurrency data
  • Verify getCoinList handles request limit correctly
  • Verify getCoinById returns correct coin details
  • Verify getCoinById returns null for non-existent coins
  • Verify error handling for network failures

Signatures

Staking Key

0x1234567890123456789012345678901234567890: 0x1234567890123456789012345678901234567890

Public Key

0x1234567890123456789012345678901234567890: 0x1234567890123456789012345678901234567890

@HermanKoii HermanKoii changed the title [WIP] Implement Coin Gekko API Integration Implement CoinGecko API Client with Cryptocurrency Data Retrieval Jun 5, 2025
@HermanKoii HermanKoii marked this pull request as ready for review June 5, 2025 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants