Skip to content
Guide

MarsProxies Residential Proxies with NSLSolver: Kasada Headers, Akamai Cookies and cf_clearance in Python and Node.js

NSLSolver TeamPublished 9 min read

The MarsProxies dashboard hands out residential proxies as host:port:username:password lines, with the targeting options appended to the password. Most HTTP clients and NSLSolver expect a URL instead, so this guide starts by turning that line into http://username:password@host:port, then uses it to get Kasada x-kpsdk headers, Akamai _abck cookies and Cloudflare cf_clearance cookies on the same IP your scraper uses, in Python and Node.js.

NSLSolver solves on its servers without a browser and bills only successful solves. Cloudflare Challenge, reCAPTCHA v3 and Akamai require a proxy because what they return is tied to the IP that earned it, so the MarsProxies _session option does most of the work.

MarsProxies residential proxy format at a glance

Gateway
ultra.marsproxies.com:44443 (HTTP/HTTPS), :44445 (SOCKS5)
Dashboard format
host:port:USERNAME:PASSWORD_<options>
As a URL
http://USERNAME:PASSWORD_<options>@ultra.marsproxies.com:44443
Sticky session
_session-<8 characters>
Session length
_lifetime-30m, _lifetime-1h, _lifetime-24h
Geo-targeting
_country-us _city-ashburn _state-california

From the MarsProxies help center (help.marsproxies.com), checked 1 December 2026; the developer docs at docs.marsproxies.com require a login. USERNAME and PASSWORD come from your MarsProxies dashboard.

Which NSLSolver solves need a MarsProxies proxy?

Pass the MarsProxies URL in the proxy field of POST https://api.nslsolver.com/solve, then send your own requests through the identical URL so they leave from the same IP.

Solve typeProxyWhat is bound to the IPNSLSolver price per 1,000
Cloudflare ChallengeRequiredcf_clearance cookie$1.00
Akamai Bot Manager (beta)Required_abck and bm_sz cookies$2.00
reCAPTCHA v3RequiredThe score depends on the IP$1.00
KasadaOptional, recommendedThe x-kpsdk-ct session$1.50
Cloudflare TurnstileOptional (proxyless by default)Nothing by default$0.80

Only successful solves are billed. MarsProxies bills its proxy traffic separately, under your MarsProxies plan.

From a MarsProxies dashboard line to a proxy URL

The MarsProxies help center shows residential proxies in the colon-separated form ultra.marsproxies.com:44445:USERNAME:PASSWORD_country-us_city-ashburn_session-wabqla82_lifetime-30m. Read it as host, port, username and password, in that order; the options after the first underscore are part of the password. NSLSolver's proxy field, curl_cffi and undici all expect protocol://username:password@host:port instead.

Mind the port. MarsProxies lists 44443 for HTTP/HTTPS and 44445 for SOCKS5, and some examples use 44445. If you build an http:// URL, use 44443; for 44445, use a socks5:// URL.

OptionExampleNotes from the MarsProxies help center
_country-_country-usTwo-letter country code, lowercase.
_city-_city-ashburnCity targeting, used with the country.
_state-_state-californiaState targeting.
_session-_session-wabqla82An 8-character string. Keep it to stay on one IP; change it to get a new one.
_lifetime-_lifetime-30mHow long the session keeps its IP; examples include 30m, 1h and 24h.

The maximum sticky time differs between MarsProxies' own pages, so check your dashboard before relying on very long sessions. With IP whitelisting (Dashboard, Residential, Whitelist), each whitelisted IP gets a saved configuration and an IP:PORT string instead of credentials.

One sticky session per worker

cf_clearance only works from the IP that earned it and only for the site's Challenge Passage window, 30 minutes by default. Akamai's _abck is tied to its client and IP in the same way, and Kasada expects one IP for the whole x-kpsdk-ct session. A rotating MarsProxies URL, one without _session, breaks all three on the next request.

The pattern that scales is one sticky session per worker: each worker generates its own 8-character _session, solves once through it, and reuses the cookie and User-Agent for its share of the URLs. Four workers means four IPs and four solves, not one solve per request. When a worker starts getting challenges or 403s again, it picks a new _session and solves again.

