easy-lanyard-wrapper
v0.1.0
Published
A small TypeScript wrapper for the Lanyard Discord presence API
Readme
Lanyard Wrapper
Lanyard Wrapper
Lanyard Wrapper is a compact TypeScript SDK for interacting with the Lanyard Discord presence API. It bundles a minimal HTTP client, an optional cache layer (in-memory by default), and a small ergonomic wrapper API that supports field projection and basic metrics.
Key features
- Lightweight HTTP client with optional
Authorizationheader support for API keys. - Adapter-based cache (in-memory LRU+TTL included). Cache adapters may expose runtime metrics.
- Field projection: callers can request only the nested fields they need using dot-notation paths.
- Simple factory API:
createDefaultClient()returns a ready-to-use client with cache and HTTP wired.
Quick status and runtime metrics
The library exposes cache metrics (when supported by the adapter) through the client API. Available metrics include:
hits— number of cache hitsmisses— number of cache missessets— number of cache writesdeletes— number of cache deletionsevictions— number of LRU evictionsentries— current number of entries in cache
Call client.getCacheStats() to retrieve these metrics (returns null if the adapter does not provide stats).
Quick start
Install dependencies and developer tooling:
npm install
npm install --save-dev ts-node typescript dotenv @types/nodeRun the basic example (PowerShell):
npm run exampleBasic usage (TypeScript)
import createDefaultClient from './src/api/client';
const client = createDefaultClient();
// full response
const full = await client.getUser('94490510688792576');
// request selected fields only
const partial = await client.getUser('94490510688792576', null, ['data.discord_user.username','data.spotify.track_id']);
// read cache metrics
const stats = await client.getCacheStats();Documentation and links
- Usage / Quick start: docs/usage.md
- Architecture: docs/architecture.md
- API reference: src/api/README.md
- Examples: examples/basic/README.md
- Contribution guide: CONTRIBUTING.md
Publishing and repository
This project is prepared for npm publishing. Before publishing, ensure you have built the project (npm run build), and that package.json contains the correct name, version, author, and repository fields.
License
This project is licensed under MIT. See the LICENSE file for details.
