r/learnpython • • Sep 04 '19

Wrote my first API

I would love any feedback. The API simply returns homebrewing calculations. I know there still a lot to do. Brew Numbers API

Github Repo

425 Upvotes

44 comments sorted by

View all comments

10

u/Sebass13 Sep 04 '19

I'd personally recommend using URL parameters over URL routing to pass in the parameters to the endpoints; it's what they are there for, and it is better supported by libraries. If you used URL parameters, here's what a request to your URL would look like with requests:

requests.get("http://18.216.248.93/carbonation/howmuchsugar/", 
             params={"temp":65, "co2volume":33.0, "beervolume":10.0})

That is a lot more intuitive than what it would look like with URL routing.

5

u/bmw2621 Sep 04 '19

In reading I saw curl has the same option. I need to figure out how to receive parameter. This would probably make error handling easier.

Thanks for the feedback