0
votes

Currently I search for available phone numbers using the Twilio Python API, then filter out the numbers that don't match specific Twilio phone number capabilities:

local = client.available_phone_numbers('US').local.list(
    'limit': 50,
    'area_code': '609'
)
records = []
for record in local:
    if record.capabilities['voice'] == False:
        continue
    records.append(record)

This is inefficient and problematic for several reasons. I would like to be able to search based on capability (voice, sms, mms, fax), but can't find out how in the documentation or by browsing through the library files.

Is this possible?

1
Can you explain what does "search based on capability" mean? - Tino
@tino, Twilio has phone numbers with different capabilities. "MMS", "SMS", "fax" and "voice". When you use their API to search for an available phone number, you can search based on items like area and postal codes. However, I have yet to find a way to search (or filter a search) based on the above capabilities. So, for instance if I want to search on a phone number that allows faxing, the only way I've been able to do so is to search using a postal or area code, then loop through the results and throw out all the numbers that don't have fax capabilities. API: wwug.co/ISaOPeiq - crazy4linux

1 Answers

0
votes

Twilio developer evangelist here.

The parameter to use to search phone numbers based on capability is sms_enabled, mms_enabled, and voice_enabled.

local = client.available_phone_numbers('US').local.list(area_code='609', mms_enabled=True, limit=50)
for record in local:
    print record.phone_number

Hope this helps!