VAS~

Loading page...

Format Numbers Premium

Convert a given phone number into a chosen Standard (E.164, RFC3966, International, National, per Country, etc.) through a simple (and secure) API GET request.

Examples


In order to use this service, you would need to perform an API `POST` request.

URL:

https://vas.purplecfs.com.au/api/formatnumbers/{your_apikey}

Request Body JSON:

{"hash":"xxxxx", "number":"0450xxxxxx", "country":"AU", "format":"E164"}

  • hash: REQUIRED. Unique SHA256 hash(apikey + service_salt). Note: if random is used, hash will change to hash(apikey + service_salt + random).
  • number: REQUIRED. The provided phone number you would like to convert.
  • country: REQUIRED: The provided phone number country code in ISO_3166 Alpha2 format. https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  • format: E164|NATIONAL|INTERNATIONAL|RFC3966 (Default: E164 if none provided)
  • random: Random string (per request) that can be provided to increase the security of the provided hash. If used then hash will be calculated as - hash(apikey + service_salt + random).

Request Headers:
  • content-type: application/json

Response JSON:

{"code":200,"response":"OK","error":"none","input":"0450xxxxxx","output":"+61450xxxxxx","format":"E164"}

  • code: 200
  • response: OK
  • error: none
  • input: The requested number to convert.
  • output: The converion format used.

const apikey = '******.*************************************'; /* (1) your api key */
const apisalt = '************'; /* (2) your service api salt */
const url = 'https://vas.purplecfs.com.au/api/formatnumbers/' + apikey;

// requires NodeJs (or use your own 3rd party crypto helper)
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
hash.update(apikey + apisalt);

// post body data
const data = {
  hash: hash.digest('hex'),
  number: '0415 415 415', /* (3) the `Input Data` name you assigned to the selected property in Zapier  */
  country: 'AU', /* (4) Define your Country Code manually or dynamically similar to value above. */
  format: 'E164' /* (5) Define your conversion */
};

// request options
const options = {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(data)
    }

// send POST request
fetch(url, options)
.then(res => res.json())
.then(res => console.log(res));
<?php
// set some key vars
$apikey = '******.*************************************'; /* (1) your api key */
$apisalt = '************'; /* (2) your service api salt */
$url = 'https://vas.purplecfs.com.au/api/formatnumbers/' . $apikey;

// set the body data
$data = array(
	'hash' => hash('sha256', $apikey . $apisalt),
	'number' => '0450 777 999', /* (3) the `Input Data` name you assigned to the selected property in Zapier  */
	'country' => 'AU', /* (4) Define your Country Code manually or dynamically similar to value above. */
	'format' => 'E164' /* (5) Define your conversion */
);

// open connection
$ch = curl_init();

// set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// execute post
$result = curl_exec($ch);
print_r($result); // use json_decode($result, true) to convert to an array
const apikey = '******.*************************************'; /* (1) your api key */
const apisalt = '************'; /* (2) your service api salt */
const url = 'https://vas.purplecfs.com.au/api/formatnumbers/' + apikey;

const crypto = require('crypto');
const hash = crypto.createHash('sha256');
hash.update(apikey + apisalt);

const data = {
  hash: hash.digest('hex'),
  number: inputData.phone, /* (3) the `Input Data` name you assigned to the selected property in Zapier  */
  country: 'AU', /* (4) Define your Country Code manually or dynamically similar to value above. */
  format: 'E164' /* (5) Define your conversion */
};

try {
    const config = {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(data)
    }

    const response = await fetch(url, config);
    const body = await response.text();
    const obj = JSON.parse(body);
    return {rawHTML: body, rCode: response.status, rMeaning: response.statusText, number: obj.output};
} catch (err) {
    return {rawHTML: 'NA', rCode: '500', rMeaning: 'Try Catch Error - ' + err.message, number: inputData.phone};
}