Appearance
API概述
欢迎来到IpFlex API文档!本指南将帮助你快速了解和使用IpFlex API。
API基本信息
| 项目 | 说明 |
|---|---|
| Base URL | https://api.ipflex.ink |
| API版本 | v1 |
| 数据格式 | JSON |
| 字符编码 | UTF-8 |
| 认证方式 | Basic Auth 或 API Key |
快速开始
1. 获取API凭证
在开始使用API之前,你需要:
还没有账号?
点击注册,新用户可获得免费试用额度!
2. 发起第一个请求
使用Basic Auth发起第一个请求:
bash
curl -u username:password \
https://api.ipflex.ink/v1/proxy/getpython
import requests
response = requests.get(
'https://api.ipflex.ink/v1/proxy/get',
auth=('username', 'password')
)
print(response.json())javascript
const axios = require('axios');
axios.get('https://api.ipflex.ink/v1/proxy/get', {
auth: {
username: 'username',
password: 'password'
}
})
.then(response => console.log(response.data));php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.ipflex.ink/v1/proxy/get');
curl_setopt($ch, CURLOPT_USERPWD, 'username:password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>3. 查看响应
json
{
"code": 0,
"message": "success",
"data": {
"proxies": [
{
"ip": "203.0.113.42",
"port": 8080,
"country": "US",
"protocol": "http"
}
]
}
}API接口列表
代理管理
| 接口 | 方法 | 描述 |
|---|---|---|
| 生成代理 | POST | 创建静态IP、动态IP、流量代理 |
| 测试代理 | GET | 测试代理连接状态和质量 |
| 删除代理 | DELETE | 删除或批量删除代理 |
地区查询
| 接口 | 方法 | 描述 |
|---|---|---|
| 国家列表 | GET | 获取支持的国家列表 |
| 州/省列表 | GET | 获取国家下的州/省 |
| 城市列表 | GET | 获取州/省下的城市 |
IP信息工具
| 接口 | 方法 | 描述 |
|---|---|---|
| IP基本信息 | GET | 查询IP的地理位置和基本信息 |
| IP质量评分 | GET | 查询IP的质量得分和详细分析 |
认证
| 接口 | 方法 | 描述 |
|---|---|---|
| API认证 | - | 认证方式说明 |
请求格式
认证方式
IpFlex API支持两种认证方式:
方式1:Basic Auth(推荐)
bash
curl -u username:password https://api.ipflex.ink/v1/proxy/get方式2:Bearer Token
bash
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.ipflex.ink/v1/proxy/get推荐
大多数情况下使用Basic Auth更简单方便。
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | 是* | 认证信息(Basic Auth或Bearer Token) |
Content-Type | 否* | POST请求时使用 application/json |
User-Agent | 否 | 推荐设置,便于识别和调试 |
*使用Basic Auth时自动包含Authorization头
请求参数
参数可以通过以下方式传递:
Query Parameters(GET请求)
https://api.ipflex.ink/v1/proxy/get?country=US&type=residentialJSON Body(POST请求)
json{ "country": "US", "type": "residential", "count": 10 }
响应格式
成功响应
所有API接口返回统一的JSON格式:
json
{
"code": 0,
"message": "success",
"data": {
// 具体数据内容
}
}错误响应
json
{
"code": 401,
"message": "authentication failed",
"error": "invalid credentials"
}状态码
| HTTP状态码 | code字段 | 说明 |
|---|---|---|
| 200 | 0 | 成功 |
| 400 | 400 | 请求参数错误 |
| 401 | 401 | 认证失败 |
| 403 | 403 | 权限不足或配额不足 |
| 404 | 404 | 资源不存在 |
| 429 | 429 | 请求频率过高 |
| 500 | 500 | 服务器内部错误 |
查看完整错误码
访问错误码说明查看所有错误码及解决方案。
限制说明
频率限制
| 套餐类型 | 请求频率限制 |
|---|---|
| 免费版 | 100次/分钟 |
| 基础版 | 1000次/分钟 |
| 专业版 | 5000次/分钟 |
| 企业版 | 无限制 |
超出频率限制将返回 429 Too Many Requests 错误。
json
{
"code": 429,
"message": "rate limit exceeded",
"error": "too many requests, please try again later"
}建议
实现指数退避重试机制来处理频率限制。
配额限制
每个账户都有使用配额限制:
- 请求数配额 - 每月可发起的API请求数量
- 流量配额 - 代理流量使用量(GB)
- IP数量 - 同时可持有的代理IP数量
查询剩余配额:
bash
curl -u username:password https://api.ipflex.ink/v1/account/quotaSDK和工具
官方SDK
IpFlex提供以下官方SDK:
推荐使用SDK
使用官方SDK可以简化开发,自动处理重试、错误等。
第三方集成
| 工具 | 集成方式 |
|---|---|
| Scrapy | 中间件集成 |
| Selenium | 代理配置 |
| Puppeteer | 代理设置 |
测试工具
在线测试
使用我们的在线API测试工具:API Console
cURL测试
bash
# 测试获取代理
curl -u username:password \
"https://api.ipflex.ink/v1/proxy/get?country=US"
# 测试账户信息
curl -u username:password \
https://api.ipflex.ink/v1/account/infoPostman集合
下载我们的 Postman Collection 快速测试所有API。
最佳实践
1. 错误处理
python
import requests
try:
response = requests.get(
'https://api.ipflex.ink/v1/proxy/get',
auth=('username', 'password'),
timeout=30
)
response.raise_for_status()
data = response.json()
if data['code'] == 0:
print("成功:", data['data'])
else:
print(f"API错误: {data['message']}")
except requests.exceptions.HTTPError as e:
if e.response.status_code == 401:
print("认证失败,请检查用户名密码")
elif e.response.status_code == 429:
print("请求过于频繁,请稍后重试")
else:
print(f"HTTP错误: {e}")
except requests.exceptions.Timeout:
print("请求超时")
except Exception as e:
print(f"未知错误: {e}")2. 重试机制
python
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
session = requests.Session()
retry_strategy = Retry(
total=3,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504]
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount('https://', adapter)
response = session.get(
'https://api.ipflex.ink/v1/proxy/get',
auth=('username', 'password')
)3. 监控日志
python
import logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s'
)
def api_request(url, **kwargs):
"""带日志的API请求"""
logging.info(f"发起请求: {url}")
try:
response = requests.get(url, **kwargs)
logging.info(f"请求成功: {response.status_code}")
return response
except Exception as e:
logging.error(f"请求失败: {e}")
return None版本历史
v1.2.0 (2024-01-08)
- ✨ 新增批量获取代理接口
- ✨ 支持按城市筛选代理
- 🐛 修复认证token过期问题
- 📝 更新错误码文档
v1.1.0 (2023-12-15)
- ✨ 新增账户统计接口
- ✨ 支持Webhook通知
- 🐛 优化代理获取速度
v1.0.0 (2023-11-01)
- 🎉 首次发布
变更日志
查看完整 CHANGELOG.md
支持和反馈
获取帮助
- 📖 常见问题
- 💻 GitHub Issues
- 📧 技术支持:support@ipflex.com
- 💬 24/7在线客服
API状态
查看 API状态页面 了解服务可用性。
反馈建议
我们欢迎你的反馈:
- 在 GitHub Discussions 提出建议
- 填写反馈表单
- 发送邮件到 feedback@ipflex.com
下一步
现在你已经了解了API的基本信息,接下来:
推荐阅读
建议先阅读第一次API调用完成第一个请求。