TMProxy APIs

TMProxy APIs

POST /location (get TMProxy locations)

URL (API endpoint)

Request URL
https://tmproxy.com/api/proxy/location

Request body

Example Value
{}
Schema
responseLocation{
  code    integer
  message string
  data	{
    locations	[
      LocationModel{
        id_location integer
        name        string
                    name location
      }
    ]
  }
}

Server response OK

Response body - code 200
{'code': 0, 'message': '', 'data': {'locations': [{'id_location': 1, 'name': '1. Random'}, {'id_location': 2, 'name': '2. Bac Ninh (Thread: High)'}, {'id_location': 4, 'name': '4. Binh Duong (Thread: High)'}, {'id_location': 5, 'name': '5. Da Nang (Thread: Moderate)'}, {'id_location': 7, 'name': '7. Can Tho (Thread: Very High)'}, {'id_location': 9, 'name': '9. TP Ho Chi Minh (Thread: Very High)'}, {'id_location': 10, 'name': '10. Ha Noi (Thread: High)'}, {'id_location': 11, 'name': '11. Khanh Hoa (Thread: High)'}, {'id_location': 12, 'name': '12. Dong Nai (Thread: High)'}, {'id_location': 13, 'name': '13. Long An (Thread: Moderate)'}, {'id_location': 14, 'name': '14. Tay Ninh (Thread: High)'}, {'id_location': 18, 'name': '18. Thai Nguyen (Thread: Moderate)'}, {'id_location': 19, 'name': '19. Ca Mau (Thread: Moderate)'}, {'id_location': 20, 'name': '20. Dak Lak (Thread: Moderate)'}, {'id_location': 21, 'name': '21. Quy Nhon (Thread: High)'}, {'id_location': 22, 'name': '22. Hai Duong (Thread: Moderate)'}, {'id_location': 23, 'name': '23. Hung Yen (Thread: Moderate)'}, {'id_location': 24, 'name': '24. Thua Thien Hue (Thread: High)'}, {'id_location': 25, 'name': '25. Binh Thuan (Thread: High)'}, {'id_location': 26, 'name': '26. Vinh Long (Thread: High)'}, {'id_location': 27, 'name': '27. Quang Binh (Thread: Moderate)'}, {'id_location': 28, 'name': '28. An Giang (Thread: Moderate)'}]}}

Example Code

JavaScript
fetch('https://tmproxy.com/api/proxy/location', {
    method: 'POST',
    headers: { 'accept': 'application/json' },
    body: JSON.stringify({}) 
  })
  .then(response => response.json())
  .then(data => {
    if (data.code === 0 && data.data?.locations) {
      data.data.locations.forEach((location, index) => {
        console.log(`Location ${index + 1}:`, location);
      });
    } else {
      console.error("Error:", data.msg || "Unknown error");
    }
  })
  .catch(error => console.error("Error:", error));
Python (requests library)
import requests

url = "https://tmproxy.com/api/proxy/location"
headers = {
  "accept": "application/json",
  "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json={})

print(response.json())
Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	url := "https://tmproxy.com/api/proxy/location"
	req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(`{}`)))
	if err != nil {
		panic(err)
	}
	req.Header.Set("accept", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	if resp.StatusCode != http.StatusOK {
		fmt.Println("Error:", resp.Status)
		fmt.Println("Response Body:", string(body))
		return
	}

	var data map[string]interface{}
	err = json.Unmarshal(body, &data)
	if err != nil {
		panic(err)
	}

	if data["code"].(float64) == 0 && data["data"] != nil {
		locations := data["data"].(map[string]interface{})["locations"].([]interface{})
		for i, location := range locations {
			fmt.Printf("Location %d: %+v\n", i+1, location)
		}
	} else {
		fmt.Println("Error:", data["msg"])
	}
}
Curl
curl -X POST "https://tmproxy.com/api/proxy/location" -H "accept: application/json" -H "Content-Type: application/json" -d "{}"
PHP (cURL)
<?php

$url = "https://tmproxy.com/api/proxy/location";

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => "{}",
    CURLOPT_HTTPHEADER => ['accept: application/json'], 
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);

if ($data && $data['code'] === 0 && isset($data['data']['locations'])) {
    foreach ($data['data']['locations'] as $index => $location) {
        echo "Location " . ($index + 1) . ": ";
        print_r($location); 
    }
} else {
    echo "Error: " . ($data['msg'] ?? 'Unknown error') . "\n";
}
?>
Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
import org.json.JSONArray;

