get-current-proxy
URL (API endpoint)
Request URL
https://tmproxy.com/api/proxy/get-current-proxyRequest body
api_key là API key bạn mua từ TMProxy
Example Value
{
"api_key": "API_KEY"
}Schema
responseCurrentProxy{
code integer
message string
data
Proxy{
ip_allow string
IP được phép sử dụng proxy mà không cần nhập username-password của proxy (khả dụng trên ipv4 proxy)
username string
username proxy, dùng để xác thực proxy ( khả dụng trên ipv4 proxy và ipv6 proxy)
password string
password proxy, dùng để xác thực proxy socks5/https ( khả dụng trên ipv4 proxy và ipv6 proxy)
public_ip string
IP Public của proxy
isp_name string
tên ISP
location_name string
tên khu vực
socks5 string
proxy sử dụng giao thức SOCK5 v5
https string
proxy sử dụng giao thức http/https
timeout integer
thời gian còn sống của proxy. 0 = lifetime
next_request integer
thời gian tối thiểu còn lại có thể đổi ip
expired_at integer
proxy sẽ hết hạn vào. nếu expired_at trống thì proxy không hết hạn
}
} Server response OK
Response body - code 200
{
"code": 0,
"message": "string",
"data": {
"ip_allow": "string",
"username": "string",
"password": "string",
"public_ip": "string",
"isp_name": "string",
"location_name": "string",
"socks5": "string",
"https": "string",
"timeout": 0,
"next_request": 0,
"expired_at": 0
}
}Example Code
JavaScript (fetch API)
fetch('https://tmproxy.com/api/proxy/get-current-proxy', {
method: 'POST',
headers: {
'accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({ "api_key": "API_KEY" })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));Python (requests library)
import requests
url = "https://tmproxy.com/api/proxy/get-current-proxy"
headers = {
"accept": "application/json",
"Content-Type": "application/json"
}
data = {
"api_key": "API_KEY"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
url := "https://tmproxy.com/api/proxy/get-current-proxy"
data := map[string]string{"api_key": "API_KEY"}
jsonData, err := json.Marshal(data)
if err != nil {
panic(err)
}
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
panic(err)
}
req.Header.Set("accept", "application/json")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("response Status:", resp.Status)
body, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(body))
}Curl
curl -X POST "https://tmproxy.com/api/proxy/get-current-proxy" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"api_key\":\"API_KEY\"}"PHP (cURL)
<?php
$url = "https://tmproxy.com/api/proxy/get-current-proxy";
$data = array("api_key" => "API_KEY");
$jsonData = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"accept: application/json",
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
die("cURL Error: " . curl_error($ch));
}
curl_close($ch);
if (json_last_error() !== JSON_ERROR_NONE) {
die("JSON Error: " . json_last_error_msg());
}
echo $response;
?>
Java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("https://tmproxy.com/api/proxy/get-current-proxy");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Accept", "application/json");
con.setDoOutput(true);
String jsonInputString = "{\"api_key\":\"API_KEY\"}";
try(OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try(BufferedReader br = new BufferedReader(
new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
}
}C#
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public class Example
{
public static async Task Main(string[] args)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var content = new StringContent("{\"api_key\":\"API_KEY\"}", Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://tmproxy.com/api/proxy/get-current-proxy", content);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
}