arxiv-api-wrapper 1.0.1 → 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.
@@ -0,0 +1,66 @@
1
+ # Simple workflow for deploying static content to GitHub Pages
2
+ name: Deploy static content to Pages
3
+
4
+ on:
5
+ # Runs on pushes targeting the default branch
6
+ push:
7
+ branches: ["main"]
8
+
9
+ # Allows you to run this workflow manually from the Actions tab
10
+ workflow_dispatch:
11
+
12
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13
+ permissions:
14
+ contents: write
15
+ pages: write
16
+ id-token: write
17
+
18
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20
+ concurrency:
21
+ group: "pages"
22
+ cancel-in-progress: false
23
+
24
+ jobs:
25
+ # Single deploy job since we're just deploying
26
+ deploy:
27
+ environment:
28
+ name: github-pages
29
+ url: ${{ steps.deployment.outputs.page_url }}
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Checkout
33
+ uses: actions/checkout@v4
34
+ with:
35
+ token: ${{ secrets.GITHUB_TOKEN }}
36
+ - name: Setup Node.js
37
+ uses: actions/setup-node@v4
38
+ with:
39
+ node-version: '20'
40
+ - name: Install dependencies
41
+ run: npm ci
42
+ - name: Generate documentation
43
+ run: npm run docs:generate
44
+ - name: Configure git
45
+ run: |
46
+ git config --local user.email "action@github.com"
47
+ git config --local user.name "GitHub Action"
48
+ - name: Commit generated docs
49
+ run: |
50
+ git add docs/
51
+ if git diff --staged --quiet; then
52
+ echo "No changes to commit"
53
+ else
54
+ git commit -m "docs: regenerate documentation [skip ci]"
55
+ git push
56
+ fi
57
+ - name: Setup Pages
58
+ uses: actions/configure-pages@v5
59
+ - name: Upload artifact
60
+ uses: actions/upload-pages-artifact@v3
61
+ with:
62
+ # Upload docs path
63
+ path: './docs'
64
+ - name: Deploy to GitHub Pages
65
+ id: deployment
66
+ uses: actions/deploy-pages@v4
package/README.md CHANGED
@@ -1,209 +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 } from 'arxiv-api-wrapper';
15
-
16
- const result = await getArxivEntries({
17
- search: {
18
- title: ['quantum computing'],
19
- author: ['John Doe'],
20
- },
21
- maxResults: 10,
22
- sortBy: 'submittedDate',
23
- sortOrder: 'descending',
24
- });
25
-
26
- console.log(`Found ${result.feed.totalResults} papers`);
27
- result.entries.forEach(entry => {
28
- console.log(`${entry.arxivId}: ${entry.title}`);
29
- });
30
- ```
31
-
32
- ## Features
33
-
34
- - **Type-safe**: Full TypeScript support with comprehensive type definitions
35
- - **Flexible Search**: Support for complex queries with multiple filters, OR groups, and negation
36
- - **Rate Limiting**: Built-in token bucket rate limiter to respect arXiv API guidelines
37
- - **Retry Logic**: Automatic retries with exponential backoff for transient failures
38
- - **Pagination**: Support for paginated results with configurable page size
39
- - **Sorting**: Multiple sort options (relevance, submission date, last updated)
40
-
41
- ## API Reference
42
-
43
- For complete API documentation with detailed type information and examples, see the [generated API documentation](./docs/index.html) (generate with `npm run docs:generate`).
44
-
45
- ### `getArxivEntries(options: ArxivQueryOptions): Promise<ArxivQueryResult>`
46
-
47
- Main function to query the arXiv API.
48
-
49
- **Options:**
50
- - `idList?: string[]` - List of arXiv IDs to fetch (e.g., `['2101.01234', '2101.05678']`)
51
- - `search?: ArxivSearchFilters` - Search filters (ignored if `idList` is provided)
52
- - `start?: number` - Pagination offset (0-based)
53
- - `maxResults?: number` - Maximum number of results (≤ 300)
54
- - `sortBy?: 'relevance' | 'lastUpdatedDate' | 'submittedDate'` - Sort field
55
- - `sortOrder?: 'ascending' | 'descending'` - Sort direction
56
- - `timeoutMs?: number` - Request timeout in milliseconds (default: 10000)
57
- - `retries?: number` - Number of retry attempts (default: 3)
58
- - `rateLimit?: { tokensPerInterval: number, intervalMs: number }` - Rate limit configuration
59
- - `userAgent?: string` - Custom User-Agent header
60
-
61
- **Search Filters:**
62
- - `title?: string[]` - Search in titles
63
- - `author?: string[]` - Search by author names
64
- - `abstract?: string[]` - Search in abstracts
65
- - `category?: string[]` - Filter by arXiv categories
66
- - `submittedDateRange?: { from: string, to: string }` - Date range filter (YYYYMMDDTTTT format)
67
- - `or?: ArxivSearchFilters[]` - OR group of filters
68
- - `andNot?: ArxivSearchFilters` - Negated filter (ANDNOT)
69
-
70
- **Returns:**
71
- ```typescript
72
- {
73
- feed: {
74
- id: string;
75
- updated: string;
76
- title: string;
77
- link: string;
78
- totalResults: number;
79
- startIndex: number;
80
- itemsPerPage: number;
81
- };
82
- entries: Array<{
83
- id: string;
84
- arxivId: string;
85
- title: string;
86
- summary: string;
87
- published: string;
88
- updated: string;
89
- authors: Array<{ name: string; affiliation?: string }>;
90
- categories: string[];
91
- primaryCategory?: string;
92
- links: Array<{ href: string; rel?: string; type?: string; title?: string }>;
93
- doi?: string;
94
- journalRef?: string;
95
- comment?: string;
96
- }>;
97
- }
98
- ```
99
-
100
- ## Examples
101
-
102
- ### Search by title and author
103
-
104
- ```typescript
105
- const result = await getArxivEntries({
106
- search: {
107
- title: ['machine learning'],
108
- author: ['Geoffrey Hinton'],
109
- },
110
- maxResults: 5,
111
- });
112
- ```
113
-
114
- ### Fetch specific papers by ID
115
-
116
- ```typescript
117
- const result = await getArxivEntries({
118
- idList: ['2101.01234', '2101.05678'],
119
- });
120
- ```
121
-
122
- ### Complex search with OR and date range
123
-
124
- ```typescript
125
- const result = await getArxivEntries({
126
- search: {
127
- or: [
128
- { title: ['quantum'] },
129
- { abstract: ['quantum'] },
130
- ],
131
- submittedDateRange: {
132
- from: '202301010600',
133
- to: '202401010600',
134
- },
135
- },
136
- sortBy: 'submittedDate',
137
- sortOrder: 'descending',
138
- });
139
- ```
140
-
141
- ### With rate limiting
142
-
143
- ```typescript
144
- const result = await getArxivEntries({
145
- search: { title: ['neural networks'] },
146
- rateLimit: {
147
- tokensPerInterval: 1,
148
- intervalMs: 3000, // 1 request per 3 seconds
149
- },
150
- });
151
- ```
152
-
153
- ## Documentation
154
-
155
- ### Generating API Documentation
156
-
157
- To generate browsable API documentation from the source code:
158
-
159
- ```bash
160
- npm run docs:generate
161
- ```
162
-
163
- This will create HTML documentation in the `docs/` directory. You can then view it locally:
164
-
165
- ```bash
166
- npm run docs:serve
167
- ```
168
-
169
- The generated documentation includes:
170
- - Complete API reference for all exported functions and types
171
- - Detailed parameter descriptions and examples
172
- - Type information and relationships
173
- - Search functionality
174
-
175
- ### IDE IntelliSense
176
-
177
- 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.
178
-
179
- ## TypeScript Types
180
-
181
- All types are exported from the package:
182
-
183
- ```typescript
184
- import type {
185
- ArxivQueryOptions,
186
- ArxivQueryResult,
187
- ArxivSearchFilters,
188
- ArxivEntry,
189
- ArxivFeedMeta,
190
- ArxivAuthor,
191
- ArxivLink,
192
- ArxivSortBy,
193
- ArxivSortOrder,
194
- ArxivRateLimitConfig,
195
- ArxivDateRange,
196
- } from 'arxiv-api-wrapper';
197
- ```
198
-
199
- ## License
200
-
201
- ISC
202
-
203
- ## Author
204
-
205
- Vilhelm Agdur
206
-
207
- ## Repository
208
-
209
- 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.0.1",
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
  }