Search Available Numbers

This page shows you how to programmatically search for numbers that are available for purchase.

You can also search for available numbers online, using the developer dashboard or from the command line, using the Vonage CLI.

Replace the following variables in the sample code with your own values:

KeyDescription
VONAGE_API_KEY

Your Vonage API key (see it on your dashboard).

VONAGE_API_SECRET

Your Vonage API secret (also available on your dashboard).

COUNTRY_CODE

The two digit country code for the number. For example: GB for the United Kingdom

VONAGE_NUMBER_TYPE

The type of number: landline, mobile-lvn or landline-toll-free

VONAGE_NUMBER_FEATURES

The capabilities of the number: SMS, VOICE or SMS,VOICE for both

NUMBER_SEARCH_CRITERIA

The filter criteria. For example, numbers containing 234.

NUMBER_SEARCH_PATTERN

Where the NUMBER_SEARCH_CRITERIA should appear in the number:

  • 0 - At the beginning of the number
  • 1- Anywhere in the number
  • 2 - At the end of the number

Write the code

Add the following to search-numbers.sh:

curl "https://rest.nexmo.com/number/search?api_key=$VONAGE_API_KEY&api_secret=$VONAGE_API_SECRET&country=$COUNTRY_CODE&type=$VONAGE_NUMBER_TYPE&features=$VONAGE_NUMBER_FEATURES&pattern=$NUMBER_SEARCH_CRITERIA&search_pattern=$NUMBER_SEARCH_PATTERN"

View full source

Run your code

Save this file to your machine and run it:

sh search-numbers.sh

See also