arxiv-api-wrapper 1.0.0 → 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/README.md +209 -0
- package/package.json +6 -2
- package/src/arxivAPIRead.ts +91 -0
- package/src/index.ts +42 -1
- package/src/types.ts +178 -0
- package/typedoc.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,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 } 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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arxiv-api-wrapper",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Provides functions wrapping the arXiv API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"arxiv"
|
|
@@ -19,12 +19,16 @@
|
|
|
19
19
|
"main": "./src/index.ts",
|
|
20
20
|
"types": "./src/index.ts",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"test": "vitest run --config tests/vitest.config.mts"
|
|
22
|
+
"test": "vitest run --config tests/vitest.config.mts",
|
|
23
|
+
"docs:generate": "typedoc",
|
|
24
|
+
"docs:serve": "npx serve docs"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {
|
|
25
27
|
"fast-xml-parser": "^4.3.5"
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
30
|
+
"@types/node": "^25.0.0",
|
|
31
|
+
"typedoc": "^0.26.0",
|
|
28
32
|
"typescript": "^5.0.0",
|
|
29
33
|
"vitest": "^1.0.0"
|
|
30
34
|
}
|
package/src/arxivAPIRead.ts
CHANGED
|
@@ -45,6 +45,40 @@ function joinAnd(parts: string[]): string {
|
|
|
45
45
|
return parts.filter(Boolean).join('+AND+');
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Builds an arXiv search query string from search filters.
|
|
50
|
+
*
|
|
51
|
+
* This function converts the structured `ArxivSearchFilters` object into
|
|
52
|
+
* a query string compatible with the arXiv API search syntax. Multiple terms
|
|
53
|
+
* in the same field are combined with AND, and multiple fields are combined
|
|
54
|
+
* with AND. OR groups and negation (ANDNOT) are also supported.
|
|
55
|
+
*
|
|
56
|
+
* @param filters - Search filters to convert to query string
|
|
57
|
+
* @returns URL-encoded query string ready for arXiv API
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const query = buildSearchQuery({
|
|
62
|
+
* title: ['machine learning'],
|
|
63
|
+
* author: ['Geoffrey Hinton'],
|
|
64
|
+
* });
|
|
65
|
+
* // Returns: "ti:\"machine learning\"+AND+au:\"Geoffrey Hinton\""
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Complex query with OR groups
|
|
71
|
+
* const query = buildSearchQuery({
|
|
72
|
+
* or: [
|
|
73
|
+
* { title: ['quantum'] },
|
|
74
|
+
* { abstract: ['quantum'] },
|
|
75
|
+
* ],
|
|
76
|
+
* category: ['quant-ph'],
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see {@link ArxivSearchFilters} for filter options
|
|
81
|
+
*/
|
|
48
82
|
export function buildSearchQuery(filters: ArxivSearchFilters): string {
|
|
49
83
|
const parts: string[] = [];
|
|
50
84
|
const phraseExact = filters.phraseExact;
|
|
@@ -110,6 +144,63 @@ function buildUrl(opts: ArxivQueryOptions): string {
|
|
|
110
144
|
return `${ARXIV_BASE_URL}?${qs}`;
|
|
111
145
|
}
|
|
112
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Queries the arXiv API and returns matching paper entries.
|
|
149
|
+
*
|
|
150
|
+
* This is the main function for interacting with the arXiv API. It supports
|
|
151
|
+
* searching by various criteria, fetching specific papers by ID, pagination,
|
|
152
|
+
* sorting, rate limiting, and automatic retries with exponential backoff.
|
|
153
|
+
*
|
|
154
|
+
* @param options - Query options including search filters, pagination, and request configuration
|
|
155
|
+
* @returns Promise resolving to query results with feed metadata and paper entries
|
|
156
|
+
*
|
|
157
|
+
* @throws {Error} If the API request fails after all retries
|
|
158
|
+
* @throws {Error} If the API returns a non-2xx status code
|
|
159
|
+
* @throws {Error} If the API returns an empty response
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* // Simple search
|
|
164
|
+
* const result = await getArxivEntries({
|
|
165
|
+
* search: {
|
|
166
|
+
* title: ['quantum computing'],
|
|
167
|
+
* author: ['John Doe'],
|
|
168
|
+
* },
|
|
169
|
+
* maxResults: 10,
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* console.log(`Found ${result.feed.totalResults} papers`);
|
|
173
|
+
* result.entries.forEach(entry => {
|
|
174
|
+
* console.log(`${entry.arxivId}: ${entry.title}`);
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* // Fetch specific papers by ID
|
|
181
|
+
* const result = await getArxivEntries({
|
|
182
|
+
* idList: ['2101.01234', '2101.05678'],
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* // With rate limiting and custom timeout
|
|
189
|
+
* const result = await getArxivEntries({
|
|
190
|
+
* search: { title: ['neural networks'] },
|
|
191
|
+
* rateLimit: {
|
|
192
|
+
* tokensPerInterval: 1,
|
|
193
|
+
* intervalMs: 3000, // 1 request per 3 seconds
|
|
194
|
+
* },
|
|
195
|
+
* timeoutMs: 15000,
|
|
196
|
+
* retries: 5,
|
|
197
|
+
* });
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* @see {@link ArxivQueryOptions} for all available options
|
|
201
|
+
* @see {@link ArxivQueryResult} for the return type structure
|
|
202
|
+
* @see {@link ArxivSearchFilters} for search filter options
|
|
203
|
+
*/
|
|
113
204
|
export async function getArxivEntries(options: ArxivQueryOptions): Promise<ArxivQueryResult> {
|
|
114
205
|
const timeoutMs = options.timeoutMs ?? 10000;
|
|
115
206
|
const retries = options.retries ?? 3;
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* # arxiv-api-wrapper
|
|
5
|
+
*
|
|
6
|
+
* A TypeScript package that provides a convenient wrapper around the arXiv API,
|
|
7
|
+
* enabling easy querying and parsing of arXiv papers.
|
|
8
|
+
*
|
|
9
|
+
* ## Features
|
|
10
|
+
*
|
|
11
|
+
* - **Type-safe**: Full TypeScript support with comprehensive type definitions
|
|
12
|
+
* - **Flexible Search**: Support for complex queries with multiple filters, OR groups, and negation
|
|
13
|
+
* - **Rate Limiting**: Built-in token bucket rate limiter to respect arXiv API guidelines
|
|
14
|
+
* - **Retry Logic**: Automatic retries with exponential backoff for transient failures
|
|
15
|
+
* - **Pagination**: Support for paginated results with configurable page size
|
|
16
|
+
* - **Sorting**: Multiple sort options (relevance, submission date, last updated)
|
|
17
|
+
*
|
|
18
|
+
* ## Quick Start
|
|
19
|
+
*
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { getArxivEntries } from 'arxiv-api-wrapper';
|
|
22
|
+
*
|
|
23
|
+
* const result = await getArxivEntries({
|
|
24
|
+
* search: {
|
|
25
|
+
* title: ['quantum computing'],
|
|
26
|
+
* author: ['John Doe'],
|
|
27
|
+
* },
|
|
28
|
+
* maxResults: 10,
|
|
29
|
+
* sortBy: 'submittedDate',
|
|
30
|
+
* sortOrder: 'descending',
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* console.log(`Found ${result.feed.totalResults} papers`);
|
|
34
|
+
* result.entries.forEach(entry => {
|
|
35
|
+
* console.log(`${entry.arxivId}: ${entry.title}`);
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @module arxiv-api-wrapper
|
|
40
|
+
*/
|
|
41
|
+
|
|
1
42
|
// Main entry point for the arXiv API wrapper package
|
|
2
|
-
export { getArxivEntries
|
|
43
|
+
export { getArxivEntries } from './arxivAPIRead';
|
|
3
44
|
export type {
|
|
4
45
|
ArxivQueryOptions,
|
|
5
46
|
ArxivQueryResult,
|
package/src/types.ts
CHANGED
|
@@ -1,87 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sort field options for arXiv query results.
|
|
3
|
+
*/
|
|
1
4
|
export type ArxivSortBy = 'relevance' | 'lastUpdatedDate' | 'submittedDate';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sort order direction for arXiv query results.
|
|
8
|
+
*/
|
|
2
9
|
export type ArxivSortOrder = 'ascending' | 'descending';
|
|
3
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for token bucket rate limiting.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const rateLimit: ArxivRateLimitConfig = {
|
|
17
|
+
* tokensPerInterval: 1,
|
|
18
|
+
* intervalMs: 3000, // 1 request per 3 seconds
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
4
22
|
export interface ArxivRateLimitConfig {
|
|
23
|
+
/** Number of tokens (requests) allowed per interval */
|
|
5
24
|
tokensPerInterval: number;
|
|
25
|
+
/** Interval duration in milliseconds */
|
|
6
26
|
intervalMs: number;
|
|
7
27
|
}
|
|
8
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Date range filter for arXiv queries.
|
|
31
|
+
* Dates must be in YYYYMMDDTTTT format (GMT timezone).
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const dateRange: ArxivDateRange = {
|
|
36
|
+
* from: '202301010600',
|
|
37
|
+
* to: '202401010600',
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
9
41
|
export interface ArxivDateRange {
|
|
42
|
+
/** Start date in YYYYMMDDTTTT format (GMT) */
|
|
10
43
|
from: string; // YYYYMMDDTTTT (GMT)
|
|
44
|
+
/** End date in YYYYMMDDTTTT format (GMT) */
|
|
11
45
|
to: string; // YYYYMMDDTTTT (GMT)
|
|
12
46
|
}
|
|
13
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Search filters for querying arXiv papers.
|
|
50
|
+
* Multiple terms in the same field are combined with AND.
|
|
51
|
+
* Multiple fields are combined with AND.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const filters: ArxivSearchFilters = {
|
|
56
|
+
* title: ['machine learning'],
|
|
57
|
+
* author: ['Geoffrey Hinton'],
|
|
58
|
+
* category: ['cs.LG'],
|
|
59
|
+
* };
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Complex query with OR groups
|
|
65
|
+
* const filters: ArxivSearchFilters = {
|
|
66
|
+
* or: [
|
|
67
|
+
* { title: ['quantum'] },
|
|
68
|
+
* { abstract: ['quantum'] },
|
|
69
|
+
* ],
|
|
70
|
+
* submittedDateRange: {
|
|
71
|
+
* from: '202301010600',
|
|
72
|
+
* to: '202401010600',
|
|
73
|
+
* },
|
|
74
|
+
* };
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @see {@link ArxivDateRange} for date range format
|
|
78
|
+
*/
|
|
14
79
|
export interface ArxivSearchFilters {
|
|
80
|
+
/** Search terms to match in all fields */
|
|
15
81
|
all?: string[];
|
|
82
|
+
/** Search terms to match in paper titles (arXiv field: ti:) */
|
|
16
83
|
title?: string[]; // ti:
|
|
84
|
+
/** Search terms to match author names (arXiv field: au:) */
|
|
17
85
|
author?: string[]; // au:
|
|
86
|
+
/** Search terms to match in abstracts (arXiv field: abs:) */
|
|
18
87
|
abstract?: string[]; // abs:
|
|
88
|
+
/** Search terms to match in comments (arXiv field: co:) */
|
|
19
89
|
comment?: string[]; // co:
|
|
90
|
+
/** Search terms to match in journal references (arXiv field: jr:) */
|
|
20
91
|
journalRef?: string[]; // jr:
|
|
92
|
+
/** arXiv category codes to filter by (arXiv field: cat:) */
|
|
21
93
|
category?: string[]; // cat:
|
|
94
|
+
/** Date range filter for submission dates (arXiv field: submittedDate:[from TO to]) */
|
|
22
95
|
submittedDateRange?: ArxivDateRange; // submittedDate:[from TO to]
|
|
23
96
|
|
|
24
97
|
// Composition
|
|
98
|
+
/** OR group: at least one of the subfilters must match */
|
|
25
99
|
or?: ArxivSearchFilters[]; // grouped OR of subfilters
|
|
100
|
+
/** Negated filter: exclude papers matching this filter */
|
|
26
101
|
andNot?: ArxivSearchFilters; // negated subfilter
|
|
27
102
|
|
|
28
103
|
// Encoding behavior
|
|
104
|
+
/** If true, wrap each search term in quotes for exact phrase matching */
|
|
29
105
|
phraseExact?: boolean; // wrap each term in quotes
|
|
30
106
|
}
|
|
31
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Options for querying the arXiv API.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const options: ArxivQueryOptions = {
|
|
114
|
+
* search: {
|
|
115
|
+
* title: ['quantum computing'],
|
|
116
|
+
* author: ['John Doe'],
|
|
117
|
+
* },
|
|
118
|
+
* maxResults: 10,
|
|
119
|
+
* sortBy: 'submittedDate',
|
|
120
|
+
* sortOrder: 'descending',
|
|
121
|
+
* };
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @see {@link ArxivSearchFilters} for search filter details
|
|
125
|
+
* @see {@link ArxivRateLimitConfig} for rate limiting configuration
|
|
126
|
+
*/
|
|
32
127
|
export interface ArxivQueryOptions {
|
|
128
|
+
/** List of arXiv IDs to fetch directly (e.g., ['2101.01234', '2101.05678']). If provided, search filters are ignored. */
|
|
33
129
|
idList?: string[];
|
|
130
|
+
/** Search filters to query papers. Ignored if `idList` is provided. */
|
|
34
131
|
search?: ArxivSearchFilters; // ignored if idList present
|
|
132
|
+
/** Pagination offset (0-based index) */
|
|
35
133
|
start?: number; // 0-based
|
|
134
|
+
/** Maximum number of results to return (≤ 300 per arXiv API guidance) */
|
|
36
135
|
maxResults?: number; // <= 300 per arXiv guidance
|
|
136
|
+
/** Field to sort results by */
|
|
37
137
|
sortBy?: ArxivSortBy;
|
|
138
|
+
/** Sort order direction */
|
|
38
139
|
sortOrder?: ArxivSortOrder;
|
|
140
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
39
141
|
timeoutMs?: number; // default 10000
|
|
142
|
+
/** Number of retry attempts for failed requests (default: 3) */
|
|
40
143
|
retries?: number; // default 3
|
|
144
|
+
/** Rate limiting configuration to respect arXiv API guidelines */
|
|
41
145
|
rateLimit?: ArxivRateLimitConfig;
|
|
146
|
+
/** Custom User-Agent header for requests */
|
|
42
147
|
userAgent?: string; // optional custom UA header
|
|
43
148
|
}
|
|
44
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Link metadata for an arXiv paper entry.
|
|
152
|
+
* Links may point to the abstract page, PDF, source files, etc.
|
|
153
|
+
*/
|
|
45
154
|
export interface ArxivLink {
|
|
155
|
+
/** URL of the link */
|
|
46
156
|
href: string;
|
|
157
|
+
/** Link relation type (e.g., 'alternate', 'related') */
|
|
47
158
|
rel?: string;
|
|
159
|
+
/** MIME type of the linked resource */
|
|
48
160
|
type?: string;
|
|
161
|
+
/** Human-readable title for the link */
|
|
49
162
|
title?: string;
|
|
50
163
|
}
|
|
51
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Author information for an arXiv paper.
|
|
167
|
+
*/
|
|
52
168
|
export interface ArxivAuthor {
|
|
169
|
+
/** Author's full name */
|
|
53
170
|
name: string;
|
|
171
|
+
/** Author's institutional affiliation (if provided) */
|
|
54
172
|
affiliation?: string;
|
|
55
173
|
}
|
|
56
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Represents a single arXiv paper entry.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const entry: ArxivEntry = {
|
|
181
|
+
* id: 'http://arxiv.org/abs/2101.01234v2',
|
|
182
|
+
* arxivId: '2101.01234v2',
|
|
183
|
+
* title: 'Example Paper Title',
|
|
184
|
+
* summary: 'Paper abstract...',
|
|
185
|
+
* published: '2021-01-01T12:00:00Z',
|
|
186
|
+
* updated: '2021-01-02T12:00:00Z',
|
|
187
|
+
* authors: [{ name: 'John Doe', affiliation: 'University' }],
|
|
188
|
+
* categories: ['cs.LG', 'cs.AI'],
|
|
189
|
+
* primaryCategory: 'cs.LG',
|
|
190
|
+
* links: [...],
|
|
191
|
+
* };
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
57
194
|
export interface ArxivEntry {
|
|
195
|
+
/** Full URL to the paper's abstract page */
|
|
58
196
|
id: string; // abs URL
|
|
197
|
+
/** arXiv ID including version (e.g., '2101.01234v2') */
|
|
59
198
|
arxivId: string; // e.g., 2101.01234v2
|
|
199
|
+
/** Paper title */
|
|
60
200
|
title: string;
|
|
201
|
+
/** Paper abstract/summary */
|
|
61
202
|
summary: string;
|
|
203
|
+
/** Publication date (ISO 8601 format) */
|
|
62
204
|
published: string;
|
|
205
|
+
/** Last update date (ISO 8601 format) */
|
|
63
206
|
updated: string;
|
|
207
|
+
/** List of paper authors */
|
|
64
208
|
authors: ArxivAuthor[];
|
|
209
|
+
/** arXiv category codes assigned to the paper */
|
|
65
210
|
categories: string[];
|
|
211
|
+
/** Primary arXiv category code */
|
|
66
212
|
primaryCategory?: string;
|
|
213
|
+
/** Links to abstract, PDF, source files, etc. */
|
|
67
214
|
links: ArxivLink[];
|
|
215
|
+
/** Digital Object Identifier (if published elsewhere) */
|
|
68
216
|
doi?: string;
|
|
217
|
+
/** Journal reference (if published) */
|
|
69
218
|
journalRef?: string;
|
|
219
|
+
/** Author comments about the paper */
|
|
70
220
|
comment?: string;
|
|
71
221
|
}
|
|
72
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Metadata about the arXiv query feed/response.
|
|
225
|
+
*/
|
|
73
226
|
export interface ArxivFeedMeta {
|
|
227
|
+
/** Feed identifier */
|
|
74
228
|
id: string;
|
|
229
|
+
/** Feed last update timestamp (ISO 8601 format) */
|
|
75
230
|
updated: string;
|
|
231
|
+
/** Feed title */
|
|
76
232
|
title: string;
|
|
233
|
+
/** Link to the query that generated this feed */
|
|
77
234
|
link: string;
|
|
235
|
+
/** Total number of results matching the query */
|
|
78
236
|
totalResults: number;
|
|
237
|
+
/** Starting index of results in this page (0-based) */
|
|
79
238
|
startIndex: number;
|
|
239
|
+
/** Number of items per page in this response */
|
|
80
240
|
itemsPerPage: number;
|
|
81
241
|
}
|
|
82
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Complete result from an arXiv API query.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* const result: ArxivQueryResult = await getArxivEntries({
|
|
249
|
+
* search: { title: ['machine learning'] },
|
|
250
|
+
* maxResults: 10,
|
|
251
|
+
* });
|
|
252
|
+
*
|
|
253
|
+
* console.log(`Found ${result.feed.totalResults} papers`);
|
|
254
|
+
* result.entries.forEach(entry => {
|
|
255
|
+
* console.log(`${entry.arxivId}: ${entry.title}`);
|
|
256
|
+
* });
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
83
259
|
export interface ArxivQueryResult {
|
|
260
|
+
/** Feed metadata and pagination information */
|
|
84
261
|
feed: ArxivFeedMeta;
|
|
262
|
+
/** Array of arXiv paper entries */
|
|
85
263
|
entries: ArxivEntry[];
|
|
86
264
|
}
|
|
87
265
|
|
package/typedoc.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://typedoc.org/schema.json",
|
|
3
|
+
"entryPoints": ["./src/index.ts"],
|
|
4
|
+
"out": "docs",
|
|
5
|
+
"name": "arxiv-api-wrapper",
|
|
6
|
+
"readme": "./README.md",
|
|
7
|
+
"includeVersion": true,
|
|
8
|
+
"excludePrivate": true,
|
|
9
|
+
"excludeProtected": true,
|
|
10
|
+
"excludeInternal": true,
|
|
11
|
+
"theme": "default",
|
|
12
|
+
"sort": ["source-order"],
|
|
13
|
+
"categorizeByGroup": true,
|
|
14
|
+
"categoryOrder": [
|
|
15
|
+
"Functions",
|
|
16
|
+
"Interfaces",
|
|
17
|
+
"Types"
|
|
18
|
+
],
|
|
19
|
+
"gitRevision": "main",
|
|
20
|
+
"gitRemote": "origin",
|
|
21
|
+
"validation": {
|
|
22
|
+
"invalidLink": true,
|
|
23
|
+
"notDocumented": false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|