Skip to content

Instantly share code, notes, and snippets.

@guangrei
Last active November 6, 2025 16:36
Show Gist options
  • Select an option

  • Save guangrei/9f0939751771fc41650b13c177200ff7 to your computer and use it in GitHub Desktop.

Select an option

Save guangrei/9f0939751771fc41650b13c177200ff7 to your computer and use it in GitHub Desktop.
Miniproxy Client API
// required npm dependency or javascript cdn: Axios
// uncomment import bellow if you are use nodejs
// import axios from 'axios';
const proxify = axios.create();
proxify.interceptors.request.use(
(config) => {
const originalUrl = config.url;
const encodedTargetUrl = encodeURIComponent(originalUrl);
config.url = `https://miniproxy.koyeb.app/proxy.jsp/${encodedTargetUrl}`;
return config;
},
(error) => {
return Promise.reject(error);
}
);
// example usage
const response = await proxify.get("https://example.com");
console.log(response.data);
<?php
// require composer dependency: guzzlehttp/guzzle
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Psr\Http\Message\RequestInterface;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\ResponseInterface;
class Proxy
{
private Client $client;
// URL proxy ini sudah statis, Kak. Tidak perlu diinput lagi.
private static string $proxyBaseUrl = 'https://miniproxy.koyeb.app/api.jsp/';
public function __construct(array $guzzleOptions = [])
{
// Pastikan tidak ada slash ganda di akhir URL proxy
$baseProxy = rtrim(self::$proxyBaseUrl, '/');
$proxyMiddleware = Middleware::mapRequest(function (RequestInterface $request) use ($baseProxy) {
$originalUrl = (string) $request->getUri();
$encodedUrl = urlencode($originalUrl);
$newUri = new Uri($baseProxy . '/' . $encodedUrl);
return $request->withUri($newUri);
});
$stack = HandlerStack::create();
$stack->push($proxyMiddleware);
$this->client = new Client(array_merge($guzzleOptions, ['handler' => $stack]));
}
public function request(string $method, $uri = '', array $options = []): ResponseInterface
{
return $this->client->request($method, $uri, $options);
}
public function get($uri, array $options = []): ResponseInterface
{
return $this->client->get($uri, $options);
}
public function post($uri, array $options = []): ResponseInterface
{
return $this->client->post($uri, $options);
}
public function put($uri, array $options = []): ResponseInterface
{
return $this->client->put($uri, $options);
}
public function delete($uri, array $options = []): ResponseInterface
{
return $this->client->delete($uri, $options);
}
public function patch($uri, array $options = []): ResponseInterface
{
return $this->client->patch($uri, $options);
}
public function head($uri, array $options = []): ResponseInterface
{
return $this->client->head($uri, $options);
}
public function options($uri, array $options = []): ResponseInterface
{
return $this->client->options($uri, $options);
}
}
# require pip dependency: requests
import requests
import urllib.parse
class newProxy(requests.Session):
def __init__(self, *args, **kwargs):
self.endpoints_request = "https://miniproxy.koyeb.app/proxy.jsp/"
super().__init__(*args, **kwargs)
def request(self, method, url, *args, **kwargs):
url = self.endpoints_request + urllib.parse.quote(url, safe='')
return super().request(method, url, *args, **kwargs)
# example
proxy = newProxy()
response = proxy.get("https://example.com")
print(response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment