arxiv-api-wrapper 1.1.0 → 1.1.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/README.md CHANGED
@@ -1,250 +1,250 @@
1
- # arxiv-api-wrapper
2
-
3
- A TypeScript package that provides a convenient wrapper around the arXiv API, enabling easy querying and parsing of arXiv papers.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install arxiv-api-wrapper
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```typescript
14
- import { getArxivEntries, getArxivEntriesById } from 'arxiv-api-wrapper';
15
-
16
- // Search for papers
17
- const result = await getArxivEntries({
18
- search: {
19
- title: ['quantum computing'],
20
- author: ['John Doe'],
21
- },
22
- maxResults: 10,
23
- sortBy: 'submittedDate',
24
- sortOrder: 'descending',
25
- });
26
-
27
- console.log(`Found ${result.feed.totalResults} papers`);
28
- result.entries.forEach(entry => {
29
- console.log(`${entry.arxivId}: ${entry.title}`);
30
- });
31
-
32
- // Or fetch specific papers by ID
33
- const papers = await getArxivEntriesById(['2101.01234', '2101.05678']);
34
- ```
35
-
36
- ## Features
37
-
38
- - **Type-safe**: Full TypeScript support with comprehensive type definitions
39
- - **Flexible Search**: Support for complex queries with multiple filters, OR groups, and negation
40
- - **Rate Limiting**: Built-in token bucket rate limiter to respect arXiv API guidelines
41
- - **Retry Logic**: Automatic retries with exponential backoff for transient failures
42
- - **Pagination**: Support for paginated results with configurable page size
43
- - **Sorting**: Multiple sort options (relevance, submission date, last updated)
44
-
45
- ## API Reference
46
-
47
- For complete API documentation with detailed type information and examples, see the [generated API documentation](https://vagdur.github.io/arxiv-api-wrapper/).
48
-
49
- ### `getArxivEntriesById(ids: string[], options?): Promise<ArxivQueryResult>`
50
-
51
- Simpler function to fetch arXiv papers by their IDs using the id_list API mode.
52
-
53
- **Parameters:**
54
- - `ids: string[]` - Array of arXiv paper IDs (e.g., `['2101.01234', '2101.05678']`)
55
- - `options?: object` - Optional request configuration
56
- - `rateLimit?: { tokensPerInterval: number, intervalMs: number }` - Rate limit configuration
57
- - `retries?: number` - Number of retry attempts (default: 3)
58
- - `timeoutMs?: number` - Request timeout in milliseconds (default: 10000)
59
- - `userAgent?: string` - Custom User-Agent header
60
-
61
- **Returns:** Same as `getArxivEntries` - see return type below.
62
-
63
- ### `getArxivEntries(options: ArxivQueryOptions): Promise<ArxivQueryResult>`
64
-
65
- Main function to query the arXiv API with search filters or ID lists.
66
-
67
- **Options:**
68
- - `idList?: string[]` - List of arXiv IDs to fetch (e.g., `['2101.01234', '2101.05678']`)
69
- - `search?: ArxivSearchFilters` - Search filters (when used with `idList`, filters the entries from `idList` to only return those matching the search query)
70
- - `start?: number` - Pagination offset (0-based)
71
- - `maxResults?: number` - Maximum number of results (≤ 300)
72
- - `sortBy?: 'relevance' | 'lastUpdatedDate' | 'submittedDate'` - Sort field
73
- - `sortOrder?: 'ascending' | 'descending'` - Sort direction
74
- - `timeoutMs?: number` - Request timeout in milliseconds (default: 10000)
75
- - `retries?: number` - Number of retry attempts (default: 3)
76
- - `rateLimit?: { tokensPerInterval: number, intervalMs: number }` - Rate limit configuration
77
- - `userAgent?: string` - Custom User-Agent header
78
-
79
- **Search Filters:**
80
- - `title?: string[]` - Search in titles
81
- - `author?: string[]` - Search by author names
82
- - `abstract?: string[]` - Search in abstracts
83
- - `category?: string[]` - Filter by arXiv categories
84
- - `submittedDateRange?: { from: string, to: string }` - Date range filter (YYYYMMDDTTTT format)
85
- - `or?: ArxivSearchFilters[]` - OR group of filters
86
- - `andNot?: ArxivSearchFilters` - Negated filter (ANDNOT)
87
-
88
- **Returns:**
89
- ```typescript
90
- {
91
- feed: {
92
- id: string;
93
- updated: string;
94
- title: string;
95
- link: string;
96
- totalResults: number;
97
- startIndex: number;
98
- itemsPerPage: number;
99
- };
100
- entries: Array<{
101
- id: string;
102
- arxivId: string;
103
- title: string;
104
- summary: string;
105
- published: string;
106
- updated: string;
107
- authors: Array<{ name: string; affiliation?: string }>;
108
- categories: string[];
109
- primaryCategory?: string;
110
- links: Array<{ href: string; rel?: string; type?: string; title?: string }>;
111
- doi?: string;
112
- journalRef?: string;
113
- comment?: string;
114
- }>;
115
- }
116
- ```
117
-
118
- ## Examples
119
-
120
- ### Search by title and author
121
-
122
- ```typescript
123
- const result = await getArxivEntries({
124
- search: {
125
- title: ['machine learning'],
126
- author: ['Geoffrey Hinton'],
127
- },
128
- maxResults: 5,
129
- });
130
- ```
131
-
132
- ### Fetch specific papers by ID
133
-
134
- Using the simpler `getArxivEntriesById` function:
135
-
136
- ```typescript
137
- const result = await getArxivEntriesById(['2101.01234', '2101.05678']);
138
- ```
139
-
140
- Or using `getArxivEntries`:
141
-
142
- ```typescript
143
- const result = await getArxivEntries({
144
- idList: ['2101.01234', '2101.05678'],
145
- });
146
- ```
147
-
148
- ### Complex search with OR and date range
149
-
150
- ```typescript
151
- const result = await getArxivEntries({
152
- search: {
153
- or: [
154
- { title: ['quantum'] },
155
- { abstract: ['quantum'] },
156
- ],
157
- submittedDateRange: {
158
- from: '202301010600',
159
- to: '202401010600',
160
- },
161
- },
162
- sortBy: 'submittedDate',
163
- sortOrder: 'descending',
164
- });
165
- ```
166
-
167
- ### Fetch papers by ID with rate limiting
168
-
169
- ```typescript
170
- const result = await getArxivEntriesById(
171
- ['2101.01234', '2101.05678'],
172
- {
173
- rateLimit: {
174
- tokensPerInterval: 1,
175
- intervalMs: 3000, // 1 request per 3 seconds
176
- },
177
- timeoutMs: 15000,
178
- }
179
- );
180
- ```
181
-
182
- ### Search with rate limiting
183
-
184
- ```typescript
185
- const result = await getArxivEntries({
186
- search: { title: ['neural networks'] },
187
- rateLimit: {
188
- tokensPerInterval: 1,
189
- intervalMs: 3000, // 1 request per 3 seconds
190
- },
191
- });
192
- ```
193
-
194
- ## Documentation
195
-
196
- ### Generating API Documentation
197
-
198
- To generate browsable API documentation from the source code:
199
-
200
- ```bash
201
- npm run docs:generate
202
- ```
203
-
204
- This will create HTML documentation in the `docs/` directory. You can then view it locally:
205
-
206
- ```bash
207
- npm run docs:serve
208
- ```
209
-
210
- The generated documentation includes:
211
- - Complete API reference for all exported functions and types
212
- - Detailed parameter descriptions and examples
213
- - Type information and relationships
214
- - Search functionality
215
-
216
- ### IDE IntelliSense
217
-
218
- All exported functions and types include JSDoc comments for enhanced IDE IntelliSense support. Hover over any exported symbol in your IDE to see inline documentation.
219
-
220
- ## TypeScript Types
221
-
222
- All types are exported from the package:
223
-
224
- ```typescript
225
- import type {
226
- ArxivQueryOptions,
227
- ArxivQueryResult,
228
- ArxivSearchFilters,
229
- ArxivEntry,
230
- ArxivFeedMeta,
231
- ArxivAuthor,
232
- ArxivLink,
233
- ArxivSortBy,
234
- ArxivSortOrder,
235
- ArxivRateLimitConfig,
236
- ArxivDateRange,
237
- } from 'arxiv-api-wrapper';
238
- ```
239
-
240
- ## License
241
-
242
- ISC
243
-
244
- ## Author
245
-
246
- Vilhelm Agdur
247
-
248
- ## Repository
249
-
250
- https://github.com/vagdur/arxiv-api-wrapper
1
+ # arxiv-api-wrapper
2
+
3
+ A TypeScript package that provides a convenient wrapper around the arXiv API, enabling easy querying and parsing of arXiv papers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install arxiv-api-wrapper
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { getArxivEntries, getArxivEntriesById } from 'arxiv-api-wrapper';
15
+
16
+ // Search for papers
17
+ const result = await getArxivEntries({
18
+ search: {
19
+ title: ['quantum computing'],
20
+ author: ['John Doe'],
21
+ },
22
+ maxResults: 10,
23
+ sortBy: 'submittedDate',
24
+ sortOrder: 'descending',
25
+ });
26
+
27
+ console.log(`Found ${result.feed.totalResults} papers`);
28
+ result.entries.forEach(entry => {
29
+ console.log(`${entry.arxivId}: ${entry.title}`);
30
+ });
31
+
32
+ // Or fetch specific papers by ID
33
+ const papers = await getArxivEntriesById(['2101.01234', '2101.05678']);
34
+ ```
35
+
36
+ ## Features
37
+
38
+ - **Type-safe**: Full TypeScript support with comprehensive type definitions
39
+ - **Flexible Search**: Support for complex queries with multiple filters, OR groups, and negation
40
+ - **Rate Limiting**: Built-in token bucket rate limiter to respect arXiv API guidelines
41
+ - **Retry Logic**: Automatic retries with exponential backoff for transient failures
42
+ - **Pagination**: Support for paginated results with configurable page size
43
+ - **Sorting**: Multiple sort options (relevance, submission date, last updated)
44
+
45
+ ## API Reference
46
+
47
+ For complete API documentation with detailed type information and examples, see the [generated API documentation](https://vagdur.github.io/arxiv-api-wrapper/).
48
+
49
+ ### `getArxivEntriesById(ids: string[], options?): Promise<ArxivQueryResult>`
50
+
51
+ Simpler function to fetch arXiv papers by their IDs using the id_list API mode.
52
+
53
+ **Parameters:**
54
+ - `ids: string[]` - Array of arXiv paper IDs (e.g., `['2101.01234', '2101.05678']`)
55
+ - `options?: object` - Optional request configuration
56
+ - `rateLimit?: { tokensPerInterval: number, intervalMs: number }` - Rate limit configuration
57
+ - `retries?: number` - Number of retry attempts (default: 3)
58
+ - `timeoutMs?: number` - Request timeout in milliseconds (default: 10000)
59
+ - `userAgent?: string` - Custom User-Agent header
60
+
61
+ **Returns:** Same as `getArxivEntries` - see return type below.
62
+
63
+ ### `getArxivEntries(options: ArxivQueryOptions): Promise<ArxivQueryResult>`
64
+
65
+ Main function to query the arXiv API with search filters or ID lists.
66
+
67
+ **Options:**
68
+ - `idList?: string[]` - List of arXiv IDs to fetch (e.g., `['2101.01234', '2101.05678']`)
69
+ - `search?: ArxivSearchFilters` - Search filters (when used with `idList`, filters the entries from `idList` to only return those matching the search query)
70
+ - `start?: number` - Pagination offset (0-based)
71
+ - `maxResults?: number` - Maximum number of results (≤ 300)
72
+ - `sortBy?: 'relevance' | 'lastUpdatedDate' | 'submittedDate'` - Sort field
73
+ - `sortOrder?: 'ascending' | 'descending'` - Sort direction
74
+ - `timeoutMs?: number` - Request timeout in milliseconds (default: 10000)
75
+ - `retries?: number` - Number of retry attempts (default: 3)
76
+ - `rateLimit?: { tokensPerInterval: number, intervalMs: number }` - Rate limit configuration
77
+ - `userAgent?: string` - Custom User-Agent header
78
+
79
+ **Search Filters:**
80
+ - `title?: string[]` - Search in titles
81
+ - `author?: string[]` - Search by author names
82
+ - `abstract?: string[]` - Search in abstracts
83
+ - `category?: string[]` - Filter by arXiv categories
84
+ - `submittedDateRange?: { from: string, to: string }` - Date range filter (YYYYMMDDTTTT format)
85
+ - `or?: ArxivSearchFilters[]` - OR group of filters
86
+ - `andNot?: ArxivSearchFilters` - Negated filter (ANDNOT)
87
+
88
+ **Returns:**
89
+ ```typescript
90
+ {
91
+ feed: {
92
+ id: string;
93
+ updated: string;
94
+ title: string;
95
+ link: string;
96
+ totalResults: number;
97
+ startIndex: number;
98
+ itemsPerPage: number;
99
+ };
100
+ entries: Array<{
101
+ id: string;
102
+ arxivId: string;
103
+ title: string;
104
+ summary: string;
105
+ published: string;
106
+ updated: string;
107
+ authors: Array<{ name: string; affiliation?: string }>;
108
+ categories: string[];
109
+ primaryCategory?: string;
110
+ links: Array<{ href: string; rel?: string; type?: string; title?: string }>;
111
+ doi?: string;
112
+ journalRef?: string;
113
+ comment?: string;
114
+ }>;
115
+ }
116
+ ```
117
+
118
+ ## Examples
119
+
120
+ ### Search by title and author
121
+
122
+ ```typescript
123
+ const result = await getArxivEntries({
124
+ search: {
125
+ title: ['machine learning'],
126
+ author: ['Geoffrey Hinton'],
127
+ },
128
+ maxResults: 5,
129
+ });
130
+ ```
131
+
132
+ ### Fetch specific papers by ID
133
+
134
+ Using the simpler `getArxivEntriesById` function:
135
+
136
+ ```typescript
137
+ const result = await getArxivEntriesById(['2101.01234', '2101.05678']);
138
+ ```
139
+
140
+ Or using `getArxivEntries`:
141
+
142
+ ```typescript
143
+ const result = await getArxivEntries({
144
+ idList: ['2101.01234', '2101.05678'],
145
+ });
146
+ ```
147
+
148
+ ### Complex search with OR and date range
149
+
150
+ ```typescript
151
+ const result = await getArxivEntries({
152
+ search: {
153
+ or: [
154
+ { title: ['quantum'] },
155
+ { abstract: ['quantum'] },
156
+ ],
157
+ submittedDateRange: {
158
+ from: '202301010600',
159
+ to: '202401010600',
160
+ },
161
+ },
162
+ sortBy: 'submittedDate',
163
+ sortOrder: 'descending',
164
+ });
165
+ ```
166
+
167
+ ### Fetch papers by ID with rate limiting
168
+
169
+ ```typescript
170
+ const result = await getArxivEntriesById(
171
+ ['2101.01234', '2101.05678'],
172
+ {
173
+ rateLimit: {
174
+ tokensPerInterval: 1,
175
+ intervalMs: 3000, // 1 request per 3 seconds
176
+ },
177
+ timeoutMs: 15000,
178
+ }
179
+ );
180
+ ```
181
+
182
+ ### Search with rate limiting
183
+
184
+ ```typescript
185
+ const result = await getArxivEntries({
186
+ search: { title: ['neural networks'] },
187
+ rateLimit: {
188
+ tokensPerInterval: 1,
189
+ intervalMs: 3000, // 1 request per 3 seconds
190
+ },
191
+ });
192
+ ```
193
+
194
+ ## Documentation
195
+
196
+ ### Generating API Documentation
197
+
198
+ To generate browsable API documentation from the source code:
199
+
200
+ ```bash
201
+ npm run docs:generate
202
+ ```
203
+
204
+ This will create HTML documentation in the `docs/` directory. You can then view it locally:
205
+
206
+ ```bash
207
+ npm run docs:serve
208
+ ```
209
+
210
+ The generated documentation includes:
211
+ - Complete API reference for all exported functions and types
212
+ - Detailed parameter descriptions and examples
213
+ - Type information and relationships
214
+ - Search functionality
215
+
216
+ ### IDE IntelliSense
217
+
218
+ All exported functions and types include JSDoc comments for enhanced IDE IntelliSense support. Hover over any exported symbol in your IDE to see inline documentation.
219
+
220
+ ## TypeScript Types
221
+
222
+ All types are exported from the package:
223
+
224
+ ```typescript
225
+ import type {
226
+ ArxivQueryOptions,
227
+ ArxivQueryResult,
228
+ ArxivSearchFilters,
229
+ ArxivEntry,
230
+ ArxivFeedMeta,
231
+ ArxivAuthor,
232
+ ArxivLink,
233
+ ArxivSortBy,
234
+ ArxivSortOrder,
235
+ ArxivRateLimitConfig,
236
+ ArxivDateRange,
237
+ } from 'arxiv-api-wrapper';
238
+ ```
239
+
240
+ ## License
241
+
242
+ ISC
243
+
244
+ ## Author
245
+
246
+ Vilhelm Agdur
247
+
248
+ ## Repository
249
+
250
+ https://github.com/vagdur/arxiv-api-wrapper
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arxiv-api-wrapper",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Provides functions wrapping the arXiv API",
5
5
  "keywords": [
6
6
  "arxiv"
@@ -20,16 +20,18 @@
20
20
  "types": "./src/index.ts",
21
21
  "scripts": {
22
22
  "test": "vitest run --config tests/vitest.config.mts",
23
+ "typecheck": "tsc --noEmit",
24
+ "check": "npm run typecheck && npm run test && npm audit",
23
25
  "docs:generate": "typedoc",
24
26
  "docs:serve": "npx serve docs"
25
27
  },
26
28
  "dependencies": {
27
- "fast-xml-parser": "^4.3.5"
29
+ "fast-xml-parser": "^5.3.5"
28
30
  },
29
31
  "devDependencies": {
30
32
  "@types/node": "^25.0.0",
31
33
  "typedoc": "^0.26.0",
32
34
  "typescript": "^5.0.0",
33
- "vitest": "^1.0.0"
35
+ "vitest": "^4.0.18"
34
36
  }
35
37
  }