API文档

API密钥
可用方法
方法 URL 描述 参数
GET/POST /api/v1/phone/validate 号码验证 phone, country, api_key
参数:
参数 描述 示例 必填
api_key API密钥 your_key
phone 电话号码 +393201234567
country 国家代码 IT, ["IT","US","DE"]
多国家处理

参数country支持多种格式:

  • 单一国家: IT
  • 多个国家用逗号分隔: IT,US,DE
  • 多个国家用分号分隔: IT;US;DE
  • 多个国家用空格分隔: IT US DE
  • 国家数组(POST): ["IT", "US", "DE"]

API会依次用每个国家解析号码,直到找到有效结果。这对于国家本地格式的号码特别有用。

响应代码
代码 描述 示例
200 请求成功
{
  "success": true,
  "data": {
    "is_valid": true,
    "type_id": 1,
    "type_name": "Mobile",
    "is_mobile": true,
    "is_fixed_line": false,
    "phone_code": "+39",
    "country_code": "IT",
    "location": null,
    "international": "+39 320 123 4567",
    "national": "320 123 4567",
    "e164": "+393201234567",
    "rfc3966": "tel:+39-320-123-4567"
  },
  "error": null,
  "request_id": "a430273e63f07ef5805f04e5f8a94d16f0351fd7"
}
400 请求无效(参数错误)
{
  "success": false,
  "data": null,
  "error": "Invalid phone number",
  "request_id": "b1e2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"
}
401 未授权(API密钥无效或缺失)
{
  "success": false,
  "data": null,
  "error": "Invalid API key",
  "request_id": "c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7"
}
403 拒绝访问(无权限或被封禁)
{
  "success": false,
  "data": null,
  "error": "Access denied",
  "request_id": "d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8"
}
404 未找到方法或资源
{
  "success": false,
  "data": null,
  "error": "Method or resource not found",
  "request_id": "e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9"
}
429 请求次数超限
{
  "success": false,
  "data": null,
  "error": "Request limit exceeded",
  "request_id": "f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0"
}
500 服务器内部错误
{
  "success": false,
  "data": null,
  "error": "Internal server error",
  "request_id": "a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1"
}
测试API密钥: test
如果您在请求中使用此密钥,API将始终返回演示(mock)响应。
余额不会消耗,实际校验不会执行。
示例:
curl "https://numlook.ru/api/v1/phone/validate?phone=+393201234567&api_key=test"
使用示例
cURL命令
号码验证:
cURL
curl "https://numlook.ru/api/v1/phone/validate?phone=+393201234567&api_key=your_key"
多国:
cURL
curl "https://numlook.ru/api/v1/phone/validate?phone=3201234567&country=IT,US,DE&api_key=your_key"
带国家数组的POST请求:
cURL
curl -X POST "https://numlook.ru/api/v1/phone/validate" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "3201234567",
    "country": ["IT", "US", "DE"],
    "api_key": "your_key"
  }'
JavaScript (fetch)
号码验证:
JavaScript
// Number validation
fetch('https://numlook.ru/api/v1/phone/validate?phone=+393201234567&api_key=your_key')
.then(response => response.json())
.then(data => console.log(data));
多国:
JavaScript
// With multiple countries
fetch('https://numlook.ru/api/v1/phone/validate?phone=3201234567&country=IT,US,DE&api_key=your_key')
.then(response => response.json())
.then(data => console.log(data));
带国家数组的POST请求:
JavaScript
// POST request with array of countries
fetch('https://numlook.ru/api/v1/phone/validate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    phone: '3201234567',
    country: ['IT', 'US', 'DE'],
    api_key: 'your_key'
  })
})
.then(response => response.json())
.then(data => console.log(data));
PHP
单号码验证:
PHP
// Single number validation
$apiKey = 'your_key';
$phone = '+393201234567';

$response = file_get_contents(
    "https://numlook.ru/api/v1/phone/validate?phone=" . urlencode($phone) . "&api_key=" . $apiKey
);

$data = json_decode($response, true);
var_dump($data);
多国:
PHP
// With multiple countries
$apiKey = 'your_key';
$phone = '3201234567';
$countries = 'IT,US,DE';

$response = file_get_contents(
    "https://numlook.ru/api/v1/phone/validate?phone=" . urlencode($phone) . "&country=" . urlencode($countries) . "&api_key=" . $apiKey
);

$data = json_decode($response, true);
var_dump($data);
带国家数组的POST请求:
PHP
// POST request with array of countries
$apiKey = 'your_key';
$postData = json_encode([
    'phone' => '3201234567',
    'country' => ['IT', 'US', 'DE'],
    'api_key' => $apiKey
]);

$context = stream_context_create([
    'http' => [
        'method' => 'POST',
        'header' => 'Content-Type: application/json',
        'content' => $postData
    ]
]);

$response = file_get_contents('https://numlook.ru/api/v1/phone/validate', false, $context);
$data = json_decode($response, true);
var_dump($data);