Skip to content

ozers/aws-sam-coin-lister

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸͺ™ AWS SAM Coin Lister

AWS SAM Node.js License PRs Welcome Maintenance Stars

🌟 A serverless cryptocurrency API built with AWS SAM and Lambda.

πŸ“Š Get real-time cryptocurrency data with DynamoDB caching for optimal performance.

graph TD
    Client[Client] -->|HTTP Request| APIGateway[API Gateway]
    APIGateway -->|Trigger| Lambda[Lambda Function]
    Lambda -->|Cache Check| DynamoDB[(DynamoDB Cache)]
    Lambda -->|Fetch Data| CoinGecko[CoinGecko API]
    Lambda -->|Update Cache| DynamoDB
    Lambda -->|Response| APIGateway
    APIGateway -->|JSON Response| Client

    style Client fill:#f9f,stroke:#333,stroke-width:2px
    style APIGateway fill:#ff9900,stroke:#333,stroke-width:2px
    style Lambda fill:#ff9900,stroke:#333,stroke-width:2px
    style DynamoDB fill:#ff9900,stroke:#333,stroke-width:2px
    style CoinGecko fill:#ff9900,stroke:#333,stroke-width:2px
Loading

πŸš€ Quick Start

# Clone & Install
git clone https://github.com/ozers/aws-sam-coin-lister.git
cd aws-sam-coin-lister/list-coins && npm install && cd ..

# Build & Deploy
sam build && sam deploy --guided

πŸ§ͺ Local Development

Method 1: Using SAM Local API

# Start local API
sam local start-api

# Test endpoints using curl
curl http://localhost:3000/coins/list
curl http://localhost:3000/coins/bitcoin
curl http://localhost:3000/coins/bitcoin/history

Method 2: Using Postman Collection

  1. Import the Postman collection:

    # Collection location
    docs/aws-sam-coin-lister.postman_collection.json
  2. Set up environment variables in Postman:

    • baseUrl: http://localhost:3000 (for local testing)
    • prodUrl: https://{api-id}.execute-api.{region}.amazonaws.com/Prod (for production)
  3. Available requests:

    • List All Coins: GET {{baseUrl}}/coins/list?page=1&per_page=100
    • Get Coin Details: GET {{baseUrl}}/coins/bitcoin
    • Get Coin History: GET {{baseUrl}}/coins/bitcoin/history

Method 3: Using Event Files

# Test with event file
sam local invoke ListCoinsFunction -e events/event.json

# Available test event
events/event.json           # List coins

🌐 API Endpoints

Endpoint Method Cache TTL Description
/ping GET 5 min Health check endpoint
/coins/list GET 30 min List all coins with pagination
/coins/{coinId} GET 5 min Get specific coin details
/coins/{coinId}/history GET 1 hour Get coin price history

πŸ“ Example Usage

# Health check
curl https://{api-id}.execute-api.{region}.amazonaws.com/Prod/ping

# List coins
curl https://{api-id}.execute-api.{region}.amazonaws.com/Prod/coins/list?page=1&per_page=100

# Get Bitcoin details
curl https://{api-id}.execute-api.{region}.amazonaws.com/Prod/coins/bitcoin

πŸ› οΈ Tech Stack

  • 🟦 Serverless: AWS SAM, Lambda, API Gateway
  • πŸ’Ύ Cache: DynamoDB
  • πŸ“Š Data: CoinGecko API
  • πŸ§ͺ Testing: Jest

πŸ“‹ Prerequisites

  • AWS Account & SAM CLI
  • Node.js 18.x
  • Docker (optional)
  • Postman (optional, for API testing)

🧹 Cleanup

# Delete stack
sam delete

# Verify
aws cloudformation describe-stacks --stack-name sam-app

πŸ” Troubleshooting

  • Cache Errors: Normal during testing
  • Deployment Issues: Check AWS credentials & IAM
  • API Issues: Verify API ID & region

πŸ“ Contributing

  1. Fork & Clone
  2. Create feature branch
  3. Commit & Push
  4. Create PR

πŸ“§ Contact


🌟 Made with ❀️ by Ozer SUBASI

Stars Forks Issues

About

πŸš€ Serverless crypto API powered by AWS SAM & Lambda. Real-time data with DynamoDB caching.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published