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!
@session = OldBill.session.create(:username => "username", :password => "password") @session.locate(52.6397278, -1.1322921).crimes_by_month
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)
@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
Police API for code: policeapi2.rkh.co.uk/api/docs/
Gemcutter for the gem: gemcutter.org/gems/oldbill
The API is separated into 2 area neighbourhoods and crime
@session = OldBill.session.create(:username => "username", :password => "password") @session.forces
@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
@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
@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