rodrq / Uber-Tracker

Project to track Uber's fare to my gf's house. Since I live in a country with high inflation, it's hard to know when a fare is high because of Uber's dynamic pricing (supply and demand) or just because it increased as everything in the economy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uber-Tracker

Project to track Uber's fare to my gf's house. Since I live in a country with high inflation, it's hard to know when a fare is high because of Uber's dynamic pricing (supply and demand) or just because it increased as everything in the economy.

Coded with Python. Using requests, FastAPI, AWS (Lambda, DynamoDB, API Gateway) and a microservice approach.

fare_request:

- Gets price with http request using requests library.
- Connects to my DynamoDB table with 'date' as partition key, and 'time' as sort key. 
- Runs every minute with an AWS EventBridge (fixed rate 1 minute) and puts item into the table. 
- Item being {'date': now as y-m-d, 'time': now as %H:%M, 'price': get_price()}

- Needs csid and sid from your Uber session, input pickup and destination coordinates and timezone as Lambda environment variables. 
- csid and sid expire after a month.

api:

- FastAPI API with two read-only functions. One queries all the fares in a day, the other a fare from a certain hour.
- 404 if fare not found.
- Connects to DynamoDB with Boto3. 
- Setup with API Gateway lambda trigger and lambda_proxy integration as method and resource. 

query_to_local:

- For data analysis purposes.
- Set .env file with your AWS credentials and load it (from dotenv import load_dotenv then load_dotenv()).
- Initialize UberFaresQuery object with 'table_name, month, year, partition_key, aws_region' as args.
- yourquery.tocvs_fares_in_month() writes a csv per day inside 'data' folder. 

Get all fares from month:

image

image

Get fare from certain hour:

image

image

About

Project to track Uber's fare to my gf's house. Since I live in a country with high inflation, it's hard to know when a fare is high because of Uber's dynamic pricing (supply and demand) or just because it increased as everything in the economy.


Languages

Language:Python 100.0%