@goperigon/perigon-ts

中文文档
6.1.0发布于 2026/11/16MITTypeScriptESM + CJS近 30 天下载 5389

Typescript client for Perigon API

原始使用文档
文档目录13 节
  1. ✨ Features
  2. 📦 Installation
  3. 🚀 Quick Start
  4. 🔑 Authentication
  5. 📚 Endpoints
  6. News & Articles
  7. Entities
  8. Content Discovery
  9. AI Features
  10. Knowledge Base
  11. 🧩 Undeclared Parameters
  12. ⚠️ Error Handling
  13. 🪪 License

Perigon logo

Perigon TypeScript SDK

TypeScript client for the Perigon API

npm version tests status documentation license

Fully-typed TypeScript SDK for the Perigon API. Access news articles, AI summaries, entity data, and more with complete type safety.

✨ Features

  • Type-safe – Full TypeScript support with IntelliSense
  • Universal – Works in Node.js, browsers, Deno, and edge runtimes
  • Zero dependencies – Lightweight core, bring your own fetch
  • Auto-generated – Always in sync with the latest API

📦 Installation

npm install @goperigon/perigon-ts
# yarn add @goperigon/perigon-ts
# pnpm add @goperigon/perigon-ts
# bun add @goperigon/perigon-ts

🚀 Quick Start

import { Configuration, V1Api } from "@goperigon/perigon-ts";

const perigon = new V1Api(
  new Configuration({
    apiKey: process.env.PERIGON_API_KEY,
  }),
);

try {
  const { articles } = await perigon.searchArticles({
    q: "artificial intelligence",
    size: 5,
  });
  console.log(`Found ${articles.length} articles`);
} catch (error) {
  console.error("API Error:", error.message);
}

🔑 Authentication

Get your API key from perigon.io:

# Environment variable (recommended)
export PERIGON_API_KEY="your_api_key_here"
// Or pass directly
const perigon = new V1Api(
  new Configuration({
    apiKey: "your_api_key_here",
  }),
);

Requests go to https://api.perigon.io by default. To send them elsewhere, such as through a proxy, pass basePath: "https://your-host" to Configuration.

📚 Endpoints

News & Articles

const { articles, numResults } = await perigon.searchArticles({
  q: "technology AND startups",
  source: ["techcrunch.com"],
  from: new Date("2024-01-01"),
  size: 10,
});
  • searchArticles – Search news articles with advanced filtering by keywords, sources, dates, and more
  • vectorSearchArticles – Find semantically similar articles using AI-powered vector search

Entities

const { results } = await perigon.searchCompanies({ name: "Apple", size: 5 });
  • searchCompanies – Find companies with detailed business information, financials, and metadata
  • searchPeople – Search for notable people and public figures across news and media
  • searchJournalists – Discover journalists and reporters by name, publication, or expertise
  • getJournalistById – Get comprehensive profile data for a specific journalist

Content Discovery

const { results } = await perigon.searchStories({
  q: "climate change",
  size: 5,
});
  • searchStories – Find related article clusters and trending story threads
  • searchTopics – Browse structured topic taxonomy and content categories
  • searchSources – Discover news sources, publications, and media outlets

AI Features

const { summary } = await perigon.searchSummarizer({
  q: "renewable energy",
  summaryBody: {
    prompt: "Summarize the main developments in renewable energy.",
    maxArticleCount: 10,
  },
});
  • searchSummarizer – Generate AI-powered summaries from multiple articles on any topic

Knowledge Base

const { results } = await perigon.searchWikipedia({
  q: "machine learning",
  size: 10,
});

🧩 Undeclared Parameters

Declared request parameters are validated; TypeScript rejects undeclared ones. To send a query parameter the API accepts but this SDK version does not declare yet, pass it through extraParams:

const { results } = await perigon.searchStories({
  q: "climate change",
  extraParams: { someNewFilter: "value" },
});

extraParams accepts strings, numbers, booleans, single dates, and arrays of strings, numbers, or booleans; null and undefined values are omitted. These values override declared parameters with the same name without checking the declared parameter's type. Undeclared top-level keys that bypass the types (e.g. from JavaScript) are dropped.

⚠️ Error Handling

All errors extend ResponseError and include status & body properties:

try {
  const result = await perigon.searchArticles({ q: "test" });
} catch (error) {
  if (error.status === 401) console.error("Invalid API key");
  else if (error.status === 429) console.error("Rate limit exceeded");
  else console.error("API Error:", error.message);
}

🪪 License

MIT © Perigon

版本与发布记录

@goperigon/perigon-ts 共发布 27 个版本,首次发布于 2025/05/02;过去 12 个月发布了 9 个版本。

版本发布日期距今
6.1.0latest2026/11/161 天前
6.0.02026/10/2919 天前
5.0.02026/10/1928 天前
4.10.02026/06/035 个月前
4.9.02026/05/225 个月前
4.7.02026/05/076 个月前

关于 @goperigon/perigon-ts 的常见问题

@goperigon/perigon-ts 是什么?

Typescript client for Perigon API

如何安装 @goperigon/perigon-ts?

在项目目录运行 npm install @goperigon/perigon-ts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:undici(>=5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@goperigon/perigon-ts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@goperigon/perigon-ts 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@goperigon/perigon-ts 可以商用吗?

@goperigon/perigon-ts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@goperigon/perigon-ts 的下载量有多少?

根据 npm 官方下载统计,@goperigon/perigon-ts 在 2026/10/17 – 2026/11/15 这 30 天内被下载 5,389 次,日均约 180 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@goperigon/perigon-ts 还在维护吗?

最新版本 6.1.0 发布于 2026/11/16(1 天前);至今共发布 27 个版本,其中过去 12 个月发布了 9 个;首次发布于 2025/05/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。