Skip to content

This .NET 8 minimal API fetches real-time earthquake data from the KOERI (Boğaziçi University Kandilli Observatory) website.

License

Notifications You must be signed in to change notification settings

snurdal/Adapter_Koeri

Repository files navigation

KOERI Earthquake API

A .NET 8 Web API that scrapes real-time earthquake data from KOERI (Kandilli Observatory and Earthquake Research Institute) and provides it through a clean REST API endpoint.

🌍 About

This project fetches the latest earthquake data from Turkey's official seismic monitoring service (KOERI) and exposes it through a modern REST API. The data includes earthquake magnitude, location coordinates, depth, timestamp, and location names.

🚀 Features

  • Real-time earthquake data from KOERI
  • Clean REST API endpoint
  • Swagger/OpenAPI documentation
  • Minimal API architecture
  • Dependency injection
  • Error handling
  • JSON response format

🛠️ Tech Stack

  • .NET 8 - Web API framework
  • HtmlAgilityPack - HTML parsing
  • Swagger/OpenAPI - API documentation
  • HttpClientFactory - HTTP requests management

📋 Prerequisites

  • .NET 8 SDK
  • Visual Studio 2022
  • Internet connection (to fetch data from KOERI)

🔧 Installation

  1. Clone the repository:
git clone [your-repository-url]
cd Adapter_Koeri
  1. Restore dependencies:
dotnet restore
  1. Run the application:
dotnet run
  1. Open your browser and navigate to:
    • API: https://localhost:7xxx/earthquakes
    • Swagger UI: https://localhost:7xxx/swagger

📊 API Endpoints

GET /earthquakes

Retrieves the latest earthquake data from KOERI.

Response Format:

[
  {
    "dateTime": "2024-01-15T14:30:25",
    "latitude": 38.123,
    "longitude": 27.456,
    "depth": 12.5,
    "magnitude": 4.2,
    "location": "IZMIR KORFEZI"
  }
]

Response Fields:

  • dateTime: Date and time of the earthquake (ISO 8601)
  • latitude: Latitude in decimal degrees
  • longitude: Longitude in decimal degrees
  • depth: Depth in kilometers
  • magnitude: Earthquake magnitude (Richter scale)
  • location: Location name in Turkish

🏗️ Project Structure

Adapter_Koeri/
├── Models/
│   └── EarthquakeModel.cs     # Data model for earthquake
├── Services/
│   └── EarthquakeService.cs   # Service for data fetching and parsing
└── Program.cs                 # Application entry point and configuration

🔍 How It Works

  1. Data Fetching: Makes HTTP request to KOERI's earthquake page
  2. HTML Parsing: Uses HtmlAgilityPack to extract data from <pre> tag
  3. Data Processing: Parses tab-separated values using regex
  4. Response: Returns structured JSON data

⚙️ Configuration

The application uses default .NET configuration. You can modify settings in appsettings.json:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  }
}

🚨 Error Handling

The API includes basic error handling:

  • Returns HTTP 500 with error details if KOERI data cannot be fetched
  • Throws exception if HTML structure changes
  • Handles parsing errors gracefully

🔄 Data Source

Data is sourced from: http://www.koeri.boun.edu.tr/scripts/sondepremler.asp

Note: This is web scraping, so the API depends on KOERI's website structure remaining consistent.

🤝 Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

⚠️ Disclaimer

This project is for educational and informational purposes. The earthquake data is sourced from KOERI's public website. Please refer to official sources for critical earthquake information.


About

This .NET 8 minimal API fetches real-time earthquake data from the KOERI (Boğaziçi University Kandilli Observatory) website.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages