100%
TypeScript
24.5k
Weekly Downloads
<15KB
Gzipped Size
Node 18+
Min Version

# Installation

Install the JobSphere SDK using your preferred package manager. The SDK is compatible with Node.js 18+, Deno, Bun, and modern browsers.

npm
# Using npm
npm install @jobsphere/sdk

# Using yarn
yarn add @jobsphere/sdk

# Using pnpm
pnpm add @jobsphere/sdk

# Using bun
bun add @jobsphere/sdk
Peer Dependencies

The SDK automatically includes type definitions. No additional packages needed for TypeScript support. For browser usage, ensure your bundler supports ES modules.

Requirements

Runtime Minimum Version Notes
Node.js 18.0+ Recommended: 20 LTS
Deno 1.38+ Use import maps
Bun 1.0+ Full compatibility
Browser ES2020+ Chrome 80+, Firefox 78+

# Quick Start

Get up and running in under a minute. Here's how to make your first API call with the JobSphere SDK.

Type-Safe

Full TypeScript support with auto-generated types

SDK + REST

Use the SDK or raw REST calls interchangeably

Secure

Built-in auth rotation and encrypted storage

Auto-Retry

Exponential backoff with circuit breaker

Streaming

Real-time webhooks and SSE support

Lightweight

Under 15KB gzipped, tree-shakeable

Basic Example

TypeScript
import { JobSphere } from "@jobsphere/sdk";

// Initialize the SDK
const jobsphere = new JobSphere({
  apiKey: process.env.JOBSHERE_API_KEY,
  environment: "production" // or "sandbox"
});

// Search for jobs
const jobs = await jobsphere.jobs.search({
  query: "Senior Software Engineer",
  location: "San Francisco, CA",
  remote: true,
  limit: 20,
  sortBy: "relevance"
});

console.log(`Found ${jobs.total} jobs`);

// Iterate through results
for (const job of jobs.data) {
  console.log(`- ${job.title} at ${job.company.name}`);
}
Sandbox Mode

Use environment: "sandbox" during development to avoid affecting live data. The sandbox comes with pre-loaded test data and mock companies.

# Authentication

The JobSphere SDK supports multiple authentication methods. API keys are recommended for server-side applications, while OAuth 2.0 is ideal for user-facing applications.

API Key Authentication

TypeScript
import { JobSphere } from "@jobsphere/sdk";

// Option 1: Pass API key directly
const client = new JobSphere({
  apiKey: "js_live_sk_abc123..."
});

// Option 2: Use environment variable (recommended)
const client = new JobSphere({
  apiKey: process.env.JOBSHERE_API_KEY
});

// Option 3: Use a secret manager
import { secretManager } from "@your-app/secrets";
const client = new JobSphere({
  apiKey: await secretManager.get("jobsphere_api_key")
});

OAuth 2.0 (User Delegation)

TypeScript
import { JobSphere, OAuthConfig } from "@jobsphere/sdk";

const oauthConfig: OAuthConfig = {
  clientId: "your_client_id",
  clientSecret: "your_client_secret",
  redirectUri: "https://yourapp.com/callback",
  scopes: ["jobs:read", "jobs:write", "applications:write"]
};

const client = new JobSphere({
  auth: oauthConfig
});

// Generate authorization URL
const authUrl = client.oauth.getAuthorizationUrl();
console.log(`Visit: ${authUrl}`);

// Exchange code for tokens
const tokens = await client.oauth.exchangeCode("authorization_code");
console.log("Access token:", tokens.accessToken);
Security Warning

Never expose your API key in client-side code or public repositories. Use environment variables or a secret management service for production deployments.

# Jobs Module

The Jobs module is the core of the SDK, providing comprehensive CRUD operations for job listings.

Search Jobs

TypeScript
// Advanced search with filters
const results = await jobsphere.jobs.search({
  query: "React Developer",
  location: "New York, NY",
  radius: 25, // miles
  remote: ["remote", "hybrid"],
  experienceLevel: "senior",
  salaryMin: 120000,
  postedWithin: "7d",
  categories: ["engineering", "frontend"],
  limit: 50,
  page: 1,
  sortBy: "posted_at",
  sortOrder: "desc"
});

console.log(results.total);     // 1243
console.log(results.page);     // 1
console.log(results.perPage);  // 50
console.log(results.hasMore);  // true

Get Job by ID

TypeScript
const job = await jobsphere.jobs.get("job_2xK9mPqR7sL3");

console.log(job.title);              // "Senior React Developer"
console.log(job.company.name);      // "TechCorp Inc."
console.log(job.salary.min);         // 140000
console.log(job.salary.currency);    // "USD"
console.log(job.location.city);     // "San Francisco"
console.log(job.isRemote);          // true
console.log(job.tags);              // ["react", "typescript", "nextjs"]

Create a Job

TypeScript
const newJob = await jobsphere.jobs.create({
  title: "Full Stack Engineer",
  companyId: "comp_8xR2nVtW4mK1",
  description: "We're looking for a talented...",
  location: {
    city: "Austin",
    state: "TX",
    country: "US"
  },
  remote: "hybrid",
  salary: {
    min: 130000,
    max: 170000,
    currency: "USD",
    period: "yearly"
  },
  categories: ["engineering", "fullstack"],
  tags: ["node", "react", "postgres"],
  experienceLevel: "mid",
  employmentType: "full_time",
  expiresAt: "2025-03-15T00:00:00Z"
});

console.log(`Created job: ${newJob.id}`);

Parameters Reference

Parameter Type Required Description
query string Optional Full-text search query
location string Optional City, state, or postal code
remote boolean | string[] Optional Filter by remote status
limit number Optional Results per page (max: 100)
page number Optional Page number for pagination
sortBy "relevance" | "posted_at" | "salary" Optional Sort field

# Companies Module

Manage company profiles, branding, and organization settings.

TypeScript
// Get company details
const company = await jobsphere.companies.get("comp_8xR2nVtW4mK1");

console.log(company.name);          // "TechCorp Inc."
console.log(company.website);       // "https://techcorp.com"
console.log(company.size);          // "201-500"
console.log(company.industry);      // "Technology"
console.log(company.activeJobs);    // 12

// Update company profile
const updated = await jobsphere.companies.update("comp_8xR2nVtW4mK1", {
  description: "Updated company description...",
  logoUrl: "https://cdn.example.com/logo.png",
  socialLinks: {
    linkedin: "https://linkedin.com/company/techcorp",
    twitter: "https://twitter.com/techcorp"
  }
});

# Applications Module

Submit job applications, track status, and manage application workflows.

TypeScript
// Apply to a job
const application = await jobsphere.applications.create({
  jobId: "job_2xK9mPqR7sL3",
  candidate: {
    name: "Jane Doe",
    email: "jane@example.com",
    linkedin: "https://linkedin.com/in/janedoe"
  },
  resume: {
    url: "https://cdn.example.com/resume.pdf",
    mimeType: "application/pdf"
  },
  coverLetter: "I am excited to apply for...",
  status: "submitted"
});

console.log(`Application ID: ${application.id}`);

// Track application status
const status = await jobsphere.applications.getStatus(application.id);
console.log(`Status: ${status.stage}`); // "screening", "interview", "offered"

# Analytics Module

Access hiring analytics, job performance metrics, and market insights.

TypeScript
// Get job analytics
const analytics = await jobsphere.analytics.getJobMetrics("job_2xK9mPqR7sL3");

console.log(analytics.views);       // 1,247
console.log(analytics.applications); // 42
console.log(analytics.clickRate);   // 0.034
console.log(analytics.topSources);  // [{ source: "linkedin", count: 18 }]

// Market salary data
const marketData = await jobsphere.analytics.getSalaryInsights({
  role: "Software Engineer",
  location: "San Francisco",
  experience: "senior"
});

console.log(marketData.median);    // 175000
console.log(marketData.p25);       // 145000
console.log(marketData.p75);       // 210000

# Webhooks

Register webhook endpoints to receive real-time notifications for events in your JobSphere account.

TypeScript
import { verifyWebhook, WebhookEvent } from "@jobsphere/sdk";

