REST API design for utility calculations -


i'm trying design api balances restful recommended practices overall usability , 1 thing i'm struggling design of utility methods calculating things.

specifically, homebrewing there many things brewer wants calculate during process: color, bitterness, abv, etc. guess it's simple enough have /calculators endpoint resulting get returning available calculators:

  • /calculators/1
  • /calculators/2

though in case it's more user-friendly return:

  • /calculators/abv
  • /calculators/ibu

what should get on calculator resource like? should values make calculation url params (/calculators/abv?og=1.050&fg=1.021)? what's appropriate response/response code when necessary params aren't provided or invalid combination of params provided? there more sensible design other resource per calculation type specify above?

there few response codes use, 400 general 'client error', 1 of those. can include body explain wrong.

the way have formed request seems reasonable enough me, it's hard it's bit of contrived example.

for simple calculations, format might work ok. more complex calculations, might want consider having single argument encodes entire calculation, think 6 * 9 ^ 10 / 6.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -