@hansogj/discogs-item-lookup
v1.2.0
Published
A CLI and library to look up item details from the Discogs API.
Downloads
13
Maintainers
Readme
Discogs Item Lookup
A CLI and library to look up information about a specific music release from the Discogs API.
Features
- Artist Name: Get the primary artist(s) for the release.
- Item Title: Find the album or single name.
- Tracklist: View the complete tracklist for the specific release version.
- Release Years: See both the year for this specific release and the year of the original master release.
- Direct Link: A convenient link to view the release directly on the Discogs website.
Installation
npm install -g @hansogj/discogs-item-lookupCLI Usage
After installation, you can use the discogs-lookup command.
discogs-lookup <release-id> [options]Arguments:
<release-id>: The numeric ID of the Discogs release (e.g.,249504).
Options:
-t, --token <token>: Discogs personal access token. This overrides theDISCOGS_TOKENenvironment variable.-h, --help: display help for command.-V, --version: output the version number.
Example:
discogs-lookup 249504This will output the release information for Daft Punk's "One More Time".
Library Usage
You can also use this package as a library in your own Node.js projects.
import { lookupRelease, DiscogsApiError } from '@hansogj/discogs-item-lookup';
async function getReleaseInfo() {
try {
const data = await lookupRelease({
releaseId: '249504',
// token: 'your-discogs-token', // optional, will use env if not provided
// disc: 2, // optional, to get only a specific disc
});
console.log(data);
} catch (error) {
if (error instanceof DiscogsApiError) {
console.error(`API Error: ${error.message}`);
} else {
console.error('An unexpected error occurred:', error);
}
}
}
getReleaseInfo();Configuration
This tool requires a Discogs Personal Access Token to communicate with the Discogs API. The token can be provided in one of two ways:
- Environment Variable (recommended): Create a
.envfile in your project root and addDISCOGS_TOKEN=your_token_here. - CLI Option: Use the
--tokenor-tflag when running the command.
Getting a Discogs Token
- Log in to your Discogs account.
- Go to your Developer Settings.
- Click "Generate new token".
- Use this token for the
DISCOGS_TOKENenvironment variable or the--tokenoption.
...
