This API follows CRUD design using the Zillow Zri data for rental markets in the United States, from the state level down to the local level at which point locations are separated by either neighborhood name or zipcode.
BYOB on Heroku
Clone the repo
Run npm install
from the root directory
Run npm start
and visit localhost:3000 in your browser
BYOB uses Mocha and Chai for testing
Run with npm test
- state
- metro
- city
- neighborhood
- zipcode
- Description: Returns an array of all associated records for that table
- Parameters
- regionType: Region type to be retrieved (see list of region types above)
- Query Parameters:
- name
- collected_on
- median_rent
- monthly_change
- quarterly_change
- yearly_change
- size_rank
- state (all except state table)
- abbr (state table only)
- metro (city, neighborhood, zipcode tables only)
- county (city, neighborhood, zipcode tables only)
- city (neighborhood, zipcode tables only)
- Return Format: A JSON object
- Errors
- 404 Table Not Found: The region type provided does not exist, confirm intended path.
- 500 Server Error: There was an error retrieving the requested records, try again.
- Example
- Request
GET /api/v1/neighborhood?state=CA
- Return
[ { "id": 59, "name": "Sherman Oaks", "metro_id": 77, "state_id": 970, "city_id": 200, "collected_on": "2017-06-30T06:00:00.000Z", "median_rent": 3610, "monthly_change": "0.00", "quarterly_change": "0.01", "yearly_change": "0.03", "size_rank": 4, "created_at": "2017-08-27T00:27:45.140Z", "updated_at": "2017-08-27T00:27:45.140Z", "state": "CA", "metro": "Los Angeles-Long Beach-Anaheim", "county": "Los Angeles", "city": "Los Angeles" }, { "id": 61, "name": "Southeast Los Angeles", "metro_id": 77, "state_id": 970, "city_id": 200, "collected_on": "2017-06-30T06:00:00.000Z", "median_rent": 2314, "monthly_change": "0.01", "quarterly_change": "0.05", "yearly_change": "0.14", "size_rank": 10, "created_at": "2017-08-27T00:27:45.140Z", "updated_at": "2017-08-27T00:27:45.140Z", "state": "CA", "metro": "Los Angeles-Long Beach-Anaheim", "county": "Los Angeles", "city": "Los Angeles" } ]
- Description: Add a single location to the specified table
- Parameters: Region type to modify (only neighborhood and zipcode currently available)
- Request body must contain:
- name
- collected_on
- median_rent
- monthly_change
- quarterly_change
- yearly_change
- size_rank
- state (all except state table)
- abbr (state table only)
- metro (city, neighborhood, zipcode tables only)
- county (city, neighborhood, zipcode tables only)
- city (neighborhood, zipcode tables only)
- Authorization
- JWT with admin rights required
- Return Format: A JSON object
- Errors
- 404 Table Not Found: The region type provided does not exist, confirm intended path.
- 500 Server Error: There was an error modifying the requested records, try again.
- 23502 Database error: Missing required parameters
- Unacceptable POST target: Attempted to POST to a table outside of those allowed
- You must be authorized to hit the endpoint: JSON web token was either not applied or invalid
- Example
- Request
POST '/api/v1/:regionType' body: { name: 'Ping pong', metro_id: 43, state_id: 767, city_id: 13, collected_on: '2017-06-30T06:00:00.000Z', median_rent: 1736, monthly_change: '0.00', quarterly_change: '0.00', yearly_change: '0.01', size_rank: 83, created_at: '2017-08-22T22:38:13.668Z', updated_at: '2017-08-22T22:38:13.668Z', state: 'TX', metro: 'Dallas-Fort Worth', county: 'Dallas', city: 'Dallas' } Authorization: 'some-valid-token'
- Return
{ "result": [ { "id": 10, "name": "Ping pong", "metro_id": 43, "state_id": 767, "city_id": 13, "collected_on": "2017-06-30T06:00:00.000Z", "median_rent": 1736, "monthly_change": "0.00", "quarterly_change": "0.00", "yearly_change": "0.01", "size_rank": 83, "created_at": "2017-08-22T22:38:13.668Z", "updated_at": "2017-08-22T22:38:13.668Z", "state": "TX", "metro": "Dallas-Fort Worth", "county": "Dallas", "city": "Dallas" } ] }
- Description: Modify multiple records in the specified table
- Parameters
- regionType: Region type to modify
- name: Required
- collected_on
- median_rent
- monthly_change
- quarterly_change
- yearly_change
- size_rank
- state (all except state table)
- abbr (state table only)
- metro (city, neighborhood, zipcode tables only)
- county (city, neighborhood, zipcode tables only)
- city (neighborhood, zipcode tables only)
- Return Format: A JSON object
- Errors
- 404 Table Not Found: The region type provided does not exist, confirm intended path.
- 500 Server Error: There was an error modifying the requested records, try again.
- Example
- Request
PUT /api/v1/neighborhood
- Return
{ "results": [ [ { "id": 58, "name": "Upper East Side", "metro_id": 76, "state_id": 972, "city_id": 199, "collected_on": "2017-06-30T06:00:00.000Z", "median_rent": 3000, "monthly_change": "0.00", "quarterly_change": "0.00", "yearly_change": "-0.05", "size_rank": 6, "created_at": "2017-08-27T00:27:45.140Z", "updated_at": "2017-08-27T00:27:45.140Z", "state": "NY", "metro": "New York", "county": "New York", "city": "New York" } ], null, null, null, null, null, null, [ { "id": 57, "name": "Upper West Side", "metro_id": 76, "state_id": 972, "city_id": 199, "collected_on": "2017-06-30T06:00:00.000Z", "median_rent": 4000, "monthly_change": "0.00", "quarterly_change": "-0.01", "yearly_change": "-0.07", "size_rank": 3, "created_at": "2017-08-27T00:27:45.140Z", "updated_at": "2017-08-27T00:27:45.140Z", "state": "NY", "metro": "New York", "county": "New York", "city": "New York" } ] ] }
- Description: Update the information for a single location
- Parameters
- regionType: The table you wish to modify
- id: the id of the item you wish to change
- [OPTIONS]
- name (must be unique)
- collected_on
- median_rent
- monthly_change
- quarterly_change
- yearly_change
- size_rank (must be unique)
- state (all except state table)
- abbr (state table only)
- metro (city, neighborhood, zipcode tables only)
- county (city, neighborhood, zipcode tables only)
- city (neighborhood, zipcode tables only)
- Return Format: A JSON object
- Errors
- 404 Table Not Found: The region type provided does not exist, confirm intended path.
- 500 Server Error: There was an error modifying the requested records, try again.
- You must be authorized to hit the endpoint: JSON web token was either not applied or invalid
- Example
- Request
PUT '/api/v1/metro/23' Body: { "median_rent": 9999, "monthly_change": "11.59", "quarterly_change": "0.00", "yearly_change": "999.33" } Authorization: 'some-valid-token'
- Return
{ "msg": "1 record(s) successfully updated", "result": 1 }
- Description: Delete all records in the specified table
- Parameters
- regionType: Region type to delete
- Return Format: A JSON object with the number of records deleted
- Errors
- 404 Table Not Found: The region type provided does not exist, confirm intended path.
- 500 Server Error: There was an error deleting the requested records, try again.
- Example
- Request
DELETE /api/v1/neighborhood
- Return
{ "result": 8 }
- Description: Delete a single record in the specified table
- Parameters
- regionType: Region type to delete record from
- id: Record ID to delete
- Return Format: The number of records deleted
- Errors
- 404 Table Not Found: The region type provided does not exist, confirm intended path.
- 500 Server Error: There was an error deleting the requested records, try again.
- Example
- Request
DELETE /api/v1/neighborhood/8
- Return
1
George Goering : GitHub Profile
Lindsay Parker : GitHub Profile