Example #1
0
    def estmate_cost(self,start,end,type="lyft"):
        auth_flow = ClientCredentialGrant(client_id, client_secret,scope,)
        session = auth_flow.get_session()
        client = LyftRidesClient(session)

        s_lat=start.split(',')[0]
        s_log=start.split(',')[1]
        e_lat=end.split(',')[0]
        e_log=end.split(',')[1]

        est_dict={}
        try:
            cost_resp=client.get_cost_estimates(start_latitude=s_lat, start_longitude=s_log, end_latitude=e_lat, end_longitude=e_log).json
            est=cost_resp["cost_estimates"][0]

            est_dict['start']=start
            est_dict['end']=end
            est_dict['es_time']=est["estimated_duration_seconds"]//60
            est_dict['es_distance']=est["estimated_distance_miles"]
            est_dict['es_cost_max']=est["estimated_cost_cents_max"]/100
            est_dict['es_cost_min']=est["estimated_cost_cents_min"]/100
        except:
            est_dict['start']=start
            est_dict['end']=end
            est_dict['es_time']='Not avaliable'
            est_dict['es_distance']='Not avaliable'
            est_dict['es_cost_max']='Not avaliable'
            est_dict['es_cost_min']='Not avaliable'

        return est_dict
Example #2
0
    def test_google_lyft_uber_pipe(self):
        geo = Geocoder(api_key=GEOCODE_API)

        sessionu = Session(server_token='hVj-yE_w4iJQ5-rbp8hmKZSNekOzLV1cvnF_BrNl')
        clientu = UberRidesClient(sessionu)

        auth_flow = ClientCredentialGrant(
            'd-0DVSBkAukU',
            'I-yZZtV1WkY_903WKVqZEfMEls37VTCa',
            'rides.request',
            )
        session = auth_flow.get_session()

        client = LyftRidesClient(session)
        start = time.time()

        dlat,dlong = geo.geocode("UT Austin").coordinates
        alat,along = geo.geocode("Round Rock, TX").coordinates
        response = client.get_cost_estimates(dlat,dlong,alat,along)
        response = clientu.get_price_estimates(
            start_latitude=dlat,
            start_longitude=dlong,
            end_latitude=alat,
            end_longitude=along,
            seat_count=2
        )

        end = time.time()
        self.assertTrue(10 > end-start)
Example #3
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Lyft sensor."""

    auth_flow = ClientCredentialGrant(
        client_id=config.get(CONF_CLIENT_ID),
        client_secret=config.get(CONF_CLIENT_SECRET),
        scopes="public",
        is_sandbox_mode=False,
    )
    try:
        session = auth_flow.get_session()

        timeandpriceest = LyftEstimate(
            session,
            config.get(CONF_START_LATITUDE, hass.config.latitude),
            config.get(CONF_START_LONGITUDE, hass.config.longitude),
            config.get(CONF_END_LATITUDE),
            config.get(CONF_END_LONGITUDE),
        )
        timeandpriceest.fetch_data()
    except APIError as exc:
        _LOGGER.error("Error setting up Lyft platform: %s", exc)
        return False

    wanted_product_ids = config.get(CONF_PRODUCT_IDS)

    dev = []
    for product_id, product in timeandpriceest.products.items():
        if (wanted_product_ids is not None) and (product_id not in wanted_product_ids):
            continue
        dev.append(LyftSensor("time", timeandpriceest, product_id, product))
        if product.get("estimate") is not None:
            dev.append(LyftSensor("price", timeandpriceest, product_id, product))
    add_entities(dev, True)
Example #4
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Lyft sensor."""
    from lyft_rides.auth import ClientCredentialGrant

    auth_flow = ClientCredentialGrant(client_id=config.get(CONF_CLIENT_ID),
                                      client_secret=config.get(
                                          CONF_CLIENT_SECRET),
                                      scopes="public",
                                      is_sandbox_mode=False)
    session = auth_flow.get_session()

    wanted_product_ids = config.get(CONF_PRODUCT_IDS)

    dev = []
    timeandpriceest = LyftEstimate(
        session, config[CONF_START_LATITUDE], config[CONF_START_LONGITUDE],
        config.get(CONF_END_LATITUDE), config.get(CONF_END_LONGITUDE))
    for product_id, product in timeandpriceest.products.items():
        if (wanted_product_ids is not None) and \
           (product_id not in wanted_product_ids):
            continue
        dev.append(LyftSensor('time', timeandpriceest, product_id, product))
        if product.get('estimate') is not None:
            dev.append(LyftSensor(
                'price', timeandpriceest, product_id, product))
    add_devices(dev, True)
