Skip to content
amoxicillin edited this page Sep 5, 2019 · 3 revisions

RESTful APIs

1. /data

[POST] /data/aggregation

get point-aggregation within a specific radius
data source is the PRISM table and RECORDS table

  • parameter: JSON
{
    "lat":
    "lon":
    "radius":
    "timestamp": '2019-07-30T15:37:27Z' (ISO timestamp, UTC)
    "days": 7 (default=7)
}
  • return: JSON
{
	"tmp": [ [timestamp, val], [timestamp, val], ... ],
	"soilw": [ [timestamp, val], [timestamp, val], ... ],
	"cnt_tweet": [ [timestamp, val], [timestamp, val], ... ]
}

[POST] /data/soilw &

[POST] /data/temp

(unused) these 2 APIs provide soil moisture and temperature within user screen

  • parameter: json
{
    "tid":2019071900,
	"interval": 4,
	"northEast":{"lat":40.0, "lon": -70.415}, 
	"southWest":{"lat": 30.0,"lon":-80.100}
}
  • return: json
[
{lat: 39.25, lng: 285.75, temperature: 301},
{lat: 39.25, lng: 287.75, temperature: 299},
{lat: 39.25, lng: 289, temperature: 299},
 ... ]

[POST] /data/wind

global wind. from a static file

  • parameter: none
  • return: json

[POST] /data/recent-temp

gives the second lastest data for temperature within ractangle around US

  • parameter: none
  • return: json
[
{lat: 39.25, lng: 285.75, temperature: 301},
{lat: 39.25, lng: 287.75, temperature: 299},
{lat: 39.25, lng: 289, temperature: 299},
 ... ]

[POST] /data/fire-polygon

TBD

[POST] /data/fire-with-id

TBD

2. /search

[GET] /search

search administrative boundaries
support region_id as integer, full-name as string and abbreviated state name as 2-letter string

  • parameter:
keyword=CA
  • return: JSON
{"type":"Polygon","coordinates":[[[-123.233256,42.006186],[-122.378853,42.011663],[-121.037003,41.995232],[-120.001861,41.995232], ..., [-123.233256,42.006186]]]}

[POST] /search/boundaries

get administrative boundaries within specific bounding box
will DB stored procedure (boundaries.sql)

  • parameter: JSON
{
	"states":true/false,  
	"cities": true/false,  
	"counties": true/false,
	"northEast":{"lat":43.389, "lon": -100.415}, 
	"southWest":{"lat": 29.305,"lon":-141.100}
}
  • return: JSON
[
{"type":"Feature","id":"01","properties":{"name":"Alabama","density":94.65},"geometry":{"type":"Polygon","coordinates":[[[-87.359296,35.00118],[-85.606675,34.984749],[-85.431413,34.124869],[-85.184951,32.859696],[-85.069935,32.580372],[-84.960397,32.421541],[-85.004212,32.322956],[-84.889196,32.262709],[-85.058981,32.13674],[-85.053504,32.01077],[-85.141136,31.840985],[-85.042551,31.539753],[-85.113751,31.27686],[-85.004212,31.003013],[-85.497137,30.997536],[-87.600282,30.997536],[-87.633143,30.86609],[-87.408589,30.674397],[-87.446927,30.510088],[-87.37025,30.427934],[-87.518128,30.280057],[-87.655051,30.247195],[-87.90699,30.411504],[-87.934375,30.657966],[-88.011052,30.685351],[-88.10416,30.499135],[-88.137022,30.318396],[-88.394438,30.367688],[-88.471115,31.895754],[-88.241084,33.796253],[-88.098683,34.891641],[-88.202745,34.995703],[-87.359296,35.00118]]]}},

{"type":"Feature","id":"04","properties":{"name":"Arizona","density":57.05},"geometry":{"type":"Polygon","coordinates":[[[-109.042503,37.000263],[-109.04798,31.331629],[-111.074448,31.331629],[-112.246513,31.704061],[-114.815198,32.492741],[-114.72209,32.717295],[-114.524921,32.755634],[-114.470151,32.843265],[-114.524921,33.029481],[-114.661844,33.034958],[-114.727567,33.40739],[-114.524921,33.54979],[-114.497536,33.697668],[-114.535874,33.933176],[-114.415382,34.108438],[-114.256551,34.174162],[-114.136058,34.305608],[-114.333228,34.448009],[-114.470151,34.710902],[-114.634459,34.87521],[-114.634459,35.00118],[-114.574213,35.138103],[-114.596121,35.324319],[-114.678275,35.516012],[-114.738521,36.102045],[-114.371566,36.140383],[-114.251074,36.01989],[-114.152489,36.025367],[-114.048427,36.195153],[-114.048427,37.000263],[-110.499369,37.00574],[-109.042503,37.000263]]]}},


...

]

3. /dropDownMenu

[GET] /dropDownMenu

auto-completion relies on this API.
frontend send user types through userInput,
this API perform DB query through stored procedure (autocomplete.sql)

  • parameter:
userInput=Irv
  • return: JSON
[
    [cityName, countyName, stateName],
    ...
]

4. /

/wildfire-prediction

provide predicted wildfires

  • parameter: JSON
{
    "northEast":{"lat":32.421541, "lon":-84.960397},
    "southWest":{"lat":32.421541, "lon":-84.960397},
    "startDate":"2019-07-30T15:37:27Z",
    "endDate":"2019-07-30T15:37:27Z"
}
  • return: JSON
[
    {"long": long, "lat": lat, "nlp": nlp, "text": text},
    ...
]

5. /tweet

[GET] /tweet/tweet-from-id

get detail of specific tweet

  • parameter:
tweet_id=1074292053801140224
  • return: JSON
{"id", "create_at", "text", "user", "profilePic", "image"}

[GET] /tweet/fire-tweet

gives all historical tweets objects with id

  • parameter: none
  • return: JSON
[
    {"create_at", "long", "lat", "id"},
    ...
]