public class Main {
    public static void main(String[] args) throws IOException {
        URL url = new URL("https://tmproxy.com/api/proxy/location");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Accept", "application/json");
        connection.setDoOutput(true);

        try (OutputStream os = connection.getOutputStream()) {
            byte[] input = "{}".getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        int responseCode = connection.getResponseCode();

        if (responseCode == HttpURLConnection.HTTP_OK) {
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }

                JSONObject data = new JSONObject(response.toString()).getJSONObject("data");
                JSONArray locations = data.getJSONArray("locations");
                for (int i = 0; i < locations.length(); i++) {
                    System.out.println("Location " + (i + 1) + ": " + locations.getJSONObject(i).toString(2));
                }
            }
        } else {
            System.out.println("Error: " + responseCode);
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                System.out.println("Error Response Body: " + response.toString());
            }
        }
        connection.disconnect();
    }
}
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("{}", Encoding.UTF8, "application/json");

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

POST /get-new-proxy (get new proxy information)

URL (API endpoint)

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

Request body

api_key is the API key you purchased from TMProxy
view id_location here.
view id_isp here

Example Value
{
  "api_key": "API_KEY",
  "id_location": 0,
  "id_isp": 0
}
Schema
responseNewProxy{
  code    integer
  message string
  data    Proxy{
          ip_allow      string
                        Allowed IP to use the proxy without needing a proxy username-password (available on IPv4 proxies)

          username      string
                        Proxy username, used for proxy authentication (available on IPv4 and IPv6 proxies)

          password      string
                        Proxy password, used for proxy authentication of SOCKS5/HTTPS (available on IPv4 and IPv6 proxies)

          public_ip     string
                        Public IP of the proxy

          isp_name      string
                        ISP name

          location_name string
                        Location name

          socks5        string
                        Proxy using SOCKS protocol v5

          https         string
                        Proxy using HTTP/HTTPS protocol

          timeout       integer
                        Proxy's remaining lifetime. 0 = lifetime

          next_request  integer
                        Minimum remaining time before the IP can be changed

          expired_at    integer
                        Proxy expiration time. If expired_at is empty, the proxy does not expire

          }
}

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);
    }
  }
}

POST /get-current-proxy (get current proxy information)

URL (API endpoint)

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

Request body

api_key is the API key you purchased from TMProxy

Example Value
{
  "api_key": "API_KEY"
}
Schema
responseCurrentProxy{
  code	  integer
  message string
  data
          Proxy{
          ip_allow      string
                        Allowed IP to use the proxy without needing a proxy username-password (available on IPv4 proxies)

          username      string
                        Proxy username, used for proxy authentication (available on IPv4 and IPv6 proxies)

          password      string
                        Proxy password, used for proxy authentication of SOCKS5/HTTPS (available on IPv4 and IPv6 proxies)

          public_ip     string
                        Public IP of the proxy

          isp_name      string
                        ISP name

          location_name string
                        Location name

          socks5        string
                        Proxy using SOCKS protocol v5

          https         string
                        Proxy using HTTP/HTTPS protocol

          timeout       integer
                        Proxy's remaining lifetime. 0 = lifetime

          next_request  integer
                        Minimum remaining time before the IP can be changed

          expired_at    integer
                        Proxy expiration time. If expired_at is empty, the proxy does not expire

          }
}   

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);
    }
  }
}

POST /stats (get API Key information)

URL (API endpoint)

Request URL
https://tmproxy.com/api/proxy/stats

Request body

api_key is the API key you purchased from TMProxy

Example Value
{
  "api_key": "API_KEY"
}
Schema
responseStats{
  code*     integer
  message*  string
            Error details

  data*     {
            id_isp            integer
                              Default id_isp of the API key

            id_location       integer
                              Default id_location of the API key

            expired_at        string($date-time)
                              Expiration time

            plan              string
                              API plan name

            price_per_day     integer
                              API price per day

            timeout           integer
                              Proxy's lifespan

            base_next_request integer
                              Minimum usage time of the proxy

            api_key           string
                              API key

            note              string
                              Note for the API Key

            max_ip_per_day    integer
                              Total number of IPs allowed to be changed per day

            ip_used_today     integer
                              Number of IPs changed today
            }
}

Server response OK

Response body - code 200
{
  "code": 0,
  "message": "string",
  "data": {
    "id_isp": 0,
    "id_location": 0,
    "expired_at": "2025-01-15T07:35:03.473Z",
    "plan": "string",
    "price_per_day": 0,
    "timeout": 0,
    "base_next_request": 0,
    "api_key": "string",
    "note": "string",
    "max_ip_per_day": 0,
    "ip_used_today": 0
  }
}