Example #5
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Lyft sensor."""
    from lyft_rides.auth import ClientCredentialGrant
    from lyft_rides.errors import APIError

    auth_flow = ClientCredentialGrant(client_id=config.get(CONF_CLIENT_ID),
                                      client_secret=config.get(
                                          CONF_CLIENT_SECRET),
                                      scopes="public",
                                      is_sandbox_mode=False)
    try:
        session = auth_flow.get_session()

        timeandpriceest = LyftEstimate(
            session, config[CONF_START_LATITUDE], config[CONF_START_LONGITUDE],
            config.get(CONF_END_LATITUDE), config.get(CONF_END_LONGITUDE))
        timeandpriceest.fetch_data()
    except APIError as exc:
        _LOGGER.error("Error setting up Lyft platform: %s", exc)
        return False

    wanted_product_ids = config.get(CONF_PRODUCT_IDS)

    dev = []
    for product_id, product in timeandpriceest.products.items():
        if (wanted_product_ids is not None) and \
           (product_id not in wanted_product_ids):
            continue
        dev.append(LyftSensor('time', timeandpriceest, product_id, product))
        if product.get('estimate') is not None:
            dev.append(LyftSensor(
                'price', timeandpriceest, product_id, product))
    add_entities(dev, True)
Example #6
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Lyft sensor."""
    from lyft_rides.auth import ClientCredentialGrant

    auth_flow = ClientCredentialGrant(
        client_id=config.get(CONF_CLIENT_ID),
        client_secret=config.get(CONF_CLIENT_SECRET),
        scopes="public",
        is_sandbox_mode=False)
    session = auth_flow.get_session()

    wanted_product_ids = config.get(CONF_PRODUCT_IDS)

    dev = []
    timeandpriceest = LyftEstimate(session, config[CONF_START_LATITUDE],
                                   config[CONF_START_LONGITUDE],
                                   config.get(CONF_END_LATITUDE),
                                   config.get(CONF_END_LONGITUDE))
    for product_id, product in timeandpriceest.products.items():
        if (wanted_product_ids is not None) and \
           (product_id not in wanted_product_ids):
            continue
        dev.append(LyftSensor('time', timeandpriceest, product_id, product))
        if product.get('estimate') is not None:
            dev.append(
                LyftSensor('price', timeandpriceest, product_id, product))
    add_devices(dev, True)
def get_lyft_session():
    auth_flow = ClientCredentialGrant(client_id=LYFT_CLIENT_ID,
                                      client_secret=LYFT_CLIENT_SECRET,
                                      scopes=LYFT_PERMISSION_SCOPES)

    session = auth_flow.get_session()

    return session
