JohnCoker / thrustcurve3

ThrustCurve.org third revision
ISC License
12 stars 7 forks source link

REST-ful API notes #18

Open broofa opened 3 years ago

broofa commented 3 years ago

[First of all, a huge thank you for hosting this site over the years! I've gotten a tremendous amount of value from it and very much appreciate all the hard work you've put into it. I'm actually really pleased to discover the new API and, even better, that you're running on a JS stack that I'm pretty familiar with. Here's hoping I can help contribute at some point.]

So, regarding the new API - speaking specifically of the REST-ful JSON api which is what I expect to be using - there are a few things that stand out as being a bit "unexpected". For your consideration...

I hope this doesn't come across as pushy. I'm sure there are good reasons for the shape of the current API. I'm mostly just hoping to convey a sense of what I think most developers familiar with REST would expect to find here.

Again, thank you for all your hard work!

JohnCoker commented 3 years ago

Support for both GET and POST is mostly a matter of reducing code. (All requests handle both for simplicity.) I don't see a reason to not support POST, but don't feel strongly about it for the JSON API.

Fields like the manufacturer are enums, and the /metadata endpoint is called to enumerate the values. Case insensitivity isn't the only thing here, there are also manufacturer abbreviations and aliases ("Cesaroni", "CTI").

I agree that ideally the structure of the JSON API should change to be more modern, but this should be added in a backwards-compatible way, at least in terms of not breaking the XML API. I had intended to add a /api/v2 path that was totally modern at some point, but just never got around to it. Note that the existing support is in api_v1.js.

The XML APIs have been in place since 2008 and are used by external programs such as OpenRocket and RockSim so should not change. (It's also of course used by the phone app.) There is a test in /spec/api which can be used to verify that nothing breaks. (It's not currently run by Travis, but must be run manually with the local server running.)