The Department of Transportation maintains the SaferBusAPI to provide safety information pertaining to transporation companies. Information related to this API and instructions for access the API can be found here: https://mobile.fmcsa.dot.gov/developer/apidescription.page?cid=561
Add this line to your application's Gemfile:
gem 'safer_bus_api'
Then run:
bundle install
Set your api_token obtained from registering at https://mobile.fmcsa.dot.gov/developer/UserAccountCreate.page
Note: Once registered you will be emailed a registration token which you can then use to complete your registration and obtain an api token for your application
SaferBusApi.configure do |config|
config.api_token = 'your-token-here'
end
request = SaferBusApi::Request.new(dot_number: '44110')
response = request.perform
response.data # Returns a formatted hash
response.raw_data # Returns the raw response from
request = SaferBusApi::Request.new(company_name: 'greyhound') # Note: company name should have no spaces and be all lower case.
response = request.perform
response.data # Returns a formatted hash
request = SaferBusApi::Request.new(mc_number: '1515') # Note: company name should have no spaces and be all lower case.
response = request.perform
response.data # Returns a formatted hash
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Ensure tests are passing with
rspec
- Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- You da man!