Example Clients:
Namespaced and versioned: /api/v1
Sample API for list of all shelters: https://api.harveyneeds.org/api/v1/shelters
Sample API for list of all shelters accepting people: https://api.harveyneeds.org/api/v1/shelters?accepting=true
You can use the If-Modified-Since
header to check if there are any new results since that timestamp. If there are no new results, you'll receive a 304 NOT MODIFIED
.
GET /api/v1/shelters HTTP/1.1
Host: api.harveyneeds.org
If-Modified-Since: Mon, 11 Sep 2017 21:23:03 -0000
The format for the date timestamp is rfc2822, though you can use any HTTP approved format.
moment.utc().format("ddd, MM MMM YYYY HH:mm:ss [GMT]");
Time.now.utc.rfc2822
In rails console
you'll want to create an admin user:
User.create! email: "youremail@example.com", password: "yourpassword", admin: true
git clone git@github.com:<YOUR OWN GITHUB REPOSITORY>/harvey-api.git
git clone git@github.com:<YOUR OWN GITHUB REPOSITORY>/harvey-api.git
GOOGLE_GEOCODER_API_KEY = Geocoding with Google Maps API, get one
GOOGLE_MAPS_JS_API_KEY = API key to show gmaps in views. See <script>
at end of body in application.html.erb
Can be exactly the same as GOOGLE_GEOCODER_API_KEY
If you see error "Google Maps API error: ApiNotActivatedMapError" in your console, to activate:
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY = Product Advertising API, see below
Note: this is optional; currently only needed to fetch new Amazon products from the Amazon Product Advertising API
You'll need to set the following ENV variables in a .env file
cp .env.sample .env
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ProductAdvertisingAPI:*",
"Resource": "*"
}
]
}
Prerequisites
Method 1: Automatic
rails db:setup
Method 2: Manual
createuser harvey-api_development -P
The -P
flag will prompt you to create a password for the new usercreatedb -O harvey-api_development harvey-api_development
Run rails migrate to create schema
rails db:migrate
Import needs and shelters data from the production API:
rails api:import
Sample output if successful
Starting ImportSheltersJob 2017-09-03 18:33:03 +0000
ImportSheltersJob Complete - {285}
Starting ImportNeedsJob 2017-09-03 18:33:05 +0000
ImportNeedsJob Complete - {92}
Test the API itself (Run API locally)
rails server
Screenshot of Success:
rails db:seed
(or doing a full import rails amazon:import
)
The ActiveJob
s and associated Rake task rails api:import
, which imports data for shelters and needs from the production API into the application database, is intended for use in development and test environments only.DO NOT RUN THIS JOB IN PRODUCTION. Since this job pulls data from the production API, running it in production can only be counter-productive, and would likely be destructive.
Code should have tests, and any pull requests should be made only after you've made sure passes the test suite
We force pull-requests from feature branches to master. Once something lands in master, it goes live instantly
git remote add upstream git@github.com:sketch-city/harvey-api.git
git fetch upstream
Within your own forked repo create branches for each logical unit for work you do. One benefit of doing this is you'll be able to periodically sync your forked repo with upstream repo into the master branch without conflicting with work you may be doing.
When you believe your code is ready to be merged into the upstream repository (sketch-city/harvey-api) by creating a pull request. Do this by
(Coming Soon)
Documentation such as READMEs (e.g., this document) are written in markdown per the [Github standard] (https://guides.github.com/features/mastering-markdown/)
Source Code Collaborators can be viewed: https://api.harveyneeds.org/contributors.html
But the API wouldn't mean anything without our volunteers:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Postgres is not running OR there is a connection problem to the database.
This system's software code is licensed under the GPLv3.
Full license availabe in LICENSE
<img
alt="Creative Commons License" style="border-width:0"
src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" />
This
work is licensed under a <a rel="license"
href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons
Attribution-NonCommercial-ShareAlike 4.0 International License.