location

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