Registry / devops / get-sitemap-links

get-sitemap-links

JSON →
library1.1.0jsnpmunverified

A TypeScript library to fetch and parse all links recursively from a sitemap XML file, including support for sitemap indexes. Version 1.1.0 is the latest stable release. It uses native fetch (Node >=18.0) or node-fetch for earlier versions. Key differentiator is its recursive crawling of sitemap index files and ability to filter specific indexes. Lightweight with zero runtime dependencies beyond node-fetch for older Node versions.

npm install get-sitemap-links
INSTALL
IMPORT
SIG · GET-SITEMAP-LINKS
G
get-sitemap-links
devopsjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export (GetSitemapLinks)
import GetSitemapLinks from 'get-sitemap-links'
const GetSitemapLinks = require('get-sitemap-links')
The library exports a default function. In CommonJS, you must use .default to access it.
CommonJS require
const GetSitemapLinks = require('get-sitemap-links').default
const GetSitemapLinks = require('get-sitemap-links')
Direct require gives an object with a default property.
TypeScript type imports
import type { SitemapOptions } from 'get-sitemap-links'
Types are not exported; the library doesn't expose explicit type exports in its documentation. Use 'typeof GetSitemapLinks' for parameter types if needed.

Fetches all links from a sitemap URL recursively, handling index sitemaps.

import GetSitemapLinks from 'get-sitemap-links'; (async () => { const urls = await GetSitemapLinks('https://example.com/sitemap.xml'); console.log(urls.length); })();
Debug
Known issues
gotchaIn CommonJS, require returns an object with .default property; failing to use .default yields undefined or errors.
fix
Use require('get-sitemap-links').default instead of require('get-sitemap-links')
affects: >=1.0.0
gotchaLibrary uses native fetch (Node 18+) but falls back to node-fetch for older versions. If node-fetch is not installed on Node <18, throws an error.
fix
Install node-fetch as a dependency if using Node <18, or upgrade to Node >=18.
affects: >=1.0.0
gotchaThe filterIndexes option only works when the provided URL is a sitemap index; otherwise it is ignored.
fix
Ensure the sitemap URL points to a valid sitemap index (e.g., /sitemap.xml) when using filterIndexes.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: GetSitemapLinks is not a function
Using CommonJS require without .default.
fix
const GetSitemapLinks = require('get-sitemap-links').default;
Error: Cannot find module 'node-fetch'
Using Node <18 without node-fetch installed.
fix
npm install node-fetch or upgrade Node to >=18.
TypeError: Failed to parse sitemap XML
URL points to a non-XML or invalid sitemap file.
fix
Verify the sitemap URL is correct and accessible.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
node-fetchoptionalRequired for Node.js versions < 18 that lack native fetch. Automatically used as fallback.
Agent activity
38 hits · last 30 days
node
34
Resources
get-sitemap-links — npm install get-sitemap-links · libregistry