Choose _lifetime to cover the reuse window (_lifetime-30m for the default Challenge Passage), and keep the location constant. The country, and city if you use one, should be the same for the solve and the replay, and for Cloudflare Challenge an accept_language that fits that country keeps the request headers consistent with the IP.

Python: parallel workers, each with its own cf_clearance

The script parses a dashboard line, builds one sticky session per worker and spreads 40 pages over 4 workers. The options the dashboard may have added to the password are stripped first so the code controls them.

marsproxies_nslsolver.py
# marsproxies_nslsolver.py  (pip install curl_cffi)
import re
import secrets
from concurrent.futures import ThreadPoolExecutor
from curl_cffi import requests

NSL_API_KEY = "nsl_YOUR_API_KEY"
# A line copied from the MarsProxies dashboard: host:port:username:password
DASHBOARD_LINE = "ultra.marsproxies.com:44443:YOUR_USERNAME:YOUR_PASSWORD"
UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
      "(KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36")

HOST, PORT, MARS_USERNAME, MARS_PASSWORD = DASHBOARD_LINE.split(":", 3)
# Drop the options the dashboard may have appended; the code below sets its own.
MARS_PASSWORD = re.split(r"_(?:country|city|state|session|lifetime)-", MARS_PASSWORD)[0]


def mars_proxy(country="us", session=None, lifetime="30m", city=None):
    """MarsProxies residential: options are appended to the PASSWORD with
    underscores. Port 44443 = HTTP/HTTPS (44445 is SOCKS5). No session = rotating."""
    password = f"{MARS_PASSWORD}_country-{country}"
    if city:
        password += f"_city-{city}"
    if session:
        password += f"_session-{session}_lifetime-{lifetime}"  # 8-character session
    return f"http://{MARS_USERNAME}:{password}@{HOST}:44443"


def solve(payload):
    r = requests.post("https://api.nslsolver.com/solve",
                      headers={"X-API-Key": NSL_API_KEY}, json=payload, timeout=180)
    data = r.json()
    if r.status_code != 200 or not data.get("success"):
        raise RuntimeError(f"NSLSolver {r.status_code}: {data.get('error', data)}")
    return data


def browser_session(proxy, user_agent, accept_language=None, impersonate="chrome"):
    # TLS fingerprint must match the UA: "chrome" for a Chrome UA, "safari_ios"
    # for the iPhone Safari UA that a Challenge solve returns
    s = requests.Session(impersonate=impersonate)
    s.proxies = {"http": proxy, "https": proxy}
    s.headers["User-Agent"] = user_agent
    if accept_language:
        s.headers["Accept-Language"] = accept_language
    return s


def worker(urls):
    """One worker = one sticky MarsProxies session = one cf_clearance."""
    proxy = mars_proxy("us", session=secrets.token_hex(4), lifetime="30m")
    cf = solve({
        "type": "challenge",
        "url": "https://cf-protected.example.com/",
        "site_key": "0x4AAAAAAA...",
        "proxy": proxy,
        "accept_language": "en-US,en;q=0.9",
    })
    s = browser_session(proxy, cf["user_agent"], "en-US,en;q=0.9", impersonate="safari_ios")
    for name, value in cf["cookies"].items():  # cf_clearance
        s.cookies.set(name, value)
    return [(u, s.get(u).status_code) for u in urls]


pages = [f"https://cf-protected.example.com/catalog?page={n}" for n in range(1, 41)]
chunks = [pages[i::4] for i in range(4)]  # 4 workers, 4 IPs, 4 solves
with ThreadPoolExecutor(max_workers=4) as pool:
    for result in pool.map(worker, chunks):
        print(result[:2])

Python: Kasada x-kpsdk headers through MarsProxies

p_js_path, fp_host and tl_host come from the browser's Network tab. Send the returned x-kpsdk-* headers through the same session with the same User-Agent, and solve again for every protected call.

marsproxies_nslsolver.py
# Same file: Kasada headers on a MarsProxies sticky session.
kasada_proxy = mars_proxy("us", session=secrets.token_hex(4), lifetime="30m")

