AuvasaKit
December 30, 2025 Β· View on GitHub
A modern Swift SDK for accessing AUVASA (Autobuses Urbanos de Valladolid) data through GTFS Real-Time and static GTFS feeds.
π Features
- β GTFS Real-Time: Vehicle positions, trip updates, and service alerts in real-time
- πΊοΈ Static GTFS Data: Stops, routes, schedules, and shapes
- β‘ Async/Await: Modern API using native Swift concurrency
- π Subscriptions: AsyncStream for live updates
- πΎ Smart Caching: Multi-layer caching system for better performance
- π Geospatial Search: Find nearby stops and vehicles
- π― Type-Safe: Strongly typed models with Sendable conformance
- β¨ Minimal Dependencies: Only SwiftProtobuf required
π Installation
Swift Package Manager
Add AuvasaKit to your Package.swift:
dependencies: [
.package(url: "https://github.com/pespinel/AuvasaKit.git", from: "1.0.0")
]
Or in Xcode:
- File β Add Package Dependencies
- Enter:
https://github.com/pespinel/AuvasaKit - Select version
π± Quick Start
import AuvasaKit
// Initialize the client
let client = AuvasaClient()
// 1οΈβ£ Import static GTFS data (first time only)
try await client.updateStaticData()
// 2οΈβ£ Find nearby stops
let userLocation = Coordinate(latitude: 41.6523, longitude: -4.7245)
let stops = try await client.findNearbyStops(
coordinate: userLocation,
radiusMeters: 500
)
// 3οΈβ£ Get next arrivals (combines schedules + real-time)
let arrivals = try await client.getNextArrivals(stopId: "813", limit: 5)
for arrival in arrivals {
let delay = arrival.delay ?? 0
print("\(arrival.route.shortName): \(arrival.bestTime) (delay: \(delay)s)")
}
// 4οΈβ£ Track buses in real-time
let positions = try await client.fetchVehiclePositions(routeId: "L1")
for position in positions {
print("Bus \(position.vehicle.label ?? ""): \(position.position)")
}
// 5οΈβ£ Subscribe to live updates
for await updates in client.subscribeToTripUpdates(stopId: "813") {
print("π Updated arrivals: \(updates.count)")
}
SwiftUI Example
struct BusMapView: View {
@State private var vehicles: [VehiclePosition] = []
@State private var subscriptionTask: Task<Void, Never>?
var body: some View {
Map {
ForEach(vehicles) { vehicle in
Annotation(vehicle.vehicle.label ?? "?",
coordinate: vehicle.position.clLocation) {
Image(systemName: "bus.fill")
.foregroundColor(.blue)
}
}
}
.onAppear {
subscriptionTask = Task {
for await positions in client.subscribeToVehiclePositions() {
vehicles = positions
}
}
}
.onDisappear {
subscriptionTask?.cancel()
}
}
}
π¦ Requirements
- iOS 15.0+ / macOS 12.0+
- Swift 5.9+
- Xcode 15.0+
π Documentation
π Read the full documentation
Guides
- Installation - Setup with Swift Package Manager
- Getting Started - Quick start tutorial
- Real-Time Data - Vehicle positions, trip updates, alerts
- Subscriptions - AsyncStream patterns for live updates
- Static Data - GTFS queries (stops, routes, schedules)
- Search Examples - Advanced search patterns
API Reference
Browse the complete API documentation including all public types, methods, and properties in the online documentation.
AUVASA Endpoints
The SDK uses the following public AUVASA endpoints:
GTFS Real-Time (Protobuf):
- Vehicle Positions:
http://212.170.201.204:50080/GTFSRTapi/api/vehicleposition - Trip Updates:
http://212.170.201.204:50080/GTFSRTapi/api/tripupdate - Alerts:
http://212.170.201.204:50080/GTFSRTapi/api/alert
GTFS Static (ZIP):
- Static data:
http://212.170.201.204:50080/GTFSRTapi/api/GTFSFile
π€ Contributing
Contributions are welcome! Please:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- AUVASA for providing public open data APIs
- GTFS Real-Time Specification
- SwiftProtobuf
β οΈ Disclaimer
This project is not officially affiliated, associated, authorized, endorsed by, or in any way officially connected with AUVASA or any of its subsidiaries or affiliates.
Made with β€οΈ for the Valladolid community