Search code examples
pythongoogle-placeshttpie

How to search on Google Places API using HTTPie


The following works in curl

curl "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&key=my_key"

The following does not working in HTTPie

http https://maps.googleapis.com/maps/api/place/nearbysearch/json location='-33.8670522,151.1957362' radius=500 types='food' name='cruise' key='my_key'

Any idea whats going wrong?


Solution

  • The == key-value separator needs to be used to specify URL parameters with HTTPie (single = is only used for form data or JSON). So to construct the URL, you could do:

    $ http https://maps.googleapis.com/maps/api/place/nearbysearch/json \
        location=='-33.8670522,151.1957362' radius==500 types=='food' name=='cruise' key=='my_key'
    

    (Note: you could also just use the full URL like you did in the curl example.)

    More details here: https://github.com/jakubroztocil/httpie#request-items