Numbers

get_number_info

Client.get_number_info(number)

Gets CNAM information about phone number

Parameters:number (str) – phone number to get information
Return type:dict
Returns:CNAM information

Example: Get Number information:

data = api.get_number_info('+1234567890')
print(data)
## {   'created': '2017-02-10T09:11:50Z',
##     'name'       : 'RALEIGH, NC',
##     'number'     : '+1234567890',
##     'updated'    : '2017-02-10T09:11:50Z'}

list_phone_numbers

Client.list_phone_numbers(application_id=None, state=None, name=None, city=None, number_state=None, size=None, **kwargs)

Get a list of user’s phone numbers

Parameters:
  • application_id (str) – Used to filter the retrieved list of numbers by an associated application ID.
  • state (str) – Used to filter the retrieved list of numbers allocated for the authenticated user by a US state.
  • name (str) – Used to filter the retrieved list of numbers allocated for the authenticated user by it’s name.
  • city (str) – Used to filter the retrieved list of numbers allocated for the authenticated user by it’s city.
  • number_state (str) – Used to filter the retrieved list of numbers allocated for the authenticated user by the number state.
  • size (str) – Used for pagination to indicate the size of each page requested for querying a list of items. If no value is specified the default value is 25. (Maximum value 1000)
Return type:

types.GeneratorType

Returns:

list of phone numbers

Example: List all phone numbers:

number_list = api.list_phone_numbers(size=1000)
print(list(number_list))
## [
##     {
##         'city'          :'RALEIGH',
##         'created_time'   :'2017-02-06T18:41:37Z',
##         'id'            :'n-n123',
##         'name'          :'demo name',
##         'national_number':'(919) 555-5346',
##         'number'        :'+19195555346',
##         'number_state'   :'enabled',
##         'price'         :'0.35',
##         'state'         :'NC'
##     },
##     {
##         'city'          :'RALEIGH',
##         'created_time'   :'2017-02-06T18:41:56Z',
##         'id'            :'n-n1234',
##         'name'          :'demo name',
##         'national_number':'(919) 555-5378',
##         'number'        :'+19195555378',
##         'number_state'   :'enabled',
##         'price'         :'0.35',
##         'state'         :'NC'
##     }
## ]

order_phone_number

Client.order_phone_number(number=None, name=None, application_id=None, fallback_number=None, **kwargs)

Allocates a number so user can use it to make and receive calls and send and receive messages.

Parameters:
  • number (str) – An available telephone number you want to use
  • name (str) – A name you choose for this number.
  • application_id (str) – The unique id of an Application you want to associate with this number.
  • fallback_number (str) – Number to transfer an incoming call when the callback/fallback events can’t be delivered.
Return type:

str

Returns:

id of created phone number

Example: Order Number:

number_id = api.order_phone_number(number='+1234567890')
print(number_id)
# n-asdf123

get_phone_number

Client.get_phone_number(number_id)

Get information about a phone number

Parameters:number_id (str) – id of a phone number
Return type:dict
Returns:number information

Example: Search, order, and fetch Number information:

available_numbers = api.search_available_local_numbers(city='Raleigh', state='NC')

number_id = api.order_phone_number(available_numbers[0]['number'])
print(number_id)
# n-123

my_number = api.get_phone_number(number_id)
print(my_number)
## {
##     'city'          :'RALEIGH',
##     'created_time'   :'2017-02-06T18:27:14Z',
##     'id'            :'n-123',
##     'national_number':'(919) 561-5039',
##     'number'        :'+19195615039',
##     'number_state'   :'enabled',
##     'price'         :'0.35',
##     'state'         :'NC'
## }

update_phone_number

Client.update_phone_number(number_id, name=None, application_id=None, fallback_number=None, **kwargs)

Update information about a phone number

Parameters:
  • number_id (str) – id of a phone number
  • name (str) – A name you choose for this number.
  • application_id (str) – The unique id of an Application you want to associate with this number.
  • fallback_number (str) – Number to transfer an incoming call when the callback/fallback events can’t be delivered.

Example: Update number information:

my_number = api.get_phone_number(number_id)
print(my_number)
## {
##     'city'          :'RALEIGH',
##     'created_time'   :'2017-02-06T18:27:14Z',
##     'id'            :'n-123',
##     'national_number':'(919) 561-5039',
##     'number'        :'+19195615039',
##     'number_state'   :'enabled',
##     'price'         :'0.35',
##     'state'         :'NC'
## }

api.update_phone_number(number_id, name='demo name')

my_number = api.get_phone_number(number_id)
print(my_number)
## {
##     'id'            :'n-123',
##     'number'        :'+19195615039',
##     'national_number':'(919) 561-5039',
##     'name'          :'demo name',
##     'created_time'   :'2017-02-06T18:41:56Z',
##     'city'          :'RALEIGH',
##     'state'         :'NC',
##     'price'         :'0.35',
##     'number_state'   :'enabled'
## }

delete_phone_number

Client.delete_phone_number(number_id)

Remove a phone number

Parameters:number_id (str) – id of a phone number

Example: Delete phone number (release) from account:

api.delete_phone_number('numberId')