Pular para o conteúdo
Entrar Começar

Atlas API examples

Este conteúdo não está disponível em sua língua ainda.

Each example works as it is: copy it, change the network if you like, and run it. They all credit Atlas with a link, as we ask in the usage notes.

Open an address in your browser and read the answer. Firefox and Chrome both show JSON as a tree you can fold and search.

Show a network’s Atlas Score on your page

Section titled “Show a network’s Atlas Score on your page”

Paste this into any web page. It draws a small card with the network’s current Atlas Score, grade, rank and three key figures, and updates every time the page loads. Change oxylabs in data-network to any network’s slug.

<div class="atlas-card" data-network="oxylabs">Loading the Atlas Score…</div>
<style>
.atlas-card { font-family: system-ui, sans-serif; max-width: 360px; padding: 18px 20px;
border-radius: 14px; background: #0e1424; color: #f4f6fb; border: 1px solid #1f2a40; }
.atlas-card .top { display: flex; align-items: center; gap: 12px; }
.atlas-card img { width: 40px; height: 40px; border-radius: 10px; background: #161d30; padding: 6px; box-sizing: border-box; }
.atlas-card .name { font-weight: 600; font-size: 16px; }
.atlas-card .rank { font-size: 12px; color: #9aa3b5; }
.atlas-card .score { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 12px; }
.atlas-card .score b { font-size: 34px; letter-spacing: -0.02em; }
.atlas-card .grade { font-size: 12px; font-weight: 600; color: #34d399; border: 1px solid #1d5c47; background: #0f2c24; border-radius: 6px; padding: 1px 7px; }
.atlas-card .label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #6b7590; }
.atlas-card .figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.atlas-card .figs div { background: #131a2c; border-radius: 8px; padding: 8px 10px; }
.atlas-card .figs strong { display: block; font-size: 15px; }
.atlas-card .figs span { font-size: 11px; color: #9aa3b5; }
.atlas-card a { display: block; margin-top: 12px; font-size: 12px; color: #5ba3ff; text-decoration: none; }
</style>
<script>
(async () => {
const card = document.querySelector(".atlas-card");
const slug = card.dataset.network; // change the network in data-network
const esc = (t) => String(t).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
try {
const data = await (await fetch("https://atlas.shifter.io/v1/rankings?range=30d")).json();
const n = data.networks.find((x) => x.slug === slug);
const ips = n.uniqueIps >= 1e6 ? (n.uniqueIps / 1e6).toFixed(2) + "M" : n.uniqueIps.toLocaleString("en-US");
card.innerHTML = `
<div class="top">
<img src="https://shifter.io/images/atlas/networks/${slug}.webp" alt="">
<div><div class="name">${esc(n.name)}</div><div class="rank">#${n.rank} of ${n.peers} residential networks</div></div>
</div>
<div class="score"><b>${n.score.toFixed(1)}</b><span class="grade">${n.grade}</span><span class="label">Atlas Score</span></div>
<div class="figs">
<div><strong>${n.successScore.score.toFixed(1)}/10</strong><span>Success</span></div>
<div><strong>${n.latencyP50} ms</strong><span>Latency</span></div>
<div><strong>${ips}</strong><span>Unique IPs</span></div>
</div>
<a href="https://shifter.io/atlas/networks/${slug}">Data: Atlas by Shifter, last 30 days</a>`;
} catch (e) {
card.textContent = "The Atlas Score could not be loaded right now.";
}
})();
</script>
What it shows, live

The top networks with the figures most reviews compare. Change top for more or fewer rows.

<table class="atlas-table">
<thead><tr><th>#</th><th>Network</th><th>Atlas Score</th><th>Success</th><th>Latency</th><th>$ / GB</th></tr></thead>
<tbody><tr><td colspan="6">Loading…</td></tr></tbody>
</table>
<p class="atlas-credit"><a href="https://shifter.io/atlas">Data: Atlas by Shifter</a>, last 30 days.</p>
<style>
.atlas-table { font-family: system-ui, sans-serif; width: 100%; border-collapse: collapse; font-size: 14px;
background: #0e1424; color: #f4f6fb; border-radius: 12px; overflow: hidden; }
.atlas-table th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
color: #6b7590; font-weight: 500; padding: 10px 12px; border-bottom: 1px solid #1f2a40; }
.atlas-table td { padding: 10px 12px; border-bottom: 1px solid #172036; }
.atlas-table tr:last-child td { border-bottom: 0; }
.atlas-table .net { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.atlas-table .net img { width: 22px; height: 22px; border-radius: 6px; }
.atlas-table .grade { font-size: 11px; font-weight: 600; color: #34d399; margin-left: 6px; }
.atlas-credit { font-family: system-ui, sans-serif; font-size: 12px; color: #9aa3b5; }
.atlas-credit a { color: #5ba3ff; }
</style>
<script>
(async () => {
const top = 10; // how many networks to show
const esc = (t) => String(t).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
const data = await (await fetch("https://atlas.shifter.io/v1/rankings?range=30d")).json();
const cell = (v, f) => (v == null ? "–" : f(v));
document.querySelector(".atlas-table tbody").innerHTML = data.networks.slice(0, top).map((n) => `
<tr>
<td>${cell(n.rank, (v) => v)}</td>
<td><span class="net"><img src="https://shifter.io/images/atlas/networks/${n.slug}.webp" alt="">${esc(n.name)}</span></td>
<td>${cell(n.score, (v) => v.toFixed(1))}<span class="grade">${n.grade ?? ""}</span></td>
<td>${cell(n.successScore?.score, (v) => v.toFixed(1) + "/10")}</td>
<td>${cell(n.latencyP50, (v) => v + " ms")}</td>
<td>${cell(n.pricePerGbAtScale, (v) => "$" + v.toFixed(2))}</td>
</tr>`).join("");
})();
</script>
What it shows, live

This Python script saves the leaderboard as atlas.csv, which opens in Excel, Numbers or Google Sheets. It needs only Python 3, nothing to install.

import csv, json, urllib.request
url = "https://atlas.shifter.io/v1/rankings?range=30d"
data = json.load(urllib.request.urlopen(url))
rnd = lambda v, d: None if v is None else round(v, d)
with open("atlas.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["rank", "network", "atlas_score", "grade", "success_of_10",
"latency_p50_ms", "unique_ips", "countries", "uptime_pct", "usd_per_gb"])
for n in data["networks"]:
w.writerow([n["rank"], n["name"],
rnd(n["score"], 1), n["grade"],
rnd((n.get("successScore") or {}).get("score"), 2),
n["latencyP50"], n["uniqueIps"], n["countries"], rnd(n["uptimePct"], 2),
n["pricePerGbAtScale"]])
print("Saved", len(data["networks"]), "networks to atlas.csv")

All of a network’s cities and ISPs in one country, from every page of the coverage answer.

import json, urllib.request
def coverage(slug, country, range_="30d"):
rows, page = [], 1
while True:
url = f"https://atlas.shifter.io/v1/networks/{slug}/coverage?range={range_}&country={country}&page={page}"
d = json.load(urllib.request.urlopen(url))
rows += [dict(zip(d["columns"], r)) for r in d["rows"]]
if page >= d["pages"]:
return rows
page += 1
rows = coverage("decodo", "DE")
print(len(rows), "city and ISP rows in Germany")
for r in rows[:5]:
print(r["city"], r["asnName"], r["ips"], "IPs")

Large countries have many pages; add a short pause between pages if you fetch several networks.

New test events as they arrive, for one network. The feed is cached for 15 seconds, so checking every 30 seconds is plenty.

let last = null;
async function poll() {
const params = new URLSearchParams({ network: "shifter", limit: "50" });
if (last) params.set("after", last);
const { events } = await (await fetch(`https://atlas.shifter.io/v1/events?${params}`)).json();
for (const e of events.slice().reverse()) {
console.log(e.at, e.providerName, e.kind, e.event, e.country);
}
if (events.length) last = events[0].id;
}
poll();
setInterval(poll, 30000);

Atlas publishes new data about once an hour. Instead of fetching everything on a timer, check the version first.

let seen = null;
async function refreshIfNew() {
const { revision } = await (await fetch("https://atlas.shifter.io/v1/version")).json();
if (revision === seen) return;
seen = revision;
const rankings = await (await fetch("https://atlas.shifter.io/v1/rankings?range=30d")).json();
// ...draw your page from rankings
}
refreshIfNew();
setInterval(refreshIfNew, 5 * 60 * 1000);