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

@2ndopinion/sdk

v0.3.1

Published

Official JavaScript/TypeScript SDK for 2ndOpinion — AI-to-AI code review where Claude, Codex, and Gemini review your code together

Downloads

95

Readme

@2ndopinion/sdk

Official JavaScript/TypeScript SDK for 2ndOpinion — the AI-to-AI code review platform where Claude, Codex, and Gemini review your code together.

Installation

npm install @2ndopinion/sdk

Quick Start

import { SecondOpinion } from '@2ndopinion/sdk';

const client = new SecondOpinion('sk_2op_your_key_here');

// Get a code review
const result = await client.opinion({
  diff: `--- a/auth.js\n+++ b/auth.js\n@@ -1,3 +1,3 @@\n-const token = req.headers.authorization;\n+const token = req.query.token;`,
  llm: 'codex',
});

console.log(result.analysis.summary);
console.log(result.analysis.recommendation); // 'accept' | 'review' | 'reject'

Methods

| Method | Description | Credits | |--------|-------------|---------| | opinion(diff, llm?, context?) | Single-model code review with risk analysis | 1 | | review(diff, llm?, context?) | Alias for opinion | 1 | | ask(question, llm?, code?, context?) | Ask an AI model a question about code | 1 | | batch(files[], llm?) | Analyze up to 20 files concurrently | 1 each | | status() | Check account credits, tier, and usage | 0 | | stream(diff, llm?, context?) | SSE streaming analysis | 1 |

Examples

Ask a Question

const answer = await client.ask({
  question: 'Is this SQL query vulnerable to injection?',
  code: `db.query("SELECT * FROM users WHERE id = " + userId)`,
  llm: 'claude',
});
console.log(answer.response);

Check Usage

const usage = await client.status();
console.log(`${usage.totalAvailable} credits remaining (${usage.tier} plan)`);

Streaming

for await (const chunk of client.stream({ diff: myDiff, llm: 'gemini' })) {
  process.stdout.write(chunk);
}

Batch Review

const results = await client.batch({
  files: [
    { path: 'auth.js', diff: authDiff },
    { path: 'db.js', diff: dbDiff },
  ],
});
results.forEach(r => console.log(`${r.file}: ${r.analysis.recommendation}`));

Error Handling

import { SecondOpinion, SecondOpinionError } from '@2ndopinion/sdk';

try {
  const result = await client.opinion({ diff: myDiff });
} catch (err) {
  if (err instanceof SecondOpinionError) {
    switch (err.code) {
      case 'RATE_LIMIT': // Wait and retry
      case 'INSUFFICIENT_CREDITS': // Upgrade plan
      case 'UNAUTHORIZED': // Check API key
    }
  }
}

CI/CD Usage

Use the SDK in Node.js scripts for automated pipelines:

import { SecondOpinion } from '@2ndopinion/sdk';
import { execSync } from 'child_process';

const client = new SecondOpinion(process.env.SECONDOPINION_API_KEY!);
const diff = execSync('git diff HEAD~1').toString();

const result = await client.opinion({ diff, llm: 'codex' });

if (result.analysis.recommendation === 'reject') {
  console.error('Code review failed:', result.analysis.summary);
  process.exit(1);
}

Or use the CLI directly with --ci for JSON output:

npx 2ndopinion analyze --ci | jq '.verdict'

Get an API Key

  1. Sign up at get2ndopinion.dev/signup
  2. Go to Dashboard > API Keys
  3. Create a key and use it in the constructor

Pricing

Free tier includes 5 credits/month. See all plans.

Links