Papers
Read the paper graph
Load a paper's nodes in reading order and move between them.
The Paper Graph is the structured content of a paper: an ordered list of nodes such as titles, paragraphs and tables.
Load the graph
const graph = await paperful.papers.graph("00000000-0000-0000-0000-000000000000");
for (const node of graph.nodes) {
console.log(node.position, node.type, node.page);
} Load every node
Large papers are loaded one page at a time. Each call to next() adds the following page to graph.nodes.
const graph = await paperful.papers.graph("00000000-0000-0000-0000-000000000000");
while (graph.cursor.next) {
await graph.next();
}
console.log(graph.nodes.length === graph.total); Filter by type
const tables = graph.nodes.filter((node) => node.type === "table"); See the List nodes API reference for every type.
Move between nodes
Each node can reach its neighbours. Missing pages are loaded automatically. To load several neighbours at once, use the node's context.
const node = graph.nodes[0];
const next = await node.next();
const previous = await node.previous(); // undefined at the start of the paper