Example #8
0
def order():
    if request.method == "POST":
        mymap = Map(
            identifier="mymap",
            lat=37.4419,
            lng=-122.1419,
            markers=[{
                'icon':
                'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                'lat': 37.4419,
                'lng': -122.1419,
                'infobox': "Your Location"
            }, {
                'icon':
                'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                'lat': nearest_hospital()[0],
                'lng': nearest_hospital()[1],
                'infobox': "Nearest Hospital"
            }])
        lyft_start_latitude = locator.locate_me()[0]
        lyft_start_longitude = locator.locate_me()[1]
        lyft_end_latitude = nearest_hospital()[0]
        lyft_end_longitude = nearest_hospital()[1]
        auth_flow = ClientCredentialGrant(creds.lyft_client_id,
                                          creds.lyft_client_secret, "public")
        session = auth_flow.get_session()
        client = LyftRidesClient(session)
        x = len(
            client.get_pickup_time_estimates(
                lyft_start_latitude,
                lyft_start_longitude).json['eta_estimates'])
        lyft_eta_seconds = []
        myauth_flow = AuthorizationCodeGrant(
            creds.lyft_client_id,
            creds.lyft_client_secret,
            "public",
        )
        auth_url = myauth_flow.get_authorization_url()
        y = 0
        while y < x:
            lyft_eta_seconds.append(
                client.get_pickup_time_estimates(
                    lyft_start_latitude,
                    lyft_start_longitude).json['eta_estimates'][y]
                ['eta_seconds'])
            y += 1
        eta_seconds = int(min(lyft_eta_seconds))
        return render_template('order.html',
                               eta_seconds=eta_seconds,
                               auth_url=auth_url,
                               yourmap=yourmap)
    return render_template('order.html',
                           eta_seconds=eta_seconds,
                           auth_url=auth_url,
                           yourmap=yourmap)
Example #9
0
    def test_lyft_estimator(self):

        auth_flow = ClientCredentialGrant(
            'd-0DVSBkAukU',
            'I-yZZtV1WkY_903WKVqZEfMEls37VTCa',
            'rides.request',
            )
        session = auth_flow.get_session()

        client = LyftRidesClient(session)
        response = client.get_cost_estimates(37.7833, -122.4167, 37.791,-122.405)
        self.assertTrue(response != None)
Example #10
0
    def test_time_lyft_api(self):
        auth_flow = ClientCredentialGrant(
            'd-0DVSBkAukU',
            'I-yZZtV1WkY_903WKVqZEfMEls37VTCa',
            'rides.request',
            )
        session = auth_flow.get_session()

        client = LyftRidesClient(session)
        start = time.time()
        response = client.get_cost_estimates(37.7833, -122.4167, 37.791,-122.405)
        end = time.time()
        self.assertTrue(1 > end-start)
Example #11
0
def Lyft(start_latitude, start_longitude, end_latitude, end_longitude):
    auth_flow = ClientCredentialGrant(
        client_id="BaRMBhEu0hPh",
        client_secret="YGqQrluq5clWEVkyPvDWQIJ7XXjOCDKk",
        scopes="public")
    session = auth_flow.get_session()

    client = LyftRidesClient(session)
    response = client.get_cost_estimates(start_latitude, start_longitude,
                                         end_latitude, end_longitude)

    print(response.json)
    estimated_cost = response.json['cost_estimates'][2][
        'estimated_cost_cents_max'] / 100

    print(estimated_cost)
    return estimated_cost
Example #12
0
def getData(nhoods, client_id, client_secret, username, pswd):
    auth_flow = ClientCredentialGrant(client_id=client_id,
                                      client_secret=client_secret,
                                      scopes='public')
    session = auth_flow.get_session()
    client = LyftRidesClient(session)

    con = psycopg2.connect(
        "dbname='Pulse' user='******' host='localhost' password='******'" %
        (username, pswd))
    cur = con.cursor()

    for row in range(len(nhoods.index)):
        lat = nhoods.iloc[row]['lat']
        lon = nhoods.iloc[row]['lon']

        response = client.get_cost_estimates(lat,
                                             lon,
                                             37.468051,
                                             -122.447088,
                                             ride_type='lyft')
        costs = response.json.get('cost_estimates')
        geoID = nhoods.iloc[row]['geoid']

        low = costs[0]['estimated_cost_cents_min']
        high = costs[0]['estimated_cost_cents_max']

        percent = costs[0]['primetime_percentage']
        perc = percent.replace('%', '')
        outperc = int(perc) / 100 + 1

        response = client.get_pickup_time_estimates(lat, lon, ride_type='lyft')
        timeEstimate = response.json.get('eta_estimates')

        etaSeconds = timeEstimate[0]['eta_seconds']

        ts = time.time()
        timeStamp = datetime.datetime.fromtimestamp(ts).strftime(
            '%Y-%m-%d %H:%M:%S')

        query = "INSERT INTO lyft_sf (geoid, time, outperc, low, high, etaseconds) VALUES (%s, %s, %s, %s,%s,%s);"
        data = (geoID, timeStamp, outperc, low, high, etaSeconds)
        cur.execute(query, data)
    con.commit()
    print('Wrote data')
    con.close()
