NYPL / nypl-branches_api

MIT License
1 stars 0 forks source link

Nypl::BranchesApi

Experimental NYPL Branches API.

Installation

Nypl::BranchesApi is a Sinatra app. To run it locally you will need to clone the repository and run:

bundle install

You can set up whatever database you like and load data from data/branches.sql

Start the server with the command

bundle exec rackup config.ru

The app looks for a DATABASE_URL environment variable to know how to connect to its database (à la Heroku). An easy way to set this is to prepend it to the command, e.g.

DATABASE_URL=postgres://localhost/nypl_branches bundle exec rackup config.ru

You can then use curl or the like to retrieve the endpoints:

curl http://localhost:9292

Endpoints

All branches / http://localhost:9292/
One branch /[branch abbreviation] http://localhost:9292/SASB
Multiple branches /[branch abbreviation[,branch abbreviation[,...]]] http://localhost:9292/SASB,YV,DY
By borough /borough/[bronx|manhattan|staten-island] http://localhost:9292/borough/staten-island

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request