Skip to content

johntran038/webdev-rest

 
 

Repository files navigation

St. Paul Crime Database Explorer


App Setup

Install Dependencies

npm install

Run Backend:

node ./rest_server.mjs

Run Frontend:

npm run dev -- --port 8000

API Documentation


Install SQLite3 Database: St. Paul Crime Database

GET requests

/codes

Returns a list of codes and their corresponding incident type (ordered by code number).

curl "http://localhost:8000/codes?code=110,700"

/neighborhoods

Returns a list of neighborhood ids and their corresponding neighborhood name (ordered by id).

curl "http://localhost:8000/neighborhoods?id=11,14"

/incidents

Returns a list of crime incidents (ordered by date/time).

curl "http://localhost:8000/incidents?limit=10&start_date=2019-09-01&end_date=2019-10-31&code=110,700"

The following query parameters are supported:

  • limit - the maximum number of incidents to return (e.g. ?limit=10). The default limit is 1000.
  • start_date - specifies the earliest date of incidents to be returned (e.g. ?start_date=2019-09-01).
  • end_date - specifies the lastest date of incidents to be returned(e.g. ?end_date=2019-10-31).
  • code - specifies the type of incidents that should be returned (e.g. ?code=110,700). All types will be returned by default.
  • grid - specifies which incidents to return based on police gird (e.g. ?grid=38,65). All police grids will returned by default.
  • neighboorhood - specifies which incidents to return based on neighboorhood (e.g. neighborhood=11,14) All neighboorhoods will be returned by default.

PUT requests

/new-incident

Puts a new incident and its data into the crime database.

curl -X PUT "http://localhost:8000/new-incident" -H "Content-Type: application/json" -d "{\"case_number\": 999999999, \"date\": \"2023-11-18\", \"time\": \"20:48:53\", \"code\": 23, \"incident\": \"Stole my heart\", \"police_grid\": 119, \"neighborhood_number\": 1, \"block\": \"4XX LUELLA ST\"}"

A 500 error will be returned if the incident already exists.

DELETE requests

/remove-incident

Removes an incident from the crime database.

curl -X DELETE "http://localhost:8000/remove-incident" -H "Content-Type: application/json" -d "{\"case_number\": 999999999}"

A 500 error will be returned if the incident already exists.

About

REST API for Web Development Course

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Vue 79.7%
  • JavaScript 17.0%
  • HTML 2.1%
  • CSS 1.2%