npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spacenetwork/spacerouter

v0.1.0

Published

JavaScript SDK for the Space Router residential proxy network

Downloads

47

Readme

SpaceRouter JavaScript SDK

JavaScript/TypeScript SDK for routing HTTP requests through the Space Router residential proxy network.

Installation

npm install spacerouter

Quick Start

import { SpaceRouter } from "spacerouter";

const client = new SpaceRouter("sr_live_YOUR_API_KEY", {
  gatewayUrl: "http://gateway:8080",
});

const response = await client.get("https://httpbin.org/ip");
console.log(await response.json()); // { origin: "residential-ip" }
console.log(response.nodeId);       // node that handled the request
console.log(response.requestId);    // unique request ID for tracing

client.close();

IP Targeting

Route requests through specific IP types or geographic regions:

// Target residential IPs in the US
const client = new SpaceRouter("sr_live_xxx", {
  ipType: "residential",
  region: "US",
});

// Target mobile IPs in South Korea
const mobile = new SpaceRouter("sr_live_xxx", {
  ipType: "mobile",
  region: "Seoul, KR",
});

// Change routing on the fly
const jpClient = client.withRouting({ ipType: "mobile", region: "JP" });

Available IP types: residential, mobile, datacenter, business

SOCKS5 Proxy

const client = new SpaceRouter("sr_live_xxx", {
  protocol: "socks5",
  gatewayUrl: "socks5://gateway:1080",
});

const response = await client.get("https://httpbin.org/ip");

API Key Management

import { SpaceRouterAdmin } from "spacerouter";

const admin = new SpaceRouterAdmin("http://localhost:8000");

// Create a key (raw value only available here)
const key = await admin.createApiKey("my-agent", { rateLimitRpm: 120 });
console.log(key.api_key); // sr_live_...

// List keys
const keys = await admin.listApiKeys();
for (const k of keys) {
  console.log(k.name, k.key_prefix, k.is_active);
}

// Revoke a key
await admin.revokeApiKey(key.id);

Error Handling

import { SpaceRouter } from "spacerouter";
import {
  AuthenticationError,   // 407 - invalid API key
  RateLimitError,        // 429 - rate limit exceeded
  NoNodesAvailableError, // 503 - no residential nodes online
  UpstreamError,         // 502 - target unreachable via node
} from "spacerouter";

const client = new SpaceRouter("sr_live_xxx");
try {
  const response = await client.get("https://example.com");
} catch (e) {
  if (e instanceof RateLimitError) {
    console.log(`Rate limited, retry after ${e.retryAfter}s`);
  } else if (e instanceof NoNodesAvailableError) {
    console.log("No nodes available, try again later");
  } else if (e instanceof UpstreamError) {
    console.log(`Node ${e.nodeId} could not reach target`);
  } else if (e instanceof AuthenticationError) {
    console.log("Check your API key");
  }
}

Note: HTTP errors from the target website (e.g. 404, 500) are not thrown as exceptions. Only proxy-layer errors produce exceptions.

Configuration

| Parameter | Default | Description | |-------------|----------------------------|------------------------------------------| | apiKey | (required) | API key (sr_live_...) | | gatewayUrl| "http://localhost:8080" | Proxy gateway URL | | protocol | "http" | "http" or "socks5" | | ipType | undefined | IP type filter | | region | undefined | Region filter (substring match) | | timeout | 30000 | Request timeout in milliseconds |