Example #13
0
    def test_google_lyft_pipe(self):
        geo = Geocoder(api_key=GEOCODE_API)

        auth_flow = ClientCredentialGrant(
            'd-0DVSBkAukU',
            'I-yZZtV1WkY_903WKVqZEfMEls37VTCa',
            'rides.request',
            )
        session = auth_flow.get_session()

        client = LyftRidesClient(session)
        start = time.time()


        dlat,dlong = geo.geocode("UT Austin").coordinates
        alat,along = geo.geocode("Round Rock, TX").coordinates
        response = client.get_cost_estimates(dlat,dlong,alat,along)

        end = time.time()
        self.assertTrue(5 > end-start)
Example #14
0
def getLyftPrices(start_lat, start_lng, end_lat, end_lng):
    lyft_auth_flow = ClientCredentialGrant(client_id=LYFT_CLIENT_ID, client_secret=LYFT_CLIENT_SECRET, scopes='public')
    lyft_session = lyft_auth_flow.get_session()

    lyft_client = LyftRidesClient(lyft_session)
    response = lyft_client.get_cost_estimates(start_lat, start_lng, end_lat, end_lng)

    estimate = response.json.get('cost_estimates')

    results = []
    for entry in estimate:
        tempdict = collections.OrderedDict()
        tempdict['ride_type'] = entry['ride_type']
        tempdict['estimate'] = '$'+ str(math.trunc(entry['estimated_cost_cents_min']/100))
        minutes = entry['estimated_duration_seconds']/60
        seconds = entry['estimated_duration_seconds']%60
        tempdict['duration'] = str(math.trunc(minutes)) +' minutes '+str(math.trunc(seconds))+' seconds'
        results.append(tempdict)

    return results
Example #15
0
    def getLyftEstimate(startLat, startLng, endLat, endLng):
        auth_flow = ClientCredentialGrant(config.lyft['client_id'],
                                          config.lyft['client_secret'],
                                          config.lyft['scope'])

        session = auth_flow.get_session()
        client = LyftRidesClient(session)
        response = client.get_cost_estimates(
            start_latitude=startLat,
            start_longitude=startLng,
            end_latitude=endLat,
            end_longitude=endLng,
        )

        ride_types = response.json.get('cost_estimates')

        results = []
        for x in ride_types:
            # TODO
            link = "lyft://ridetype?id=lyft&pickup[latitude]=" + startLat + "&pickup[longitude]=" + startLng + "&destination[latitude]=" + endLat + "&destination[longitude]=" + endLng

            obj = {
                "brand":
                "Lyft",
                "name":
                x["display_name"],
                "low_estimate":
                x["estimated_cost_cents_min"] / 100,
                "high_estimate":
                x["estimated_cost_cents_max"] / 100,
                "avg_estimate": (((x["estimated_cost_cents_min"] +
                                   x["estimated_cost_cents_max"]) / 2) / 100),
                "duration":
                x["estimated_duration_seconds"],
                "link":
                link
            }

            results.append(obj)

        return results
Example #16
0
#import pandas as pd
#import matplotlib.pyplot as plt
import numpy as np
import math
import requests
import os
import logging

# LYFT CLIENT SETUP
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session as lyftSession

lyft_token = os.environ.get('LYFT_TOKEN')
auth_flow = ClientCredentialGrant(client_id="BqM2cwqXmV3w",
                                  client_secret=lyft_token,
                                  scopes=set(["public"]))
lyft_session = auth_flow.get_session()
lyft_token = lyft_session.oauth2credential.access_token

from lyft_rides.client import LyftRidesClient

