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.
- package/.github/workflows/static.yml +66 -0
- package/README.md +250 -209
- package/package.json +5 -3
- package/src/arxivAPIRead.ts +316 -246
- package/src/atom.ts +1 -1
- package/src/index.ts +57 -57
- package/src/types.ts +265 -265
- package/tests/arxivAPI.integration.test.ts +144 -98
- package/tests/arxivAPIRead.test.ts +1 -1
- package/tests/fixtures/parseEntries/2507.17541.json.ts +1 -1
- package/tests/fixtures/parseEntries/search_agdur.json.ts +1 -1
- package/tsconfig.json +13 -0
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
result.
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- **
|
|
39
|
-
- **
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- `
|
|
55
|
-
- `
|
|
56
|
-
- `
|
|
57
|
-
- `retries?: number` - Number of retry attempts (default: 3)
|
|
58
|
-
- `
|
|
59
|
-
- `userAgent?: string` - Custom User-Agent header
|
|
60
|
-
|
|
61
|
-
**
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- `
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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.
|
|
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": "^
|
|
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": "^
|
|
35
|
+
"vitest": "^4.0.18"
|
|
34
36
|
}
|
|
35
37
|
}
|