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.
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.
- Real-time earthquake data from KOERI
- Clean REST API endpoint
- Swagger/OpenAPI documentation
- Minimal API architecture
- Dependency injection
- Error handling
- JSON response format
- .NET 8 - Web API framework
- HtmlAgilityPack - HTML parsing
- Swagger/OpenAPI - API documentation
- HttpClientFactory - HTTP requests management
- .NET 8 SDK
- Visual Studio 2022
- Internet connection (to fetch data from KOERI)
- Clone the repository:
git clone [your-repository-url]
cd Adapter_Koeri- Restore dependencies:
dotnet restore- Run the application:
dotnet run- Open your browser and navigate to:
- API:
https://localhost:7xxx/earthquakes - Swagger UI:
https://localhost:7xxx/swagger
- API:
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 degreeslongitude: Longitude in decimal degreesdepth: Depth in kilometersmagnitude: Earthquake magnitude (Richter scale)location: Location name in Turkish
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
- Data Fetching: Makes HTTP request to KOERI's earthquake page
- HTML Parsing: Uses HtmlAgilityPack to extract data from
<pre>tag - Data Processing: Parses tab-separated values using regex
- Response: Returns structured JSON data
The application uses default .NET configuration. You can modify settings in appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}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 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.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
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.