I am writing a small program that consumes an API. The program is using Python with requests JSON and requests module. it makes a HTTP request and the API returns a json data. Then I will do something to the data.
it looks like this.
import json, requests
url = 'http://maps.googleapis.com/maps/api/directions/json'
params = {...}
resp = requests.get(url=url, params=params)
data = json.loads(resp.text)
#do something with data
However, I start to wonder about 3 specific questions about my choice of language and design:
Currently, It is obvious that I am the only one using this program but eventually if I publish this program that means more than one people will be using it. Should my choice of language and module differ when it comes to production environment?
why should I use the request module, why not urllib.request
module? urllib module can also make http request.
Furthermore, why use Python? I am using Python because I am familiar with it. Maybe I can use this chance to learn JavaScript. I can use JQuery and AJAX to accomplish the same thing. Is there a better way? or it depends on what the program is for?
Any explanation is appreciated.
Bonus: This following question is broad so I don't expect the chosen answer to include for the following questions but it will be nice.
There are much more great languages, modules, and library that can be used to accomplish my desired task. Basically is there a best way to request JSON data from an API? or it depends on the circumstances? if so, how do circumstances should affect the choice of language and design? and what are the pros and cons?
urllib2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With