Because I’m too lazy to pick up the phone and wait for the uber app to load.
We are going to use uber api for this. Create an app and get your server token. In the estimates endpoint you don’t need to pass different start location and end location to get the surge multiplier. (Note that I’m using the v1 of the api. v1.2 doesn’t provide us the surge multiplier since they are showing upfront charges now). Just pass the starting location to check for surge. (Use google maps and check the url to get your lat, long).
Here’s a simple script to get what we need from the api. Don’t forget to replace YOUR_TOKEN with your actual server token from the uber developer dashboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ch = curl_init(); | |
$headers[] = "Authorization: Token YOUR_TOKEN"; | |
$headers[] = "Accept-Language: en_US"; | |
$headers[] = "Content-Type: application/json"; | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
//get surge from old api. v1.2 surge multiplier is not available because we have upfront pricing now. | |
curl_setopt($ch, CURLOPT_URL, 'https://api.uber.com/v1/estimates/price?start_latitude='.$argv[1].'&start_longitude='.$argv[2].'&end_latitude='.$argv[1].'&end_longitude='.$argv[2]); | |
$content = curl_exec($ch); | |
$surge = json_decode($content)->prices[0]->surge_multiplier; | |
echo ($surge==1?'No surge':$surge.'x surge') . "\n"; |
Then from your terminal set an alias to the script with your lat long values.
$ alias surge="/path/to/script/surge.php 6.9328 79.8414722"
Reload the profile to make the new alias work. In my case its;
$ source ~/.zshrc
Next time you want to check if there’s any surge you just have to type surge in your terminal.