Get a Number from your City on Grasshopper
GrassHopper is one of my favorite virtual phone systems. We used it in the past at my company and I use it in my daily life.
Recently I wanted to open an account with a local Santa Barbara number. GrassHopper allows you to choose the area code of the number but does not let you pick the city it is from.
The first number I got was not from Santa Barbara and their support personnel was not able to help me. Time for some scripting!
The GrassHopper website uses a REST endpoint to get the list of number availables you can choose from. The one below is the URL, but it requires a few more parameters and headers, which I recommed you to get from your Chrome Development Tools
https://signup.grasshopper.com/api/LocalNumberCatalog/LocalNumbersbynpa?areaCode=805&count=10&numberLockSessionId=...
I then looked for a website that would give me the primary city associated to a number, and found this one
https://www.hocalls.com/name-and-address/8059551
It was then a matter of putting them together with some bash scripting
CURL="curl 'https://signup.grasshopper.com/api/LocalNumberCatalog/LocalNumbersbynpa?areaCode=805&count=10&numberLockSessionId=..." for i in {1..10}; do for number in `$CURL 2>/dev/null | jq . | grep E164 | egrep -o '+1805[0-9]*'`; do prefix=`echo $number | cut -c 2-8` city=`wget -q -O- "https://www.hocalls.com/name-and-address/$prefix" | egrep -o '<b style="color: #f7f7f7;">.*</b>' | sed 's/]*>//g'` echo "$number $city" done done
This scripts makes 10 requests to the GrassHopper API to retrieve 100 numbers and checks with HoCalls the primary city of each of them, printing the output on the screen. Here is an example:
... 18058743159 Oxnard, CA 18058453330 Santa Barbara, CA 18057699014 Paso Robles, CA 18052501568 San Luis Obispo, CA 18053183283 Santa Barbara, CA 18053929991 Santa Paula, CA 18059543056 Ventura, CA 18057794034 San Luis Obispo, CA ...
Once I identified some Santa Barbara numbers, I could confidently go ahead and buy them on GrassHopper.