lyft_client = LyftRidesClient(lyft_session)

# UBER CLIENT SETUP
from uber_rides.session import Session as uberSession
from uber_rides.client import UberRidesClient

uber_token = os.environ.get('UBER_TOKEN')
uberSession = uberSession(server_token=uber_token)
uber_client = UberRidesClient(uberSession)
Example #17
0
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session
from lyft_rides.client import LyftRidesClient
import json
import creds
auth_flow = ClientCredentialGrant(
    creds.lyft_client_id,
    creds.lyft_client_secret,
    "public",
)
session = auth_flow.get_session()

client = LyftRidesClient(session)
response = client.get_drivers(37.7833, -122.4167)
ride_types = response.json.get('ride_types')

print(ride_types)
Example #18
0
import math
import requests
import fake_cube
import pickle

from flask import Flask
app = Flask(__name__)

from ast import literal_eval as make_tuple

#LYFT CLIENT SETUP
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session as lyftSession

auth_flow = ClientCredentialGrant(
    client_id="BqM2cwqXmV3w",
    client_secret="SwNdpIHbN9adZ0lc4IWq_ejdZV7bBSz1",
    scopes=set(["public"]))
lyft_session = auth_flow.get_session()
lyft_token = lyft_session.oauth2credential.access_token

from lyft_rides.client import LyftRidesClient
lyft_client = LyftRidesClient(lyft_session)
#{"token_type": "Bearer", "access_token": "XgOzXKLM6Oj/tTRdyndXpJMC6+UOvXQxAnmNJaaWwY2aJFXWqD2pJLxJ2uPWcmfbL2Y+yL87IFYzT7OE/EEjwf75DEq5U9qfCzplImiACUV91ikGBtuiIqs=", "expires_in": 86400, "scope": "public"}
#lyft_token = XgOzXKLM6Oj/tTRdyndXpJMC6+UOvXQxAnmNJaaWwY2aJFXWqD2pJLxJ2uPWcmfbL2Y+yL87IFYzT7OE/EEjwf75DEq5U9qfCzplImiACUV91ikGBtuiIqs=

#UBER CLIENT SETUP
from uber_rides.session import Session as uberSession
from uber_rides.client import UberRidesClient

uber_token = "eWfH_tAQpYHHfVi2nCSFbLrLpoS_69f34ldS63J0"
uberSession = uberSession(server_token=uber_token)
Example #19
0
# conn.commit()
#
# update_two='UPDATE RIDE SET Destination=(SELECT address FROM EAT)'
# cur.execute(update_two)
# conn.commit()

client_id = 'KZ-TZqsDDPf9'
client_secret = 'K7GU9SoiwvUMcr-QyzQ_ynaqlGpEF9Ww'
access_token = '7ze30S6B+qvt4f7vet2nm6PHg8q8wfQWEIg3lxeP1EPgHoLFagPZuevnqm07lXx19gwXZZMNdhwSRuCc2yVG+NacsXJifU3M8sJyjMavSvz1t6RpLCmL8u4='
scope = "public"
token_type = 'bearer'
#

auth_flow = ClientCredentialGrant(
    client_id,
    client_secret,
    scope,
)
session = auth_flow.get_session()
client = LyftRidesClient(session)

#1.startpoint


#
def estmate_cost(start, end, type="lyft"):
    #     'https://api.lyft.com/v1/cost?start_lat=37.7763&start_lng=-122.3918&end_lat=37.7972&end_lng=-122.4533'
    s_lat = start.split(',')[0]
    s_log = start.split(',')[1]
    e_lat = end[0].split(',')[0]
    e_log = end[0].split(',')[1]
Example #20
0
from lyft_rides.auth import AuthorizationCodeGrant
import lyft_rides.auth

from uber_rides.session import Session
from uber_rides.client import UberRidesClient
from uber_rides.auth import AuthorizationCodeGrant

from flask import session
import os
from random import randint
import arrow
import googlemaps

