The site is currently a mess of javascript and PHP calling GET requests on itself without any sort of standard and is a total black box. It needs to have an API not only to clean up it's own internal workings but to give users and other developers an alternate means to submit entries and alternate means of reading data. I'm pretty fresh to JSON-based APIs but they seem simple enough for the relatively small number of features that would need to be communicated. I don't expect this database to become a hulking beast so something lightweight like that should be sufficient. After the API is working then the interface can be re-written to implement it.
At minimum:
/api/upload
image (required): site currently supports png, jpg and gif
plate (required): 8 characters max, letters and numbers only.
date (required): a unix time string.
gps (required): it's more practical to store the lat and long in the database separately since it makes location searches easier but might make more sense for the user-facing side to pair them? Not sure.
state: string for license plate style, defaults to NY
street1: ideally the name of the parallel street
street2: ideally the name of the perpendicular street
comment: 200 characters max. also this is called comment and description interchangeably in the code which gets extract confusing now that I've added disqus comments, whoops.
/api/search
I guess just a search that can select by plate, date-min, date-max, gps-lat-min, gps-lat-max, gps-long-min, gps-long-max, street (a substring search of both street1 and street1), comment (same)? And a sort option allowing ascending or descending sorting by id, date, plate, state, gps-lat, gps-long, street, and comment. Or is that too granular?
I'm not sure of the best way to represent an entry in JSON, but I guess a simple flat group of 8 properties is best? Image would be expressed as a URL suffix, like /2016/09/21/1.jpg. Well I guess the API could add on the http://domain/images part. And I guess the upload would have to assume formData because of the image?
The site is currently a mess of javascript and PHP calling GET requests on itself without any sort of standard and is a total black box. It needs to have an API not only to clean up it's own internal workings but to give users and other developers an alternate means to submit entries and alternate means of reading data. I'm pretty fresh to JSON-based APIs but they seem simple enough for the relatively small number of features that would need to be communicated. I don't expect this database to become a hulking beast so something lightweight like that should be sufficient. After the API is working then the interface can be re-written to implement it.
At minimum:
/api/upload
/api/search
I'm not sure of the best way to represent an entry in JSON, but I guess a simple flat group of 8 properties is best? Image would be expressed as a URL suffix, like /2016/09/21/1.jpg. Well I guess the API could add on the http://domain/images part. And I guess the upload would have to assume formData because of the image?