How would I convert the following curl commands from the Lyft api to http interfaced requests (so they can be executed over web like https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY)? If http requests translation is not possible, how would I integrate and process these curl commands in R?
#Authentication code
curl -X POST -H "Content-Type: application/json" \
--user "<client_id>:<client_secret>" \
-d '{"grant_type": "client_credentials", "scope": "public"}' \
'https://api.lyft.com/oauth/token'
#Search query
curl --include -X GET -H 'Authorization: Bearer <access_token>' \
'https://api.lyft.com/v1/eta?lat=37.7833&lng=-122.4167'
Hi you could use https://curl.trillworks.com/ to convert curl commands to the language of your choice or you could use lyft SDK's (for Python use https://pypi.python.org/pypi/lyft_rides).
Here is the corresponding Python version
import requests
headers = {
'Content-Type': 'application/json',
}
data = '{"grant_type": "client_credentials", "scope": "public"}'
requests.post('https://api.lyft.com/oauth/token', headers=headers, data=data, auth=('<client_id>', '<client_secret>'))
From this post request you will get access token that has to be used for subsequent requests.
headers = {
'Authorization': 'Bearer <access_token>',
}
requests.get('https://api.lyft.com/v1/eta?lat=37.7833&lng=-122.4167', headers=headers)
Note: I haven't tested this as I am unable to create a lyft developer account so there might be some minor changes in the code given here.