A modern API built with Express.js for retreiving realtime data of the "Kieler Verkehrsgesellschaft" (KVG) data.
- Fast and Efficient: Built with performance in mind.
- Easy to Use: Simple endpoints with clear documentation.
- Scalable: Ready to handle large amounts of data.
- Secure: The endpoints are only accessable with a valid key
-
Clone the repository:
git clone https://github.com/maxverwiebe/KVG-ExpressAPI.git
-
Install dependencies:
npm install
-
Adjust the configuation file:
./config.json
-
Start the server:
node server/index.js
The generator sends requests to the unofficial API of the KVG to assign the stop name to each ID. The result is stored in a csv file.
-
Adapt the search range in:
tools/csv_generator_improved.js
-
Start the generation:
node tools/csv_generator_improved.js
- Method: GET
- Description: A basic endpoint for testing.
- Headers:
X-API-KEY
: Your API key
- Responses:
200 OK
: Successful request401 Unauthorized
: Missing API key403 Forbidden
: Invalid API key
- Method: GET
- Description: Fetches departing buses from a station.
- Parameters:
type
: Can be "name" or "id"id
: The station name or ID
- Headers:
X-API-KEY
: Your API key
- Responses:
200 OK
: Successful request with JSON data401 Unauthorized
: Missing API key403 Forbidden
: Invalid API key404 Not Found
: Bus station not found500 Internal Server Error
: Error fetching station ID
- Method: GET
- Description: Fetches all buses from a station.
- Parameters:
type
: Can be "name" or "id"id
: The station name or ID
- Headers:
X-API-KEY
: Your API key
- Responses:
200 OK
: Successful request with JSON data401 Unauthorized
: Missing API key403 Forbidden
: Invalid API key404 Not Found
: Bus station not found500 Internal Server Error
: Error fetching station ID
Example using Axios:
const axios = require('axios');
axios.get('http://your-api-url/stations/get_busses/name/StationName', {
headers: {
'X-API-KEY': 'your-api-key'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
- Method: GET
- Description: Fetches information about a running trip.
- Parameters:
id
: The station name or ID
- Headers:
X-API-KEY
: Your API key
- Responses:
200 OK
: Successful request with JSON data401 Unauthorized
: Missing API key403 Forbidden
: Invalid API key404 Not Found
: Bus station not found500 Internal Server Error
: Error fetching station ID
Contributions, issues, and feature requests are welcome!
This project is MIT licensed.