A RESTful API built with Go (Gin framework) that provides information about countries, their currencies, and estimated GDP based on population and exchange rates.
- Fetch and store country data from external APIs
- Real-time exchange rate integration
- GDP estimation based on population and exchange rates
- Filter countries by region or currency
- Sort countries by estimated GDP
- Visual summary generation
- In-memory data storage with refresh capability
GET /status
Returns the total number of countries in the database and last refresh timestamp.
POST /countries/refresh
Fetches fresh data from external APIs and updates the database.
GET /countries
Returns all countries. Supports the following query parameters:
region: Filter by region (e.g.,Africa,Europe)currency: Filter by currency code (e.g.,NGN,USD)sort: Sort by GDP (gdp_ascorgdp_desc)
Examples:
GET /countries?region=africa
GET /countries?currency=ngn
GET /countries?sort=gdp_desc
GET /countries?region=africa&sort=gdp_desc
GET /countries/:name
Returns details for a specific country.
Example:
GET /countries/Nigeria
DELETE /countries/:name
Removes a country from the database.
GET /summary/image
Returns a visual summary of the database including total countries and top 5 countries by GDP.
- Country data: REST Countries API
- Exchange rates: Exchange Rates API
{
"id": 1,
"name": "Nigeria",
"capital": "Abuja",
"region": "Africa",
"population": 206139589,
"currency_code": "NGN",
"exchange_rate": 1600.23,
"estimated_gdp": 25767448125.2,
"flag_url": "https://flagcdn.com/ng.svg",
"last_refreshed_at": "2025-10-22T18:00:00Z"
}- Clone the repository
- Navigate to the project directory
- Run the application:
go run .- The API will be available at
http://localhost:8080
- Built with Go 1.x and Gin web framework
- Uses in-memory storage (can be extended to use a database)
- Generates visual summaries using the
gggraphics library - Case-insensitive search and filtering
- Automatic timestamp management for data freshness
- Database integration for persistent storage
- User authentication and rate limiting
- Additional filtering options
- Historical exchange rate data
- More detailed country statistics
- Caching layer for improved performance
MIT License - feel free to use this project for learning or building upon it.