#Authorize access to Lyft API
auth_flow = ClientCredentialGrant(
    client_id=os.environ["LYFT_CLIENT_ID"],
    client_secret=os.environ["LYFT_CLIENT_SECRET"],
    scopes=None)
lyft_est_session = auth_flow.get_session()
lyft_client = LyftRidesClient(lyft_est_session)

lyft_auth_flow = lyft_rides.auth.AuthorizationCodeGrant(
    os.environ["LYFT_CLIENT_ID"], os.environ["LYFT_CLIENT_SECRET"],
    ["rides.request", "rides.read"], True)

#Authorize access to Uber API
uber_est_session = Session(server_token=os.environ["UBER_SERVER_TOKEN"])
uber_client = UberRidesClient(uber_est_session)

if "NO_DEBUG" in os.environ:
    uber_base_uri = "https://ridethrift.herokuapp.com/callback"
else:
Example #21
0
app = Flask(__name__)
app.secret_key = 'SUPERSECRETSECRETKEY'
app.config['MONGO_URI'] = "mongodb+srv://swlabadmin:[email protected]/RideDB?retryWrites=true"

secrets = json.loads(open('secrets.json', 'r').read())
os.environ['GOOGLE_API_KEY'] = secrets['google_api_key']

uberServerKey = secrets['uber-server-key']
uber_session = Session(server_token=uberServerKey)
uber_client = UberRidesClient(uber_session)

googleApiKey = secrets['google_api_key']
geo = Geocoder(api_key=googleApiKey)
pms = ParkMeScraper()
ws = WeatherScraper()

auth_flow = ClientCredentialGrant(
            'd-0DVSBkAukU',
            'I-yZZtV1WkY_903WKVqZEfMEls37VTCa',
            'rides.request',
            )

lyft_session = auth_flow.get_session()
lyft_client = LyftRidesClient(lyft_session)

from views import *

if __name__ == '__main__':
    app.run(ssl_context=('cert.pem', 'key.pem'),debug=False)
from configparser import SafeConfigParser

from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session
from lyft_rides.client import LyftRidesClient

config_parser = SafeConfigParser()
config_parser.read('api_keys.cfg')

LYFT_CLIENT_ID = config_parser.get('LyftAPI', 'id')
LYFT_CLIENT_SECRET = config_parser.get('LyftAPI', 'secret')
LYFT_PERMISSION_SCOPES = config_parser.get('LyftAPI', 'scopes')

auth_flow = ClientCredentialGrant(
    LYFT_CLIENT_ID,
    LYFT_CLIENT_SECRET,
    LYFT_PERMISSION_SCOPES
    )
session = auth_flow.get_session()

# Returns the fastest travel means offered by Uber and its duration in seconds
def get_lyft_pickup_time(start_latitude, start_longitude, ride_type=None):
	client = LyftRidesClient(session)

	response = client.get_pickup_time_estimates( 
	    start_latitude,
	    start_longitude,
	    ride_type
	)

	if response.status_code == 200:
Example #23
0
import csv
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session as lyft_Session
from lyft_rides.auth import AuthorizationCodeGrant
from lyft_rides.client import LyftRidesClient

# Uber API

conn = sqlite3.connect('yelp.db')
cur = conn.cursor()
session = uber_Session(server_token='Uvu3eEPnLtPKCbTU7KrCko5jo1ua4CVgYAqd0JfO')
client = UberRidesClient(session)

auth_flow = ClientCredentialGrant(
    		'gRUenY4LPYg_',
    		'dFyiT-f23Jwmo_A7n2xGfzp_WcWvBIi8',
    		'public',
    		)
lyft_session = auth_flow.get_session()

def first_loc():
	df1 = pd.read_sql_query("SELECT name, coordinates_latitude, coordinates_longitude, location_address1, location_address2, location_address3, location_city, location_state, location_zip_code, location_country FROM yelp_businesses ORDER BY RANDOM() LIMIT 1;", conn)
	return df1
