@goperigon/perigon-ts 1.0.1
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/LICENSE +21 -0
- package/README.md +244 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Perigon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<!-- ---------- Header ---------- -->
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img src="https://goperigon.com/favicon.ico" width="120" alt="Perigon logo" />
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<h1 align="center">Perigon TypeScript SDK</h1>
|
|
7
|
+
<p align="center">TypeScript client for the <strong>Perigon API</strong></p>
|
|
8
|
+
|
|
9
|
+
<!-- ---------- Badges ---------- -->
|
|
10
|
+
<p align="center">
|
|
11
|
+
<!-- npm -->
|
|
12
|
+
<a href="https://www.npmjs.com/package/@goperigon/perigon-ts">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/@goperigon/perigon-ts?style=for-the-badge" alt="npm version">
|
|
14
|
+
</a>
|
|
15
|
+
<!-- tests -->
|
|
16
|
+
<a href="https://github.com/goperigon/perigon-ts/actions/workflows/test.yml">
|
|
17
|
+
<img src="https://img.shields.io/github/actions/workflow/status/goperigon/perigon-ts/test.yml?label=tests%20%E2%9C%85&style=for-the-badge" alt="tests status">
|
|
18
|
+
</a>
|
|
19
|
+
<!-- docs -->
|
|
20
|
+
<a href="https://docs.perigon.io">
|
|
21
|
+
<img src="https://img.shields.io/badge/docs-perigon.io-informational?style=for-the-badge&logo=readthedocs" alt="documentation">
|
|
22
|
+
</a>
|
|
23
|
+
<!-- license -->
|
|
24
|
+
<a href="LICENSE">
|
|
25
|
+
<img src="https://img.shields.io/github/license/goperigon/perigon-ts?style=for-the-badge" alt="license">
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
A fully-typed, promise-based SDK generated from the official Perigon OpenAPI specification. Works in Node.js, modern browsers, Cloudflare Workers, and Deno.
|
|
30
|
+
|
|
31
|
+
## Table of Contents
|
|
32
|
+
|
|
33
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
34
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
35
|
+
|
|
36
|
+
- [β¨ Features](#-features)
|
|
37
|
+
- [π¦ Installation](#-installation)
|
|
38
|
+
- [π Quick start](#-quick-start)
|
|
39
|
+
- [π§βπ» Endpoint snippets](#-endpoint-snippets)
|
|
40
|
+
- [π§ͺ Running integration tests](#-running-integration-tests)
|
|
41
|
+
- [π€ Contributing](#-contributing)
|
|
42
|
+
- [πͺͺ License](#-license)
|
|
43
|
+
|
|
44
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## β¨ Features
|
|
49
|
+
|
|
50
|
+
- **Type-safe** request/response models (goodbye `any`)
|
|
51
|
+
- Ships as both **ESM & CommonJS** with sourcemaps
|
|
52
|
+
- **Zero-dependency core** β bring your own `fetch` if needed
|
|
53
|
+
- Generated directly from [docs.perigon.io](https://docs.perigon.io), so itβs always in sync
|
|
54
|
+
- Runs in **Node, browsers, Deno, and edge runtimes**
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## π¦ Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm install @goperigon/perigon-ts
|
|
62
|
+
# yarn add @goperigon/perigon-ts
|
|
63
|
+
# pnpm add @goperigon/perigon-ts
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## π Quick start
|
|
69
|
+
|
|
70
|
+
### 1. Export your API key
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# .env
|
|
74
|
+
PERIGON_API_KEY=your_key_here
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Instantiate the client
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { Configuration, V1Api } from "@goperigon/perigon-ts";
|
|
81
|
+
|
|
82
|
+
const perigon = new V1Api(
|
|
83
|
+
new Configuration({
|
|
84
|
+
apiKey: process.env.PERIGON_API_KEY!, // or () => 'your_key'
|
|
85
|
+
// basePath: 'https://api.perigon.io', // override for proxy / dev
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3. Make calls
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// π Search recent news articles
|
|
94
|
+
const { articles, numResults } = await perigon.searchArticles({
|
|
95
|
+
q: "artificial intelligence",
|
|
96
|
+
size: 5,
|
|
97
|
+
});
|
|
98
|
+
console.log(numResults, articles[0].title);
|
|
99
|
+
|
|
100
|
+
// π€ Look up a journalist by ID
|
|
101
|
+
const journalist = await perigon.getJournalistById({ id: "123456" });
|
|
102
|
+
console.log(journalist.name);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> All SDK methods return **typed promises** with full IntelliSense support.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## π§βπ» Endpoint snippets
|
|
110
|
+
|
|
111
|
+
### Articles β search and filter news (`/v1/all`)<br>
|
|
112
|
+
|
|
113
|
+
**Docs β** <https://docs.perigon.io/docs/overview>
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
const { articles } = await perigon.searchArticles({
|
|
117
|
+
q: "technology",
|
|
118
|
+
size: 5,
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Articles β date range filter<br>
|
|
123
|
+
|
|
124
|
+
**Docs β** <https://docs.perigon.io/docs/overview>
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
await perigon.searchArticles({
|
|
128
|
+
q: "business",
|
|
129
|
+
from: "2025-04-01",
|
|
130
|
+
to: "2025-04-08",
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Articles β restrict to a source<br>
|
|
135
|
+
|
|
136
|
+
**Docs β** <https://docs.perigon.io/docs/overview>
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
await perigon.searchArticles({ source: ["nytimes.com"] });
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Companies β fetch structured company data (`/v1/companies`)<br>
|
|
143
|
+
|
|
144
|
+
**Docs β** <https://docs.perigon.io/docs/company-data>
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
const { results } = await perigon.searchCompanies({
|
|
148
|
+
name: "Apple",
|
|
149
|
+
size: 5,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Journalists β search and detail lookβup (`/v1/journalists`)<br>
|
|
154
|
+
|
|
155
|
+
**Docs β** <https://docs.perigon.io/docs/journalist-data>
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const { results } = await perigon.searchJournalists1({
|
|
159
|
+
name: "Kevin",
|
|
160
|
+
size: 1,
|
|
161
|
+
});
|
|
162
|
+
const journalist = await perigon.getJournalistById({ id: results[0].id });
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Stories β discover related article clusters (`/v1/stories`)<br>
|
|
166
|
+
|
|
167
|
+
**Docs β** <https://docs.perigon.io/docs/stories-overview>
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
await perigon.searchStories({ q: "climate change", size: 5 });
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Vector search β semantic retrieval (`/v1/vector`)<br>
|
|
174
|
+
|
|
175
|
+
**Docs β** <https://docs.perigon.io/docs/vector-endpoint>
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
await perigon.vectorSearchArticles({
|
|
179
|
+
articleSearchParams: {
|
|
180
|
+
prompt: "Latest advancements in artificial intelligence",
|
|
181
|
+
size: 5,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Summarizer β generate an instant summary (`/v1/summarizer`)<br>
|
|
187
|
+
|
|
188
|
+
**Docs β** <https://docs.perigon.io/docs/search-summarizer>
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
const { summary } = await perigon.searchSummarizer({
|
|
192
|
+
q: "renewable energy",
|
|
193
|
+
size: 10,
|
|
194
|
+
});
|
|
195
|
+
console.log(summary);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Topics β explore taxonomy (`/v1/topics`)<br>
|
|
199
|
+
|
|
200
|
+
**Docs β** <https://docs.perigon.io/docs/topics>
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
await perigon.searchTopics({ size: 10 });
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
| Action | Code Example |
|
|
207
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
208
|
+
| Filter by source | `await perigon.searchArticles({ source: ['nytimes.com'] })` |
|
|
209
|
+
| Limit by date range | `await perigon.searchArticles({ q: 'business', from: '2025β04β01', to: '2025β04β08' })` |
|
|
210
|
+
| Company lookup | `await perigon.searchCompanies({ name: 'Apple', size: 5 })` |
|
|
211
|
+
| Summarize any query | `await perigon.searchSummarizer({ q: 'renewable energy', size: 20 })` |
|
|
212
|
+
| Semantic / vector search | `await perigon.vectorSearchArticles({ articleSearchParams: { prompt: 'advancements in AI', size: 5 }})` |
|
|
213
|
+
| Retrieve available taxonomic **topics** | `await perigon.searchTopics({ size: 10 })` |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## π§ͺ Running integration tests
|
|
218
|
+
|
|
219
|
+
The repository ships with Jest tests that hit the live API.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# 1. export your key
|
|
223
|
+
echo "PERIGON_API_KEY=..." > .env
|
|
224
|
+
|
|
225
|
+
# 2. run the suite (15β30β―s)
|
|
226
|
+
npm test
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Set `PERIGON_API_KEY` in your CI to keep tests green.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## π€ Contributing
|
|
234
|
+
|
|
235
|
+
1. `pnpm install`
|
|
236
|
+
2. Make your changes
|
|
237
|
+
3. Run `pnpm test`
|
|
238
|
+
4. Open a pull request β happy to review!
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## πͺͺ License
|
|
243
|
+
|
|
244
|
+
MIT Β© Perigon
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@goperigon/perigon-ts",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "OpenAPI client for @goperigon/perigon-ts",
|
|
5
|
+
"author": "OpenAPI-Generator",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/goperigon/perigon-ts"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"typings": "./dist/index.d.ts",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc && tsc -p tsconfig.esm.json",
|
|
17
|
+
"test": "jest --coverage",
|
|
18
|
+
"test:integration": "jest tests/integration --runInBand --testTimeout=30000",
|
|
19
|
+
"test:unit": "jest tests/unit",
|
|
20
|
+
"prepare": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "^29.5.0",
|
|
24
|
+
"@types/node": "^18.15.0",
|
|
25
|
+
"dotenv": "^16.0.3",
|
|
26
|
+
"jest": "^29.5.0",
|
|
27
|
+
"ts-jest": "^29.1.0",
|
|
28
|
+
"ts-node": "^10.9.1",
|
|
29
|
+
"typescript": "^4.0 || ^5.0"
|
|
30
|
+
}
|
|
31
|
+
}
|