Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twilio's Available Phone Number API

Tags:

api

twilio

I'm working with the Twilio Available Phone Numbers API, and trying to list all the available phones for Brazil. It is working fine, but I can't get the phone location from the response, with city and state. It should by possible to reach the city by the area code, but Brazil share an area code with multiple cities at the same region. ZipCode is also not an option, because it cames always empty for brazilian phones)

When I search for a phone using the Twilio front-end I can see its location just the way I need it, so it should be available somewhere, but I can't get this piece of information out of the API response.

Any hints on that ?

like image 729
Daniel Cheida de Oliveira Avatar asked Oct 30 '22 09:10

Daniel Cheida de Oliveira


1 Answers

Twilio developer evangelist here.

With the lookup API you can get a lot of information about a number, but unfortunately not it's location at the moment.

You will be able to get an exact location in some numbers. I say "some numbers" because some will have latitude and longitude information, which you can then use to pinpoint that location exactly.

I've just done a query myself, and one of the numbers returned this:

{
  "friendly_name": "+55513937XXXX",
  "phone_number": "+55513937XXXX",
  "lata": null,
  "rate_center": null,
  "latitude": "-16.516700",
  "longitude": "-39.350000",
  "region": "RS",
  "postal_code": null,
  "iso_country": "BR",
  "address_requirements": "none",
  "beta": false,
  "capabilities": {
    "voice": true,
    "SMS": false,
    "MMS": false
  }
}

This gave me a very exact location, but like I said, probably not something you can completely rely on, as we rely on getting this information from carriers and they don't always give us that.

Here is a curl request example of what I tried to get the results above.

curl -G https://api.twilio.com/2010-04-01/Accounts/YOUR_TWILIO_SID/AvailablePhoneNumbers/BR/Local.json \
-d "Contains=5551*" \
-u 'YOUR_TWILIO_SID:YOUR_AUTH_TOKEN'

Hope this helps you out.

like image 189
Marcos Placona Avatar answered Nov 15 '22 06:11

Marcos Placona