======= Example Clients:
Namespaced and versioned: /api/v1
Sample API for list of all shelters: https://irma-api.herokuapp.com/api/v1/shelters
Sample API for list of all shelters accepting people: https://irma-api.herokuapp.com/api/v1/shelters?accepting=true
Shape:
{
"shelters": [
{
county: "Palm Beach County",
shelter: "Dr. Mary Mcleod Bethune Elementary School",
address: "1501 Avenue U, West Palm Beach, Palm Beach County, FL, United States",
city: "West Palm Beach",
state: "Florida",
zip: "33404",
pets: null,
phone: "(561) 882-7600",
accepting: true,
updated_by: null,
notes: null,
volunteer_needs: null,
longitude: -80.084386,
latitude: 26.776181,
supply_needs: null,
source: null,
google_place_id: "ChIJoQqfCZ3V2IgRmoonj7yL5x4",
special_needs: false,
needs: [ ],
updated_at: "2017-09-09T11:44:42-05:00",
updatedAt: "2017-09-09T11:44:42-05:00",
last_updated: "2017-09-09T11:44:42-05:00",
cleanPhone: "5618827600"
},
{
county: "Palm Beach County",
shelter: "Palm Beach Gardens High School",
address: "4245 Holly Drive, Palm Beach Gardens, FL, United States",
city: "Palm Beach Gardens",
state: "Florida",
zip: "33410",
pets: null,
phone: "(561) 694-7300",
accepting: true,
updated_by: null,
notes: null,
volunteer_needs: null,
longitude: -80.1010343,
latitude: 26.8250767,
supply_needs: null,
source: null,
google_place_id: "ChIJTyeTJ6sq2YgRT1ojAxBcxk4",
special_needs: false,
needs: [ ],
updated_at: "2017-09-09T11:44:43-05:00",
updatedAt: "2017-09-09T11:44:43-05:00",
last_updated: "2017-09-09T11:44:43-05:00",
cleanPhone: "5616947300"
},
{
county: "Manatee County",
shelter: "Buffalo Creek Middle School",
address: "7320 69th St E",
city: "Palmetto",
state: null,
zip: "34221",
pets: "Yes",
phone: "(941) 721-2260",
accepting: true,
updated_by: null,
notes: null,
volunteer_needs: null,
longitude: -82.4907812,
latitude: 27.5756384,
supply_needs: null,
source: "http://www.mymanatee.org/home/government/departments/public-safety/emergency-management/shelter-list-table.html",
google_place_id: "ChIJb4ViKXcjw4gRicDxsEVhf4Q",
special_needs: false,
needs: [ ],
updated_at: "2017-09-09T16:24:41-05:00",
updatedAt: "2017-09-09T16:24:41-05:00",
last_updated: "2017-09-09T16:24:41-05:00",
cleanPhone: "9417212260"
}
],
"meta": {
"result_count": 3,
"filters": {
accepting: "true"
}
}
}
Filters:
county
: County Nameaccepting
: true/falseshelter
: the namelat
and lon
: specify the lat / lon. We'll order by the lat/lon and return results within a 100 mile radiuslimit
: only return n resultsSample:
/api/v1/shelters?accepting=true&county=Alachua+County
/api/v1/shelters?shelter=Archer
Shape:
{
"needs": [
{
"updated_by": "Taylor",
"timestamp": "2017-08-31 12:52",
"location_name": "BBVA Compass Stadium",
"location_address": "2200 Texas Ave, Houston, TX 77003",
"longitude": "-95.351565",
"latitude": "29.752355",
"contact_for_this_location_name": "",
"contact_for_this_location_phone_number": "",
"are_volunteers_needed": true,
"tell_us_about_the_volunteer_needs": "Need volunteers to process donations, sign up through Red Cross. Friday, September 1 from 8 a.m.-8 p.m. daily. More details: https://www.houstondynamo.com/post/2017/08/30/bbva-compass-stadium-capacity-no-longer-collecting-donations-storm-relief",
"are_supplies_needed": false,
"tell_us_about_the_supply_needs": "No longer taking donations",
"anything_else_you_would_like_to_tell_us": ""
}
],
"meta": {
"result_count": 1,
"filters": {
"location_name": "BBVA"
}
}
}
Filters:
supplies_needed
: truevolunteers_needed
: truelocation_name
: the namelat
and lon
: specify the lat / lon. We'll order by the lat/lon and return results within a 100 mile radiuslimit
: only return n resultsSample:
/api/v1/needs?location_name=Montgomery
/api/v1/needs?supplies_needed=true
Shows needs as an Amazon Product, ready for purchase.
Shape:
{
"products": [
{
"need": "pet items",
"asin": "B00ME73XUG",
"amazon_title": "PET FACTORY 28750 Chicken Dog Roll, 40-Pack",
"detail_url":
"https://www.amazon.com/FACTORY-28750-Chicken-Roll-40-Pack/dp/B00ME73XUG?psc=1&SubscriptionId=AKIAJ5PESCDQX7KIMQ5Q&tag=oneclickrelie-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B00ME73XUG",
"priority": false,
"category_specific": "Rawhide",
"category_general": "Pet Supplies",
"price_in_cents": 2352,
"price": "$23.52"
}
],
"meta": {
"result_count": 247
}
}
Filters:
need
: Name of need, eg: 'baby'priority
: true
. Note: data has to be gathered to make this truelimit
: only return n resultscategory
: matching either the category_specific or category_generalSample:
/api/v1/products?limit=2&need=baby
baby
Shape:
{
"charitable_organizations": [
{
"name": "Boys and Girls Country",
"services": "Children",
"food_bank": false,
"donation_website": "https://www.boysandgirlscountry.org/donate",
"phone_number": "(281)351-4976",
"email": "info@boysandgirlscountry.org",
"physical_address": "18806 Roberts Road",
"city": "Hockley",
"state": "TX",
"zip": "77447",
"updatedAt": "2017-09-04T00:58:58.088Z"
}
],
"meta": {
"result_count": 1,
"filters": {
"city": "Hockley"
}
}
}
Filters:
food_bank
: truename
: the nameservices
: the services providedlimit
: only return n resultscity
: the organizations in a citySample:
/api/v1/charitable_organizations?services=schools
/api/v1/charitable_organizations?food_bank=true
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
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.