1、示例说明
以【地区查询】API请求路径为:https://apis.ipfoxy.com/ip/open-api/area-list
API请求域名为:https://apis.ipfoxy.com,地区查询Path: /ip/open-api/area-list,Method: GET
请求header固定包含api-token(代理密钥)
,api-id(用户ID)
获取方式如下图,单账户的请求频率限制为 1分钟内 60次
2、Python调用示例
import http.client
conn = http.client.HTTPSConnection("apis.ipfoxy.com")
headers = {
'api-token': "填入秘钥",
'api-id': "填入用户id"
}
conn.request("GET", "/ip/open-api/area-list", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
3、Golang调用示例
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://apis.ipfoxy.com/ip/open-api/area-list"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api-token", "填入秘钥")
req.Header.Add("api-id", "填入用户id")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
3、Node.Js-Native调用示例
const http = require('https');
const options = {
method: 'GET',
hostname: 'apis.ipfoxy.com',
port: null,
path: '/ip/open-api/area-list',
headers: {
'api-token': '填入秘钥',
'api-id': '填入用户id'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
4、PHP-Http调用示例
<?php
$request = new HttpRequest();
$request->setUrl('https://apis.ipfoxy.com/ip/open-api/area-list');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders([
'api-token' => '填入秘钥',
'api-id' => '填入用户id'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
5、C#调用示例
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://apis.ipfoxy.com/ip/open-api/area-list"),
Headers =
{
{ "api-token", "填入秘钥" },
{ "api-id", "填入用户id" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
6、C语言调用示例
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://apis.ipfoxy.com/ip/open-api/area-list");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "api-token: 填入秘钥");
headers = curl_slist_append(headers, "api-id: 填入用户id");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
7、Java调用示例
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "https://apis.ipfoxy.com/ip/open-api/area-list")
.setHeader("api-token", "填入秘钥")
.setHeader("api-id", "填入用户id")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();