Authentication overview
Numverify secures access to its phone number validation API primarily through an API key-based authentication mechanism. This approach requires developers to include a unique access_key parameter with every API request. The system then uses this key to identify the requesting user and authorize the request based on their active subscription and usage limits. This method is common for RESTful APIs that prioritize simplicity and ease of integration, particularly for services that involve stateless transactions like data validation.
The Numverify API is designed to be straightforward, primarily utilizing GET requests for its validation operations. The API key serves as the sole credential required for authentication, streamlining the setup process for developers integrating the service into their applications. All communications with the Numverify API are expected to occur over HTTPS to ensure the confidentiality and integrity of data in transit, protecting the API key and any sensitive phone number data being validated.
Supported authentication methods
Numverify exclusively supports API key authentication. This method is widely adopted for its ease of implementation and management in various development environments. Developers embed their unique API access key directly into the request URL as a query parameter.
API Key Authentication
API key authentication involves a unique string that is passed with each request to identify the client. For Numverify, this key is referred to as an access_key and is retrieved from the user's account dashboard after registration. This key acts as both an identifier and a secret, granting access to the API's features up to the limits of the associated subscription plan.
When to use API Key Authentication
- When integrating client-side applications where the API key can be securely managed (e.g., server-side proxies).
- For backend services and scripts that can store the key securely.
- When a simple, stateless authentication mechanism is preferred for quick integration.
Security considerations for API Keys
While convenient, API keys should be treated as sensitive credentials. Exposing them in client-side code without a proxy or storing them insecurely can lead to unauthorized access and potential abuse of your API quota. Best practices involve using environment variables, secret management services, or server-side proxies to prevent key exposure.
The table below summarizes the supported authentication method:
| Method | When to Use | Security Level |
|---|---|---|
API Key (access_key) |
For all Numverify API requests, primarily from server-side applications or secure proxies. | Moderate (requires secure handling to prevent exposure) |
Getting your credentials
To obtain your Numverify API access key, you must first register for an account on the Numverify website. The process typically involves:
- Sign Up: Navigate to the Numverify homepage and complete the registration process. This usually requires providing an email address and creating a password.
- Account Activation: Verify your email address if prompted, which activates your Numverify account.
- Access Dashboard: Log in to your newly created account. Your personal dashboard will typically display your unique API
access_key. - Copy Key: Locate and copy the
access_key. This key is essential for making authenticated requests to the Numverify API.
Numverify offers a free tier that includes 250 requests per month, allowing developers to test the API and integrate it without an initial financial commitment. Even for the free tier, an API key is required to track usage and manage access.
It is recommended to store your API key securely, preferably using environment variables or a dedicated secret management solution, especially in production environments. Avoid hardcoding the key directly into your application's source code.
Authenticated request example
Numverify API requests are made via HTTP GET to a base URL, with the API key and the target phone number included as query parameters. All requests should be made over HTTPS for security.
API Endpoint Structure
The primary endpoint for phone number validation is typically structured as follows:
http://api.numverify.com/v1/validate?access_key=YOUR_ACCESS_KEY&number=TARGET_PHONE_NUMBER
Replace YOUR_ACCESS_KEY with your actual Numverify API key and TARGET_PHONE_NUMBER with the phone number you wish to validate (e.g., 14158586273).
cURL Example
A basic authenticated request using cURL to validate a phone number:
curl "http://api.numverify.com/v1/validate?access_key=YOUR_ACCESS_KEY&number=14158586273"
Python Example
Using the requests library in Python:
import requests
ACCESS_KEY = "YOUR_ACCESS_KEY"
PHONE_NUMBER = "14158586273"
url = f"http://api.numverify.com/v1/validate?access_key={ACCESS_KEY}&number={PHONE_NUMBER}"
response = requests.get(url)
data = response.json()
print(data)
PHP Example
Using file_get_contents or cURL in PHP:
<?php
$access_key = 'YOUR_ACCESS_KEY';
$phone_number = '14158586273';
$url = 'http://api.numverify.com/v1/validate?access_key=' . $access_key . '&number=' . $phone_number;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$validationResult = json_decode($json, true);
print_r($validationResult);
?>
These examples demonstrate how to include the access_key in the request URL. Numverify's official documentation provides further examples across various programming languages, including jQuery, Ruby, and Go, covering different response parameters such as country, carrier, and line type.
Security best practices
Securing your API keys and interactions with the Numverify API is essential to prevent unauthorized access, protect sensitive data, and manage your API usage effectively. Adhering to these best practices helps maintain the integrity of your application and data.
1. Protect your API Key
- Environment Variables: Store your API key as an environment variable rather than hardcoding it directly into your source code. This prevents the key from being exposed if your code repository is compromised.
- Secret Management Services: For more complex applications, consider using a dedicated secret management service like AWS Secrets Manager, Google Secret Manager, or Azure Key Vault. These services provide secure storage and retrieval of sensitive credentials.
- Avoid Client-Side Exposure: Never expose your Numverify API key directly in client-side code (e.g., JavaScript in a web browser or mobile app). If client-side access is necessary, route requests through a secure backend proxy that can append the API key server-side.
2. Use HTTPS for all communications
Always ensure that all requests to the Numverify API are made over HTTPS (https://api.numverify.com). HTTPS encrypts the communication channel, protecting your API key and the phone number data from interception and tampering during transit. While the Numverify documentation examples sometimes show http://, using https:// is the industry standard for secure API communication, as detailed in Mozilla's explanation of HTTPS.
3. Implement Rate Limiting and Error Handling
- Client-Side Rate Limiting: Implement client-side rate limiting in your application to prevent accidental overuse of your API quota. This can involve queuing requests or introducing delays between calls.
- Robust Error Handling: Gracefully handle API errors, including authentication failures, rate limit exceeded responses, and invalid parameters. This prevents your application from crashing and provides a better user experience. Numverify's API will return specific error codes for issues like an invalid access key or exceeding daily limits.
4. Monitor API Usage
Regularly monitor your API usage through your Numverify account dashboard. This helps you track your consumption against your subscription limits and identify any unusual activity that might indicate unauthorized use of your API key. Early detection of anomalies can prevent unexpected charges or service interruptions.
5. Rotate API Keys Regularly
Periodically rotate your API keys, especially if you suspect a key might have been compromised or if personnel with access to the key leave your organization. Most API providers, including Numverify, offer a mechanism to generate new keys and revoke old ones from their account dashboards. Regularly rotating credentials is a fundamental security practice, as outlined in Google Cloud's security best practices for credential rotation.
6. Principle of Least Privilege
If Numverify were to offer different types of API keys with varying permissions (though currently it does not), the principle of least privilege would apply. This means granting only the necessary permissions for a given task. For Numverify's current model, this translates to ensuring that the key is only used for its intended purpose of phone number validation.