NPM Fetch Meta Data
A very simple API to retrieve metadata about an NPM package. There are no helper functions to acquire individual parts of the metadata (example: versions..) rather, the entire JSON object is returned to the caller in order that the caller can do whatever it wishes.
Installation
npm install npm-fetch-meta-data
Usage
const getNPMMetaData = ;const options = packageName: PACKAGE_NAME // REQUIRED --> ex: axios registry: REGISTRY_NAME // OPTIONAL --> defaults to https://registry.npmjs.org/ ; const metaData = await ; // process metadata object// log some info about this package console;console;console;console;console;console;console;console;
To view the complete payload from the NPM registry query, try this... (this package, but you can use any package)
https://registry.npmjs.org/npm-fetch-meta-data
Just parse the data that is returned.
Error Handling
If a package is not found the AXIOS error object is returned... (Generally a 404)
Running the example
cd examplesnode index.js npm-fetch-meta-data
This will yield
Package author..............James YoungPackage author email........N/APackage author Url..........N/APackage name................npm-fetch-meta-dataPackage description.........Fetch metadata about any NPM packageNumber of versions..........1Last updated................2020-04-26T18:37:02.876ZHomepage....................https://github.com/jamesskyoung/npm-fetch-meta-data#readmeRepository type.............gitRepository url..............git+https://github.com/jamesskyoung/npm-fetch-meta-data.gitIntegrity...................sha512-DgjO6hbOdCo9pT9GGgFJ2jtwgGnJ2OmVaCC6ezi+liFVwOLmorXbH+Y5SZu7hjMlxoVuwiLMl+yc4mwRcYATBw==
Tests
npm test