Git Product home page Git Product logo

tfl_api_client's Introduction

Transport for London API Client

This gem aims to provide a simple, programmatic ruby client that allows native ruby applications to seamlessly interact with Transport for London's live APIs.

Build Status Dependency Status Code Climate Coverage Status

Installation

Add this line to your application's Gemfile:

gem 'tfl_api_client'

And then install via bundler:

$ bundle install

Or install it yourself as:

$ gem install tfl_api_client

Supported Ruby Versions

The TFL API Client supports Ruby 2.0.0 or higher.

Usage

TFL API Client has been designed to be as simple as possible to work with.

To use the TFL API, developers should register for a set of API credentials (an Application ID and Application Key).

Once valid API credentials have been obtained, you will need to pass the Application ID and Application Key upon initialisation of the client:

@client = TflApi::Client.new(app_id: TFL_APP_ID, app_key: TFL_APP_KEY)

In addition to the above mandatory parameters, a number of optional parameters can be passed:

Option Default Value Description
host https://api.tfl.gov.uk TFL API's host url
logger a new Logger instance Logger object to log into
log_level INFO The log level to logging at
log_location STDOUT Location to send all logs (can be a file or STDOUT)

Full documentation can be found on the project's ruby docs.

Changelog

See the CHANGELOG for a list of changes.

Contributing

This project started in order to fill a gap in the current offers for gems that provide a programmatic interface to TFL's API.

The TFL API Client gem was originally developed by Luke Hackett, and is not an official TFL client.

In the spirit of free software, everyone is encouraged to help improve this project.

Here are some ways in which you can contribute:

  • by using prerelease versions
  • by reporting bugs
  • by suggesting new features
  • by writing or editing documentation
  • by writing code ( no patch is too small : fix typos, add comments, clean up inconsistent whitespace )
  • by refactoring code
  • by reviewing code

Submitting an Issue

I utilise the GitHub issue tracking to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted.

When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and operating system.

Ideally, a bug report should include a pull request with failing specs.

Submitting a Pull Request

  1. Fork the repository.
  2. Create a feature branch using the gitflow naming convention e.g. feature/my-new-feature.
  3. Implement your feature or bug fix.
  4. Add, commit, and push your changes.
  5. Submit a pull request.

Notes

  • Please add tests if you changed code - contributions without tests won't be accepted.
  • Please don't update the Gem version.

The contributing guidelines was inspired by Middleman-Heroku and Factory Girl.

License

Copyright (c) 2015 - 2018 Luke Hackett. MIT Licensed, see LICENSE for details.

tfl_api_client's People

Contributors

lukehackett avatar

Watchers

 avatar

tfl_api_client's Issues

Get all BikePoint Locations

Return all BikePoint locations known by the TFL service as an array of hashes

End Point: /BikePoint/locations

Get all BikePoint Locations within a given "locus"

TFL define a locus as an area that is defined by the latitude/longitude of its centre and a radius in metres.

i.e. if there were 100 BikePoints within the locus area, when making this call I would expect to find 100 BikePoints returned

End Point: /BikePoint?lat=<latitude>&lon=<longitude>&radius=<radius>

Add HTTP application logging

In order to aid debugging a logger should be implemented so that all HTTP requests are logged to a logger. Upon client construction, a custom logger object, or a log level and/or location to store logs can be given.

Constructor Arguments:

  • [optional] Logger Object (must be a type of logger)
  • [optional] Log Level (not set if using custom logger)
  • [optional] Location to store logs (not set if using a custom logger)

Add more API Exceptions

Currently all non-success responses automatically raise an ApiException error.
This could cause problems in the future, so it would be nice to be able to raise errors that are a little more specific. The errors that could help are:

  • Unauthorized (401)
  • Forbidden (403)
  • NotFound (404)
  • InternalServerError (500)
  • ServiceUnavailable (503)

All other errors should raise an ApiException, and hence therefore ApiException would be come the default / generic exception.

Get all BikePoint Locations within a given "bounding box"

TFL define a bounding box as a box with it's lat/lon of its north-west and south-east corners as the edges of the box.

i.e. if there were 10 BikePoints within the bounding box area, when making this call I would expect to find 10 BikePoints returned

End Point: /BikePoint?swLat=<sw_latitude>&swLon=<sw_longitude>&neLat=<ne_latitude>&neLon=<ne_longitude>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.