List Contacts
Welcome to the Notify Africa SMS RESTful API documentation!
This comprehensive guide will walk you through the process of listing contacts in your Notify Africa account.
We present you with a step-by-step guide to help you list contacts and manage your contact list efficiently.
If you have reached this page, we assume you have an active Notify Africa account and are ready to list your contacts.
- Javascript
- php
- python
try {
// Send a POST request to the API endpoint for creating contacts
const baseUrl = 'https://example.com/v2'; // contact us for the base URL
const token = 'YOUR_API_TOKEN';
const endPoint = '/contacts/list/records';
const records = 10;
const page = 1;
const url = `${baseUrl}${endPoint}`;
const response = await fetch(`${url}/${records}?page=${page}`,{
method:'GET',
headers: { 'Authorization': `Bearer ${token}`},
})
// Parse the response body as JSON
const json = await response.json();
console.log('Response:', json);
} catch (error) {
console.error('Error:', error);
}
<?php
// API endpoint URL
$baseUrl = 'https://example.com/v2';
$endPoint = '/contacts/list/records';
$records = 10;
$page = 1;
$url = "$baseUrl$endPoint/$records?page=$page";
// Set the headers
$options = array(
'http' => array(
'header' => "Authorization: Bearer YOUR_API_TOKEN\r\n" .
"Accept: application/json\r\n",
'method' => 'GET'
)
);
// Create a stream context
$context = stream_context_create($options);
// Send the request and get the response
$response = file_get_contents($url, false, $context);
// Parse the response JSON
$responseData = json_decode($response, true);
// Check if the response is successful
if ($response !== false) {
echo "Response: ";
print_r($responseData);
} else {
echo "Error: Unable to fetch contacts.";
}
?>
import requests
# API endpoint URL
base_url = 'https://example.com/v2'
end_point = '/contacts/list/records'
records = 10
page = 1
url = f"{base_url}{end_point}/{records}?page={page}"
# Set the headers
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Accept': 'application/json'
}
# Send the request and get the response
response = requests.get(url, headers=headers)
# Parse the response JSON
if response.status_code == 200:
response_data = response.json()
print("Response:", response_data)
else:
print("Error:", response.status_code, response.text)