// Express.js example
app.post("/webhooks/jobsphere", async (req, res) => {
  const signature = req.headers["x-jobsphere-signature"] as string;

  try {
    const event: WebhookEvent = await verifyWebhook(
      req.body,
      signature,
      process.env.JOBSHERE_WEBHOOK_SECRET
    );

    switch (event.type) {
      case "application.submitted":
        await notifyHiringTeam(event.data);
        break;
      case "job.expiring":
        await sendExpiryReminder(event.data);
        break;
      case "application.status_changed":
        await updateCandidateDashboard(event.data);
        break;
    }

    res.status(200).json({ received: true });
  } catch (error) {
    res.status(400).json({ error: "Invalid signature" });
  }
});

Available Events

Event Description Trigger
application.submitted New application received Real-time
application.status_changed Application status updated Real-time
job.published Job listing published Real-time
job.expiring Job expires in 7 days Scheduled
job.expired Job has expired Real-time

# Error Handling

The SDK provides a structured error hierarchy for handling API errors gracefully.

TypeScript
import {
  JobSphereError,
  AuthenticationError,
  RateLimitError,
  NotFoundError,
  ValidationError
} from "@jobsphere/sdk";

try {
  const job = await jobsphere.jobs.get("job_invalid_id");
} catch (error) {
  if (error instanceof NotFoundError) {
    console.error(`Job not found: ${error.jobId}`);
  } else if (error instanceof RateLimitError) {
    console.error(`Retry after ${error.retryAfter} seconds`);
  } else if (error instanceof AuthenticationError) {
    console.error("Invalid API key");
  } else if (error instanceof ValidationError) {
    console.error("Validation failed:", error.fields);
  } else if (error instanceof JobSphereError) {
    console.error(`API Error: ${error.code} - ${error.message}`);
  } else {
    console.error("Unexpected error", error);
  }
}

Error Codes

Code Type HTTP Status Description
invalid_api_key Auth 401 The API key is invalid or expired
not_found Not Found 404 The requested resource doesn't exist
rate_limit_exceeded Rate Limit 429 Too many requests. Wait before retrying
validation_failed Validation 422 Request body failed validation
server_error Server 500 Internal server error. Retry later

# Changelog

v3.2.1 January 15, 2025 Latest
  • Fixed pagination cursor encoding for large result sets
  • Resolved timeout issues with bulk job creation (>500 records)
v3.2.0 January 2, 2025
  • Added Analytics module with salary insights
  • New streaming API for real-time job updates
  • Fixed OAuth token refresh in browser environments
v3.1.0 November 20, 2024
  • Added webhook verification helper functions
  • Support for application attachments (PDF, DOCX)
  • Reduced bundle size by 22% with tree-shaking
v3.0.0 October 5, 2024 Breaking
  • Minimum Node.js version bumped to 18
  • Replaced callback-based API with Promises/async-await
  • Renamed JobSphereClient to JobSphere
  • Full TypeScript 5.x support
  • Automatic retry with exponential backoff

# FAQ

Is the SDK free to use?

Yes! The SDK itself is open-source and free under the MIT license. You'll need a JobSphere API key to make API calls, and standard JobSphere pricing applies for API usage.

Can I use this in the browser?

Yes, the SDK supports browser environments. However, you should use OAuth 2.0 for client-side authentication to avoid exposing API keys.

How do I handle rate limits?

The SDK includes built-in retry logic with exponential backoff. You can customize retry settings via the retryConfig option. Rate limit details are available in the error response.

Does it work with serverless functions?

Absolutely! The SDK is fully compatible with AWS Lambda, Vercel Functions, Cloudflare Workers, and other serverless platforms.

# Contributing

We welcome contributions! The SDK is open-source and maintained by the JobSphere team and community.

bash
# Clone the repository
git clone https://github.com/jobsphere/sdk-js.git
cd sdk-js

# Install dependencies
npm install

# Run tests
npm run test

# Build the package
npm run build

# Generate TypeScript types
npm run generate:types
Development Guidelines

Read our Contributing Guide for detailed information on coding standards, commit conventions, and the PR review process.