def second_loc():
	
	df2 = pd.read_sql_query('SELECT name, coordinates_latitude, coordinates_longitude, location_address1, location_address2, location_address3, location_city, location_state, location_zip_code, location_country FROM yelp_businesses where name IN (SELECT name FROM yelp_businesses ORDER BY RANDOM() LIMIT 1)', conn)
	
	return df2
	
def yelp_query():
	df1 = first_loc()
Example #24
0
from lyft_rides.client import LyftRidesClient

import requests
import json

geolocator = Nominatim(user_agent="uberVcar")

#UBER CREDENTIALS
session = UberSession(server_token='hWrizMQl5BAsAs_Xxsb0D49J6_IDkpsvad4ShfYX')
uber_client = UberRidesClient(session)

        
#LYFT CREDENTIALS
auth_flow = ClientCredentialGrant(
    '2E3iq4LPcDDL',
    'Q5IsU-VbuZeNsBQvmwOm9dMnjpTO9MZh',
    'public',
)
session = auth_flow.get_session()
lyft_client = LyftRidesClient(session)

# api-endpoint
URL = "https://dev.tollguru.com/beta00/calc/gmaps"
 

headers = {"x-api-key": "k98AnfwbGz7LGKSMR7dIq8Z9xhg2oxnU8w5KJ7Kj" }

app = Flask(__name__)
api = Api(app)

states_names = {
import geopy.distance
import pandas as pd
import numpy as np
import datetime
import sqlite3
import random
from apscheduler.schedulers.background import BackgroundScheduler

#opening necessary files
points = pd.read_csv('measurment_points_seattle.csv')
lat = points['latitude'].values; lon = points['longitude'].values; point_id = points['point_id'].values; 
#number of points
nop = count = len(points)

#authentication lyft
auth_flow = ClientCredentialGrant('token','token','public')
session_lyft = auth_flow.get_session();
client_lyft = LyftRidesClient(session_lyft)

#authentication uber
session_uber = Session(server_token='token')
client_uber = UberRidesClient(session_uber)

#function for getting data on lyft
def extract_lyft(point_id_o, o_lat, o_lon, d_lat, d_lon, point_id_d):
    global count, pd_timestamp, rand_seq
    #getting number of nearby cars
    locations = []
    response = client_lyft.get_drivers(o_lat, o_lon)
    nearby_drivers = response.json.get('nearby_drivers')
    for i in range(0, len(nearby_drivers)):
Example #26
0
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session
from lyft_rides.client import LyftRidesClient

auth_flow = ClientCredentialGrant(
    'yM-_iRPCi4-f',
    'PyRA3zG4llCje6ZoBBqdpLr5ITTuu3qR',
    ['public', 'profile', 'rides.read', 'rides.request'],
)
session = auth_flow.get_session()
client = LyftRidesClient(session)
response = client.get_cost_estimates(start_latitude=42.299709,
                                     start_longitude=-71.351121,
                                     end_latitude=42.288493,
                                     end_longitude=-71.359711,
                                     ride_type='lyft_line')
print response.json
response = client.get_ride_types(42.299709, -71.351121)
ride_types = response.json.get('ride_types')
print ride_types
Example #27
0
from lyft_rides.auth import ClientCredentialGrant
from lyft_rides.session import Session

import lyft_tokens
import json
from lyft_rides.client import LyftRidesClient

auth_flow = ClientCredentialGrant(
    lyft_tokens.YOUR_CLIENT_ID,
    lyft_tokens.YOUR_CLIENT_SECRET,
    lyft_tokens.YOUR_PERMISSION_SCOPES,
)
session = auth_flow.get_session()
client = LyftRidesClient(session)

response = client.get_cost_estimates(start_latitude=37.7766,
                                     start_longitude=-122.391,
                                     end_latitude=37.7972,
                                     end_longitude=-122.4533,
                                     ride_type='lyft')
estimate = response.json.get('cost_estimates')
distance = estimate[0]['estimated_distance_miles']
costmin = estimate[0]['estimated_cost_cents_min']
costmax = estimate[0]['estimated_cost_cents_max']

print(distance)
print(costmin)
print(costmax)

# for line in estimate:
#     print(line)