Project

oldbill

0.01
No commit activity in last 3 years
No release in over 3 years
ruby wrapper for the police API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1.0.0
~> 0.7.4
~> 0.6.0
 Project Readme

OldBill¶ ↑

OldBill gives you a nice ruby wrapper for the police.uk API

It allows you to hook into the new Police API service to find out about crime in your local area.

The Police API allows you to download data about crime localised to your area within a date range, and is data direct from the UK police service. Enjoy!

Idiomatic Ruby¶ ↑

Concrete classes and methods modelling Police data¶ ↑

Quickstart¶ ↑

@session = OldBill.session.create(:username => "username", :password => "password")

@session.locate(52.6397278, -1.1322921).crimes_by_month

Defaults:¶ ↑

caching                    # => true (boolean)
expires_in                 # => 60*60*24 (seconds)
cache                      # => Moneta::Memory.new "(Moneta Supported Cache) http://github.com/wycats/moneta
server                     # => "api-stage.carboncalculated.com" (string)
api_version                #=>  "v1" (string)
logging                    # => true (boolean)

This is overriding the defaults¶ ↑

@session = OldBill::Session.create(
  :username => "username",
  :password => "password"
  :cache => Moneta::S3.new(:access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'], :bucket => 'carbon')
  :expires_in => 60*60*24*14
)

This has created a session with S3 Moneta cache that expires in 14 days

Resources¶ ↑

Police API for code: policeapi2.rkh.co.uk/api/docs/

Gemcutter for the gem: gemcutter.org/gems/oldbill

Using OldBill¶ ↑

The API is separated into 2 area neighbourhoods and crime

Forces¶ ↑

@session = OldBill.session.create(:username => "username", :password => "password")
@session.forces

Crimes¶ ↑

@session = OldBill.session.create(:username => "username", :password => "password")

@session.crimes_by_month("leicestershire", "C01")

@session.street_level_crimes(52.6397278, -1.1322921)

@session.crime_categories

Neighbourhoods¶ ↑

@session = OldBill.session.create(:username => "username", :password => "password")

@session.neighbourhoods("leicestershire")

@session.neighbourhood("leicestershire", "C01")

You can then call methods on the neighbourhood

@session.neighbourhood("leicestershire", "C01").street_level_crimes
@session.neighbourhood("leicestershire", "C01").crimes_by_month
@session.neighbourhood("leicestershire", "C01").events
@session.neighbourhood("leicestershire", "C01").police_officers

Locate A Neighbourhood¶ ↑

@session = OldBill.session.create(:username => "username", :password => "password")
@session.locate(52.6397278, -1.1322921)

@session.locate(52.6397278, -1.1322921).events
@session.locate(52.6397278, -1.1322921).crimes_by_month
@session.locate(52.6397278, -1.1322921).police_officers
@session.locate(52.6397278, -1.1322921).full_neighbourhood.street_level_crimes