TMProxy APIs
TMProxy APIs
TMProxy cung cấp API RESTful cho phép bạn tích hợp dịch vụ proxy vào ứng dụng một cách dễ dàng. Tài liệu này cung cấp chi tiết các endpoint, tham số và ví dụ response cho từng API.
POST /location (lấy danh sách các tỉnh)
URL (API endpoint)
Request URL
https://tmproxy.com/api/proxy/locationRequest 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 (lấy Proxy mới)
URL (API endpoint)
Request URL
https://tmproxy.com/api/proxy/get-new-proxyRequest body
api_key là API key bạn mua từ TMProxy
id_location xem tại đậy.
id_isp xem tại đây
Example Value
{
"api_key": "API_KEY",
"id_location": 0,
"id_isp": 0
}Schema
responseNewProxy{
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": "string"
}
} 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 (lấy thông tin Proxy đang sử dụng)
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
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": "string"
}
}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 (lấy thông tin của API Key)
URL (API endpoint)
Request URL
https://tmproxy.com/api/proxy/statsRequest body
api_key là API key bạn mua từ TMProxy
Example Value
{
"api_key": "API_KEY"
}Schema
responseStats{
code* integer
message* string
chi tiet loi
data* {
id_isp integer
id_isp mặc định của api key
id_location integer
id_location mặc định của api key
expired_at string($date-time)
Hết hạn vào
plan string
Tên gói API
price_per_day integer
giá tiền api 1 ngày
timeout integer
thời gian sống của proxy
base_next_request integer
thời gian sử dụng tối thiểu của proxy
api_key string
api key
note string
ghi chú của API
max_ip_per_day integer
Tổng số ip được phép đổi 1 ngày
ip_used_today integer
số ip đã đổi trong ngày
}
}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 (cập nhật ghi chú của API Key)
URL (API endpoint)
Request URL
https://tmproxy.com/api/proxy/noteRequest body
api_key là API key bạn mua từ 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 (lấy thông tin nhà mạng)
URL (API endpoint)
Request URL
https://tmproxy.com/api/proxy/ispRequest 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);
}
}
}