Example Code

JavaScript (fetch API)
fetch('https://tmproxy.com/api/proxy/stats', {
    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/stats"
headers = {
  'accept': 'application/json',
  'Content-Type': 'application/json'
}
data = {
  "api_key": "API_KEY"
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://tmproxy.com/api/proxy/stats"
	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("Response Body:", string(body))

	var responseData map[string]interface{}
	if err := json.Unmarshal(body, &responseData); err != nil {
		panic(err)
	}

	fmt.Println("Response Data:", responseData)

	if successMsg, ok := responseData["success_message"]; ok {
		fmt.Println("Success Message:", successMsg)
	}
}
Curl
curl -X POST "https://tmproxy.com/api/proxy/stats" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"api_key\":\"API_KEY\"}"
PHP (cURL)
<?php
$url = "https://tmproxy.com/api/proxy/stats";
$data = array("api_key" => "API_KEY");  
$jsonData = json_encode($data);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
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);
curl_close($ch);

echo $response;
?>
Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

public class Main {
    public static void main(String[] args) throws IOException {
        try {
            URL url = new URI("https://tmproxy.com/api/proxy/stats").toURL(); 
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod("POST");
            con.setRequestProperty("accept", "application/json");
            con.setRequestProperty("Content-Type", "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());
            }
        } catch (URISyntaxException e) {
            System.err.println("Lỗi khi tạo URL: " + e.getMessage());
        }
    }
}
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/stats", content);
      var responseString = await response.Content.ReadAsStringAsync();

      Console.WriteLine(responseString);
    }
  }
}

POST /note (update API Key note)

URL (API endpoint)

Request URL
https://tmproxy.com/api/proxy/note

Request body

api_key is the API key you purchased from TMProxy

Example Value
{
  "api_key": "API_KEY",
  "note": "thông_tin_cần_note"
}
Schema
responseNote{
  code    integer
  message string
}

Server response OK

Response body - code 200
{
  "code": 0,
  "message": "string"
}

Example Code

JavaScript (fetch API)
fetch('https://tmproxy.com/api/proxy/note', {
    method: 'POST',
    headers: {
      'accept': 'application/json',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      "api_key": "API_KEY",
      "note": "string"
    })
  })
  .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/note"
headers = {
  "accept": "application/json",
  "Content-Type": "application/json"
}
data = {
  "api_key": "API_KEY",
  "note": "string"
}

response = requests.post(url, headers=headers, json=data)
print(response.text)
Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://tmproxy.com/api/proxy/note"
	data := map[string]string{
		"api_key": "API_KEY",
		"note":    "YOUR_NOTE",
	}
	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("response Body:", string(body))
}
Curl
curl -X POST "https://tmproxy.com/api/proxy/note" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"api_key\":\"API_KEY\",\"note\":\"YOUR_NOTE\"}"
PHP (cURL)
<?php
// PHP (cURL)
$url = "https://tmproxy.com/api/proxy/note";
$data = array(
  "api_key" => "API_KEY", 
  "note" => "YOUR_NOTE" 
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

echo $response . "\n";

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch) . "\n";
}
curl_close($ch);
?>
Java
import java.io.BufferedReader;
import java.io.IOException;
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 IOException {
        String apiKey = "API_KEY"; //
        String note = "YOUR_NOTE";      
        URL url = new URL("https://tmproxy.com/api/proxy/note");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/json; utf-8");
        connection.setRequestProperty("Accept", "application/json");
        connection.setDoOutput(true); 

        String jsonInputString = String.format("{\"api_key\": \"%s\", \"note\": \"%s\"}", apiKey, note);

        try (OutputStream os = connection.getOutputStream()) {
            byte[] input = jsonInputString.getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        int responseCode = connection.getResponseCode();
        System.out.println("Response Code: " + responseCode);

        try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"))) {
            StringBuilder response = new StringBuilder();
            String responseLine = null;
            while ((responseLine = br.readLine()) != null) {
                response.append(responseLine.trim());
            }
            System.out.println("Response Body: " + response.toString());
        }
        connection.disconnect();
    }
}
C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

public class Program
{
    public static async Task Main(string[] args)
    {
        using (var client = new HttpClient())
        {
            var url = "https://tmproxy.com/api/proxy/note";
            var data = new { api_key = "API_KEY", note = "YOUR_NOTE" }; // Thay YOUR_ACTUAL_NOTE bằng nội dung note
            var json = JsonSerializer.Serialize(data);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await client.PostAsync(url, content);
            var responseString = await response.Content.ReadAsStringAsync();

            Console.WriteLine(responseString);
        }
    }
}

