@goperigon/perigon-ts 1.1.2 β 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -136
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +3833 -6636
- package/dist/index.js +2 -2
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- ---------- Header ---------- -->
|
|
2
2
|
<p align="center">
|
|
3
|
-
<img src="https://
|
|
3
|
+
<img src="https://perigon.io/favicon.ico" width="120" alt="Perigon logo" />
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
<h1 align="center">Perigon TypeScript SDK</h1>
|
|
@@ -26,32 +26,27 @@
|
|
|
26
26
|
</a>
|
|
27
27
|
</p>
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Table of Contents
|
|
29
|
+
Fully-typed TypeScript SDK for the Perigon API. Access news articles, AI summaries, entity data, and more with complete type safety.
|
|
32
30
|
|
|
33
31
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
34
32
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
35
33
|
|
|
36
34
|
- [β¨ Features](#-features)
|
|
37
35
|
- [π¦ Installation](#-installation)
|
|
38
|
-
- [π Quick
|
|
39
|
-
- [
|
|
36
|
+
- [π Quick Start](#-quick-start)
|
|
37
|
+
- [π Authentication](#-authentication)
|
|
38
|
+
- [π Endpoints](#-endpoints)
|
|
39
|
+
- [β οΈ Error Handling](#-error-handling)
|
|
40
40
|
- [πͺͺ License](#-license)
|
|
41
41
|
|
|
42
42
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
43
43
|
|
|
44
|
-
---
|
|
45
|
-
|
|
46
44
|
## β¨ Features
|
|
47
45
|
|
|
48
|
-
- **Type-safe**
|
|
49
|
-
-
|
|
50
|
-
- **Zero
|
|
51
|
-
-
|
|
52
|
-
- Runs in **Node, browsers, Deno, and edge runtimes**
|
|
53
|
-
|
|
54
|
-
---
|
|
46
|
+
- **Type-safe** β Full TypeScript support with IntelliSense
|
|
47
|
+
- **Universal** β Works in Node.js, browsers, Deno, and edge runtimes
|
|
48
|
+
- **Zero dependencies** β Lightweight core, bring your own fetch
|
|
49
|
+
- **Auto-generated** β Always in sync with the latest API
|
|
55
50
|
|
|
56
51
|
## π¦ Installation
|
|
57
52
|
|
|
@@ -59,182 +54,125 @@ A fully-typed, promise-based SDK generated from the official Perigon OpenAPI spe
|
|
|
59
54
|
npm install @goperigon/perigon-ts
|
|
60
55
|
# yarn add @goperigon/perigon-ts
|
|
61
56
|
# pnpm add @goperigon/perigon-ts
|
|
57
|
+
# bun add @goperigon/perigon-ts
|
|
62
58
|
```
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## π Quick start
|
|
67
|
-
|
|
68
|
-
### 1. Instantiate the client
|
|
60
|
+
## π Quick Start
|
|
69
61
|
|
|
70
62
|
```ts
|
|
71
63
|
import { Configuration, V1Api } from "@goperigon/perigon-ts";
|
|
72
64
|
|
|
73
65
|
const perigon = new V1Api(
|
|
74
66
|
new Configuration({
|
|
75
|
-
apiKey:
|
|
76
|
-
// basePath: 'https://api.perigon.io', // override for proxy / dev
|
|
67
|
+
apiKey: process.env.PERIGON_API_KEY,
|
|
77
68
|
}),
|
|
78
69
|
);
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### 2. Make calls
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
// π Search recent news articles
|
|
85
|
-
const { articles, numResults } = await perigon.searchArticles({
|
|
86
|
-
q: "artificial intelligence",
|
|
87
|
-
size: 5,
|
|
88
|
-
});
|
|
89
|
-
console.log(numResults, articles[0].title);
|
|
90
|
-
|
|
91
|
-
// π€ Look up a journalist by ID
|
|
92
|
-
const journalist = await perigon.getJournalistById({ id: "123456" });
|
|
93
|
-
console.log(journalist.name);
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
> All SDK methods return **typed promises** with full IntelliSense support.
|
|
97
70
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const { articles } = await perigon.searchArticles({
|
|
108
|
-
q: "technology",
|
|
109
|
-
size: 5,
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Articles β date range filter<br>
|
|
114
|
-
|
|
115
|
-
**Docs β** <https://dev.perigon.io/reference?endpoint=11>
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
await perigon.searchArticles({
|
|
119
|
-
q: "business",
|
|
120
|
-
from: "2025-04-01",
|
|
121
|
-
to: "2025-04-08",
|
|
122
|
-
});
|
|
71
|
+
try {
|
|
72
|
+
const { articles } = await perigon.searchArticles({
|
|
73
|
+
q: "artificial intelligence",
|
|
74
|
+
size: 5,
|
|
75
|
+
});
|
|
76
|
+
console.log(`Found ${articles.length} articles`);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error("API Error:", error.message);
|
|
79
|
+
}
|
|
123
80
|
```
|
|
124
81
|
|
|
125
|
-
|
|
82
|
+
## π Authentication
|
|
126
83
|
|
|
127
|
-
|
|
84
|
+
Get your API key from [perigon.io](https://perigon.io):
|
|
128
85
|
|
|
129
|
-
```
|
|
130
|
-
|
|
86
|
+
```bash
|
|
87
|
+
# Environment variable (recommended)
|
|
88
|
+
export PERIGON_API_KEY="your_api_key_here"
|
|
131
89
|
```
|
|
132
90
|
|
|
133
|
-
### Companies β fetch structured company data (`/v1/companies`)<br>
|
|
134
|
-
|
|
135
|
-
**Docs β** <https://dev.perigon.io/reference?endpoint=2>
|
|
136
|
-
|
|
137
91
|
```ts
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
92
|
+
// Or pass directly
|
|
93
|
+
const perigon = new V1Api(
|
|
94
|
+
new Configuration({
|
|
95
|
+
apiKey: "your_api_key_here",
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
142
98
|
```
|
|
143
99
|
|
|
144
|
-
|
|
100
|
+
## π Endpoints
|
|
145
101
|
|
|
146
|
-
|
|
102
|
+
### News & Articles
|
|
147
103
|
|
|
148
104
|
```ts
|
|
149
|
-
const {
|
|
150
|
-
|
|
151
|
-
|
|
105
|
+
const { articles, numResults } = await perigon.searchArticles({
|
|
106
|
+
q: "technology AND startups",
|
|
107
|
+
source: ["techcrunch.com"],
|
|
108
|
+
from: "2024-01-01",
|
|
109
|
+
size: 10,
|
|
152
110
|
});
|
|
153
|
-
const journalist = await perigon.getJournalistById({ id: results[0].id });
|
|
154
111
|
```
|
|
155
112
|
|
|
156
|
-
|
|
113
|
+
- [`searchArticles`](https://dev.perigon.io/reference?endpoint=11) β Search news articles with advanced filtering by keywords, sources, dates, and more
|
|
114
|
+
- [`vectorSearchArticles`](https://dev.perigon.io/reference?endpoint=10) β Find semantically similar articles using AI-powered vector search
|
|
157
115
|
|
|
158
|
-
|
|
116
|
+
### Entities
|
|
159
117
|
|
|
160
118
|
```ts
|
|
161
|
-
await perigon.
|
|
119
|
+
const { results } = await perigon.searchCompanies({ name: "Apple", size: 5 });
|
|
162
120
|
```
|
|
163
121
|
|
|
164
|
-
|
|
122
|
+
- [`searchCompanies`](https://dev.perigon.io/reference?endpoint=2) β Find companies with detailed business information, financials, and metadata
|
|
123
|
+
- [`searchPeople`](https://dev.perigon.io/reference?endpoint=5) β Search for notable people and public figures across news and media
|
|
124
|
+
- [`searchJournalists`](https://dev.perigon.io/reference?endpoint=3) β Discover journalists and reporters by name, publication, or expertise
|
|
125
|
+
- [`getJournalistById`](https://dev.perigon.io/reference?endpoint=4) β Get comprehensive profile data for a specific journalist
|
|
165
126
|
|
|
166
|
-
|
|
127
|
+
### Content Discovery
|
|
167
128
|
|
|
168
129
|
```ts
|
|
169
|
-
const {
|
|
170
|
-
q: "
|
|
130
|
+
const { results } = await perigon.searchStories({
|
|
131
|
+
q: "climate change",
|
|
171
132
|
size: 5,
|
|
172
133
|
});
|
|
173
134
|
```
|
|
174
135
|
|
|
175
|
-
|
|
136
|
+
- [`searchStories`](https://dev.perigon.io/reference?endpoint=7) β Find related article clusters and trending story threads
|
|
137
|
+
- [`searchTopics`](https://dev.perigon.io/reference?endpoint=9) β Browse structured topic taxonomy and content categories
|
|
138
|
+
- [`searchSources`](https://dev.perigon.io/reference?endpoint=6) β Discover news sources, publications, and media outlets
|
|
176
139
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
```ts
|
|
180
|
-
await perigon.vectorSearchArticles({
|
|
181
|
-
articleSearchParams: {
|
|
182
|
-
prompt: "Latest advancements in artificial intelligence",
|
|
183
|
-
size: 5,
|
|
184
|
-
},
|
|
185
|
-
});
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Wikipedia vector search β semantic Wikipedia retrieval (`/v1/vector/wikipedia`)<br>
|
|
189
|
-
|
|
190
|
-
**Docs β** <https://dev.perigon.io/reference?endpoint=12>
|
|
191
|
-
|
|
192
|
-
```ts
|
|
193
|
-
await perigon.vectorSearchWikipedia({
|
|
194
|
-
wikipediaSearchParams: {
|
|
195
|
-
prompt: "quantum computing breakthroughs",
|
|
196
|
-
size: 5,
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Summarizer β generate an instant summary (`/v1/summarizer`)<br>
|
|
202
|
-
|
|
203
|
-
**Docs β** <https://dev.perigon.io/reference?endpoint=8>
|
|
140
|
+
### AI Features
|
|
204
141
|
|
|
205
142
|
```ts
|
|
206
143
|
const { summary } = await perigon.searchSummarizer({
|
|
207
144
|
q: "renewable energy",
|
|
208
145
|
size: 10,
|
|
209
146
|
});
|
|
210
|
-
console.log(summary);
|
|
211
147
|
```
|
|
212
148
|
|
|
213
|
-
|
|
149
|
+
- [`searchSummarizer`](https://dev.perigon.io/reference?endpoint=8) β Generate AI-powered summaries from multiple articles on any topic
|
|
214
150
|
|
|
215
|
-
|
|
151
|
+
### Knowledge Base
|
|
216
152
|
|
|
217
153
|
```ts
|
|
218
|
-
await perigon.
|
|
154
|
+
const { results } = await perigon.searchWikipedia({
|
|
155
|
+
q: "machine learning",
|
|
156
|
+
size: 10,
|
|
157
|
+
});
|
|
219
158
|
```
|
|
220
159
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
| Filter by source | `await perigon.searchArticles({ source: ['nytimes.com'] })` |
|
|
224
|
-
| Limit by date range | `await perigon.searchArticles({ q: 'business', from: '2025β04β01', to: '2025β04β08' })` |
|
|
225
|
-
| Company lookup | `await perigon.searchCompanies({ name: 'Apple', size: 5 })` |
|
|
226
|
-
| Wikipedia page search | `await perigon.searchWikipedia({ q: 'machine learning', size: 5 })` |
|
|
227
|
-
| Summarize any query | `await perigon.searchSummarizer({ q: 'renewable energy', size: 20 })` |
|
|
228
|
-
| Semantic / vector search | `await perigon.vectorSearchArticles({ articleSearchParams: { prompt: 'advancements in AI', size: 5 }})` |
|
|
229
|
-
| Wikipedia semantic search | `await perigon.vectorSearchWikipedia({ wikipediaSearchParams: { prompt: 'quantum physics', size: 5 }})` |
|
|
230
|
-
| Retrieve available taxonomic **topics** | `await perigon.searchTopics({ size: 10 })` |
|
|
160
|
+
- [`searchWikipedia`](https://dev.perigon.io/reference?endpoint=13) β Search Wikipedia articles with full-text matching and filtering
|
|
161
|
+
- [`vectorSearchWikipedia`](https://dev.perigon.io/reference?endpoint=12) β Find semantically related Wikipedia content using vector similarity
|
|
231
162
|
|
|
232
|
-
|
|
163
|
+
## β οΈ Error Handling
|
|
233
164
|
|
|
234
|
-
|
|
235
|
-
We have put together basic and advanced examples of accessing and using the Perigon API using the python SDK inside the **examples/** folder.
|
|
165
|
+
All errors extend `ResponseError` and include `status` & `body` properties:
|
|
236
166
|
|
|
237
|
-
|
|
167
|
+
```ts
|
|
168
|
+
try {
|
|
169
|
+
const result = await perigon.searchArticles({ q: "test" });
|
|
170
|
+
} catch (error) {
|
|
171
|
+
if (error.status === 401) console.error("Invalid API key");
|
|
172
|
+
else if (error.status === 429) console.error("Rate limit exceeded");
|
|
173
|
+
else console.error("API Error:", error.message);
|
|
174
|
+
}
|
|
175
|
+
```
|
|
238
176
|
|
|
239
177
|
## πͺͺ License
|
|
240
178
|
|