iOS Framework for fetching Bikeshare availability data
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Bikeshare Kit

A simple iOS framework for automatically fetching bikeshare data.


Installation is easy, thanks to BikeshareKit having zero dependencies!


Run unit tests in Xcode using cmd-U.




You must send a valid token. Need a token? Contact @thelowlypeon.

BSManager.configure([.Token: "my_valid_auth_token"])
BSManager.sharedManager().syncServices() //...


let manager = BSManager(token: "my_valid_auth_token")

Active Stations

By default, BikeshareKit will only return active stations. To include all, pass the following param:

BSManager.configure([.IncludeInactiveStations: true])

Get a list of all available Bikeshare Services

BSManager.sharedManager().syncServices({(error) -> Void in
    if error == nil {
        print("hooray! retrieved \( services")
    } else {
        print("Uh oh, there was an error: \(error)")

Get stations nearest a given CLLocationCoordinate2D

let belmontAndLSD = CLLocation(latitude: 41.9408, longitude: -87.6392)
manager.stationsNearest(belmontAndLSD.coordinate, limit: 1) {(stations, error) in
    if let error = error {
        print("error: \(error)")
    } else {
        if let closestStation = stations?[0] {
            print("closest station: \(closestStation)")
            print("availability: \(closestStation.availability!)")

Set your favorite service

Set a favorite service to avoid syncing or dealing with all services.

BSManager.sharedManager().favoriteService = myFavoriteService

Persist data locally to use until updates are available

//on your app delegate's applicationWillResignActive()

//on didFinishLaunchingWithOptions()

let countOfServicesOnLaunch = BSManager.sharedManager().services.count
BSManager.sharedManager().syncServices({(error) -> Void in
    let newCount =
    print("retrieved \(newCount - countOfServicesOnLaunch) new services")


You can observe changes in values using iOS's built in Key Value Observing, or KVO, or with third party libraries like ReactiveCocoa.

//in view controller
override func viewDidAppear(animated: Bool) {
    BSManager.sharedManager().addObserver(self, forKeyPath: "", options: .New, context: nil)

override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
    if keyPath == "" {
        print("observed change to favorite service or favorite service's name: \(change)")


BSManager's services are stored as a Set (or, in Objective-C, an NSSet). This means that the services contained in the set are unique based on an internal (private) ID. This makes synchronizing services with the API extremely fast, but also means that updates to individual services will trigger a change event when syncing. Keep this in mind when implementing KVO.

The same is true for a BSService's stations.