1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { fetch } from "https://esm.town/v/std/fetch";
export const searchArXiV = async ({ query = "", start = 0, max_results = 10 }) => {
const { parseStringPromise } = await import("npm:xml2js");
const url = new URL("https://export.arxiv.org/api/query");
url.searchParams.set("search_query", query);
url.searchParams.set("start", start);
url.searchParams.set("max_results", max_results);
const response = await fetch(url.toString());
const text = await response.text();
if (!response.ok) {
throw new Error(text);
}
const feed = await parseStringPromise(text);
return feed;
};