get-current-proxy

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