Skip to main content
POST
/
proxies
JavaScript
import Kernel from '@onkernel/sdk';

const client = new Kernel({
  apiKey: process.env['KERNEL_API_KEY'], // This is the default and can be omitted
});

const proxy = await client.proxies.create({ type: 'datacenter' });

console.log(proxy.id);
import os
from kernel import Kernel

client = Kernel(
api_key=os.environ.get("KERNEL_API_KEY"), # This is the default and can be omitted
)
proxy = client.proxies.create(
type="datacenter",
)
print(proxy.id)
package main

import (
"context"
"fmt"

"github.com/kernel/kernel-go-sdk"
"github.com/kernel/kernel-go-sdk/option"
)

func main() {
client := kernel.NewClient(
option.WithAPIKey("My API Key"),
)
proxy, err := client.Proxies.New(context.TODO(), kernel.ProxyNewParams{
Type: kernel.ProxyNewParamsTypeDatacenter,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", proxy.ID)
}
curl --request POST \
--url https://api.onkernel.com/proxies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"country": "US",
"name": "<string>",
"protocol": "https",
"bypass_hosts": [
"<string>"
],
"config": {
"country": "US"
}
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.onkernel.com/proxies",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'country' => 'US',
'name' => '<string>',
'protocol' => 'https',
'bypass_hosts' => [
'<string>'
],
'config' => [
'country' => 'US'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.post("https://api.onkernel.com/proxies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"country\": \"US\",\n \"name\": \"<string>\",\n \"protocol\": \"https\",\n \"bypass_hosts\": [\n \"<string>\"\n ],\n \"config\": {\n \"country\": \"US\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.onkernel.com/proxies")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"country\": \"US\",\n \"name\": \"<string>\",\n \"protocol\": \"https\",\n \"bypass_hosts\": [\n \"<string>\"\n ],\n \"config\": {\n \"country\": \"US\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "country": "US",
  "id": "<string>",
  "name": "<string>",
  "protocol": "https",
  "bypass_hosts": [
    "<string>"
  ],
  "last_checked": "2023-11-07T05:31:56Z",
  "ip_address": "192.168.1.1",
  "config": {
    "country": "US"
  }
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}
{
"code": "bad_request",
"message": "Missing required field: app_name",
"details": [
{
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
],
"inner_error": {
"code": "invalid_input",
"message": "Provided version string is not semver compliant"
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Configuration for routing traffic through a proxy.

type
enum<string>
required

Proxy type to use. In terms of quality for avoiding bot-detection, from best to worst: mobile > residential > isp > datacenter.

Available options:
datacenter,
isp,
residential,
mobile,
custom
country
string

ISO 3166 country code. Defaults to US if not provided.

Example:

"US"

name
string

Readable name of the proxy.

protocol
enum<string>
default:https

Protocol to use for the proxy connection.

Available options:
http,
https
bypass_hosts
string[]

Hostnames that should bypass the parent proxy and connect directly.

config
object

Configuration specific to the selected proxy type.

Response

Proxy created successfully

Configuration for routing traffic through a proxy.

type
enum<string>
required

Proxy type to use. In terms of quality for avoiding bot-detection, from best to worst: mobile > residential > isp > datacenter.

Available options:
datacenter,
isp,
residential,
mobile,
custom
country
string

ISO 3166 country code. Defaults to US if not provided.

Example:

"US"

id
string
name
string

Readable name of the proxy.

protocol
enum<string>
default:https

Protocol to use for the proxy connection.

Available options:
http,
https
bypass_hosts
string[]

Hostnames that should bypass the parent proxy and connect directly.

status
enum<string>

Current health status of the proxy.

Available options:
available,
unavailable
last_checked
string<date-time>

Timestamp of the last health check performed on this proxy.

ip_address
string

IP address that the proxy uses when making requests.

Example:

"192.168.1.1"

config
object

Configuration specific to the selected proxy type.