k = solve({
    "type": "kasada",
    "url": "https://www.kasada-site.example.com/login",
    "user_agent": UA,
    "ua_version": 145,
    "kasada_config": {
        "p_js_path": "/<uuid-1>/<uuid-2>/p.js",       # the target's real p.js path (DevTools > Network)
        "fp_host": "www.kasada-site.example.com",     # host serving /fp
        "tl_host": "api.kasada-site.example.com",     # host receiving POST /tl
    },
    "proxy": kasada_proxy,
})

api = browser_session(kasada_proxy, UA)
r = api.post("https://api.kasada-site.example.com/v1/search",
             headers=k["headers"], json={"q": "..."})
print(r.status_code)  # x-kpsdk-cd is single-use: solve again for the next call

Python: Akamai _abck cookies through MarsProxies

This example targets a city and uses a one-hour lifetime. Replay all returned cookies with the same User-Agent. Akamai is in beta on NSLSolver.

marsproxies_nslsolver.py
# Same file: Akamai cookies from a city-targeted MarsProxies session.
akamai_proxy = mars_proxy("us", session=secrets.token_hex(4), lifetime="1h", city="ashburn")

ak = solve({
    "type": "akamai",
    "url": "https://akamai-site.example.com/login",
    "user_agent": UA,
    "proxy": akamai_proxy,  # required for akamai
})

shop = browser_session(akamai_proxy, UA, "en-US,en;q=0.9")
for name, value in ak["cookies"].items():  # _abck, bm_sz, ...
    shop.cookies.set(name, value)
r = shop.get("https://akamai-site.example.com/api/products")
print(r.status_code)  # 403 "Access Denied" = solve again

Node.js: the same flows with undici

The Node version runs two Challenge workers in parallel, each with its own ProxyAgent and session. Encode the password with encodeURIComponent, since it carries the options.

marsproxies-nslsolver.mjs
// marsproxies-nslsolver.mjs  (Node 18+, npm i undici)
import { randomBytes } from "node:crypto";
import { fetch, ProxyAgent } from "undici";

const NSL_API_KEY = "nsl_YOUR_API_KEY";
const MARS_USERNAME = "YOUR_USERNAME";
const MARS_PASSWORD = "YOUR_PASSWORD";
const UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " +
  "(KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36";

// Options go in the PASSWORD; 44443 is the HTTP/HTTPS port.
function marsProxy({ country = "us", city, lifetime = "30m" } = {}) {
  let password = MARS_PASSWORD + "_country-" + country;
  if (city) password += "_city-" + city;
  password += "_session-" + randomBytes(4).toString("hex") + "_lifetime-" + lifetime;
  return "http://" + MARS_USERNAME + ":" + encodeURIComponent(password) + "@ultra.marsproxies.com:44443";
}

