get-new-proxy

URL (API endpoint)

Request URL
https://tmproxy.com/api/proxy/get-new-proxy

Request body

api_key 是您从 TMProxy 购买的 API 密钥
id_location 请参阅 此处
id_isp 请参阅 此处

Example Value
{
  "api_key": "API_KEY",
  "id_location": 0,
  "id_isp": 0
}
Schema
responseNewProxy{
  code    integer
  message string
  data    Proxy{
          ip_allow      string
                        允许使用代理的 IP,无需输入代理的用户名和密码(可用于 ipv4 代理)

          username      string
                        代理用户名,用于代理身份验证(适用于 IPv4 代理和 IPv6 代理)

          password      string
                        代理密码,用于验证 socks5/https 代理(可用于 ipv4 代理和 ipv6 代理)

          public_ip     string
                        代理的公共 IP

          isp_name      string
                        ISP 名称

          location_name string
                        区域名称

          socks5        string
                        使用SOCK5 v5协议的代理

          https         string
                        使用 HTTP/HTTPS 协议的代理

          timeout       integer
                        代理有效期. 0 = lifetime

          next_request  integer
                        最短可更换IP的剩余时间

          expired_at    integer
                        代理将在 过期。如果 expired_at 为空,则代理永不过期。

          }
}


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-new-proxy', {
    method: 'POST',
    headers: {
      'accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      "api_key": "API_KEY",
      "id_location": 0,
      "id_isp": 0
    })
  })
  .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-new-proxy"
headers = {
  "accept": "application/json",
  "Content-Type": "application/json"
}
data = {
  "api_key": "API_KEY",
  "id_location": 0,
  "id_isp": 0
}

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-new-proxy"
	data := map[string]interface{}{
		"api_key":     "API_KEY",
		"id_location": 0,
		"id_isp":      0,
	}
	jsonData, _ := json.Marshal(data)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	req.Header.Set("accept", "application/json")
	req.Header.Set("Content-Type", "application/json")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
Curl
curl -X POST "https://tmproxy.com/api/proxy/get-new-proxy" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"api_key\":\"API_KEY\",\"id_location\":0,\"id_isp\":0}"
PHP (cURL)
<?php

$url = "https://tmproxy.com/api/proxy/get-new-proxy";
$data = array(
  "api_key" => "API_KEY", 
  "id_location" => 0,
  "id_isp" => 0
);

$ch = curl_init($url);
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => json_encode($data),
  CURLOPT_HTTPHEADER => [
    "accept: application/json",
    "Content-Type: application/json"
  ],
  CURLOPT_RETURNTRANSFER => true
]);

echo curl_exec($ch);
curl_close($ch);

?>
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-new-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\",\"id_location\":0,\"id_isp\":0}";

        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 data = new { 
        api_key = "5efa7eba36903dbaa143702bc5a03efd", 
        id_location = 0, 
        id_isp = 0 
      };

      var json = System.Text.Json.JsonSerializer.Serialize(data);
      var content = new StringContent(json, Encoding.UTF8, "application/json");

      var response = await client.PostAsync("https://tmproxy.com/api/proxy/get-new-proxy", content);
      response.EnsureSuccessStatusCode();
      var responseBody = await response.Content.ReadAsStringAsync();
      Console.WriteLine(responseBody);
    }
  }
}