POST /ISP (get Internet Service Provider information)

URL (API endpoint)

Request URL
https://tmproxy.com/api/proxy/isp

Request body

Example Value
{}
Schema
responseIsp{
  code    integer
  message string
  data	{
    locations	[
      ISPModel{
        id_isp  integer
        name    string
                name isp
      }
    ]
  } 
}

Server response OK

Response body - code 200
{
  "code": 0,
  "message": "string",
  "data": {
    "list_isp": [
      {
        "id_isp": 0,
        "name": "Random"
      },
      {
        "id_isp": 1,
        "name": "Viettel"
      },
      {
        "id_isp": 2,
        "name": "VNPT"
      }
    ]
  }
}

Example Code

JavaScript (fetch API)
fetch('https://tmproxy.com/api/proxy/isp', {
  method: 'POST',
  headers: { 'accept': 'application/json' }
})
.then(response => response.json())
.then(data => {
  if (data.code === 0 && data.data?.list_isp) {
    data.data.list_isp.forEach((isp, index) => {
      console.log(`ISP ${index + 1}:`, isp); 
    });
  } else {
    console.error("Error:", data.msg || "Unknown error");
  }
})
.catch(error => console.error("Error:", error));
Python (requests library)
import requests

url = "https://tmproxy.com/api/proxy/isp"
headers = {
  "accept": "application/json",
  "Content-Type": "application/json"
}

response = requests.post(url, headers=headers, json={})

print(response.json())
Go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	url := "https://tmproxy.com/api/proxy/isp"
	req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(`{}`)))
	if err != nil {
		panic(err)
	}
	req.Header.Set("accept", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		fmt.Println("Error:", resp.Status)
		body, _ := ioutil.ReadAll(resp.Body)
		fmt.Println("Response Body:", string(body))
		return
	}

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}

	var data map[string]interface{}
	err = json.Unmarshal(body, &data)
	if err != nil {
		panic(err)
	}

	if data["code"].(float64) == 0 && data["data"] != nil {
		isps := data["data"].(map[string]interface{})["list_isp"].([]interface{})
		for i, isp := range isps {
			fmt.Printf("ISP %d: %+v\n", i+1, isp)
		}
	} else {
		fmt.Println("Error:", data["msg"])
	}
}
Curl
curl -X POST "https://tmproxy.com/api/proxy/isp" -H "accept: application/json" -H "Content-Type: application/json" -d "{}"
PHP (cURL)
<?php
$url = "https://tmproxy.com/api/proxy/isp";

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => "{}",
    CURLOPT_HTTPHEADER => ['accept: application/json'], 
    CURLOPT_RETURNTRANSFER => true,
]);

$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);

if ($data && $data['code'] === 0 && isset($data['data']['list_isp'])) {
    foreach ($data['data']['list_isp'] as $index => $isp) {
        echo "ISP " . ($index + 1) . ": ";
        print_r($isp); 
    }
} else {
    echo "Error: " . ($data['msg'] ?? 'Unknown error') . "\n";
}

?>
Java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
import org.json.JSONArray;

public class Main {
    public static void main(String[] args) throws IOException {
        URL url = new URL("https://tmproxy.com/api/proxy/isp");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Accept", "application/json");
        connection.setDoOutput(true);

        try (OutputStream os = connection.getOutputStream()) {
            byte[] input = "{}".getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        int responseCode = connection.getResponseCode();

        if (responseCode == HttpURLConnection.HTTP_OK) {
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }

                JSONObject data = new JSONObject(response.toString()).getJSONObject("data");
                JSONArray isps = data.getJSONArray("list_isp");
                for (int i = 0; i < isps.length(); i++) {
                    System.out.println("ISP " + (i + 1) + ": " + isps.getJSONObject(i).toString(2));
                }
            }
        } else {
            System.out.println("Error: " + responseCode);
            try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getErrorStream(), "utf-8"))) {
                StringBuilder response = new StringBuilder();
                String responseLine;
                while ((responseLine = br.readLine()) != null) {
                    response.append(responseLine.trim());
                }
                System.out.println("Error Response Body: " + response.toString());
            }
        }
        connection.disconnect();
    }
}
C#
// C# (HttpClient)
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("{}", Encoding.UTF8, "application/json");

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