async function solve(payload) {
  const res = await fetch("https://api.nslsolver.com/solve", {
    method: "POST",
    headers: { "X-API-Key": NSL_API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify(payload),
  });
  const data = await res.json();
  if (!res.ok || !data.success) {
    throw new Error("NSLSolver " + res.status + ": " + (data.error || JSON.stringify(data)));
  }
  return data;
}

const cookieHeader = (cookies) =>
  Object.entries(cookies).map(([k, v]) => k + "=" + v).join("; ");

// 1) Cloudflare Challenge: one sticky session per worker
async function cfWorker(urls) {
  const proxy = marsProxy({ country: "us" });
  const agent = new ProxyAgent(proxy);
  const cf = await solve({
    type: "challenge",
    url: "https://cf-protected.example.com/",
    site_key: "0x4AAAAAAA...",
    proxy,
    accept_language: "en-US,en;q=0.9",
  });
  const headers = { "User-Agent": cf.user_agent, "Accept-Language": "en-US,en;q=0.9", Cookie: cookieHeader(cf.cookies) };
  const statuses = [];
  for (const url of urls) statuses.push((await fetch(url, { dispatcher: agent, headers })).status);
  return statuses;
}
const urls = Array.from({ length: 20 }, (_, i) => "https://cf-protected.example.com/catalog?page=" + (i + 1));
console.log(await Promise.all([cfWorker(urls.slice(0, 10)), cfWorker(urls.slice(10))]));

// 2) Kasada
const kProxy = marsProxy({ country: "us" });
const k = await solve({
  type: "kasada",
  url: "https://www.kasada-site.example.com/login",
  user_agent: UA,
  ua_version: 145,
  kasada_config: {
    p_js_path: "/<uuid-1>/<uuid-2>/p.js",     // the target's real p.js path (DevTools > Network)
    fp_host: "www.kasada-site.example.com",   // host serving /fp
    tl_host: "api.kasada-site.example.com",   // host receiving POST /tl
  },
  proxy: kProxy,
});
const api = await fetch("https://api.kasada-site.example.com/v1/search", {
  method: "POST",
  dispatcher: new ProxyAgent(kProxy),
  headers: { ...k.headers, "User-Agent": UA, "Content-Type": "application/json" },
  body: JSON.stringify({ q: "..." }),
});
console.log("kasada", api.status);

// 3) Akamai, city-targeted
const akProxy = marsProxy({ country: "us", city: "ashburn", lifetime: "1h" });
const ak = await solve({ type: "akamai", url: "https://akamai-site.example.com/login", user_agent: UA, proxy: akProxy });
const products = await fetch("https://akamai-site.example.com/api/products", {
  dispatcher: new ProxyAgent(akProxy),
  headers: { "User-Agent": UA, Cookie: cookieHeader(ak.cookies) },
});
console.log("akamai", products.status);
// Node's fetch does not copy Chrome's TLS fingerprint; if a strict site still
// blocks it, send the follow-up requests from Python with curl_cffi.

Full NSLSolver API reference

Troubleshooting MarsProxies with NSLSolver

For the meaning of each NSLSolver status code and of the Cloudflare, Kasada and Akamai errors, see the anti-bot error-code reference.

SymptomLikely causeFix
Connection fails with an http:// URLPort 44445 (SOCKS5) used with the HTTP scheme.Use port 44443 for http://, or socks5:// with 44445.
407 or authentication errorsThe dashboard line was pasted as is, or the parts were read in the wrong order.Split host:port:username:password and rebuild it as http://username:password@host:port.
cf_clearance accepted, then challenged againNo _session, a session string that changes, or a lifetime shorter than the reuse window.Keep one 8-character _session per worker and a _lifetime of at least 30m.
Wrong countryCountry code not recognised.Use a two-letter lowercase code such as us, as in the help center examples.
NSLSolver 400 Validation failedProxy without a scheme, or a missing required field.Send the full http:// URL and check the field named in the error.
NSLSolver 503 Solve failedThe solve did not complete; it is not billed.Retry with backoff; if it repeats on one session, switch to a new one.

Related

Frequently asked questions

How do I convert a MarsProxies proxy line for NSLSolver?

Split host:port:username:password and rebuild it as http://username:password@host:port, for example http://USERNAME:PASSWORD_country-us_session-a1b2c3d4_lifetime-30m@ultra.marsproxies.com:44443. Put that URL in the proxy field of POST /solve.

Which MarsProxies port should I use?

MarsProxies lists 44443 for HTTP/HTTPS and 44445 for SOCKS5. Use 44443 with an http:// URL, or a socks5:// URL with 44445.

Do I need a sticky MarsProxies session for cf_clearance?

Yes. cf_clearance only works from the IP that earned it, so add an 8-character _session and a _lifetime at least as long as you will reuse the cookie, such as 30m for Cloudflare's default Challenge Passage.

How many sessions should I run?

One per worker. Each worker solves once on its own sticky session and reuses the result, which keeps every cookie on the IP that earned it and spreads requests across several IPs.

What does NSLSolver cost with MarsProxies?

NSLSolver charges per successful solve: $1.00 per 1,000 for Cloudflare Challenge, $1.50 for Kasada and $2.00 for Akamai (beta). Failed solves are not billed. MarsProxies bills its proxy traffic separately under your MarsProxies plan.

Plug your MarsProxies proxies into NSLSolver

Kasada headers, Akamai cookies and cf_clearance through your own residential IPs, solved server-side without a browser. Only successful solves are billed, and you get free credit when you sign up with Google, Gmail or Proton.