A framework-agnostic fully typed JavaScript client for the ModDex API, the Minecraft mod and modpack review platform.
📚 Docs • 🚀 Getting Started • 📖 API Reference • 📝 Changelog
npm install moddex-js
pnpm add moddex-js
yarn add moddex-js
bun add moddex-jsimport ModDexClient from 'moddex-js';
const client = new ModDexClient({
client: 'my-app/1.0.0',
});
const { data: project } = await client.lookup.get('modrinth', 'sodium');
const { data: reviews } = await client.projects.listReviews(project.id);
console.log(project.rating);
console.log(reviews);const client = new ModDexClient({
client: 'my-app/1.0.0',
token: 'your-api-token',
baseUrl: 'https://moddex.gg',
timeoutMs: 10_000,
cache: { ttlMs: 60_000 },
});interface ModDexClientOptions {
token?: string;
client?: string; // sent as the X-Client header
baseUrl?: string; // default: "https://moddex.gg"
timeoutMs?: number; // default: 10000
userAgent?: string;
fetch?: typeof globalThis.fetch;
cache?: boolean | CacheOptions; // default: false
}Lookup:
client.lookup.get(platform, value, options?)client.lookup.find(options)client.lookup.listReviews(platform, value, options?)client.lookup.batch(options)client.lookup.file(options)client.lookup.fileBatch(options)
Projects:
client.projects.list(options?)client.projects.get(id, options?)client.projects.listReviews(id, options?)client.projects.listFiles(id, options?)client.projects.listDependencies(id, options?)client.projects.listDependents(id, options?)client.projects.listContents(id, options?)client.projects.listSimilar(id, options?)client.projects.getCommunityTags(id)
Reviews:
client.reviews.list(options?)client.reviews.get(id, options?)
Catalog:
client.catalog.getFilters()client.catalog.listMinecraftVersions(options?)client.catalog.listLoaders()client.catalog.listTags(options?)
Sync:
client.sync.listProjects(options?)client.sync.listReviews(options?)client.sync.listReviewIds()
User:
client.user.get()
Every list method also has an iterate* helper that walks every page.
The ModDex API is public, so a token is optional. It only raises your rate limits. Create one on moddex.gg under Settings > API Tokens. It is sent as Authorization: Bearer <token> on every request.
const client = new ModDexClient({
token: 'your-api-token',
});You can inject your own fetch implementation.
import ModDexClient from 'moddex-js';
import fetch from 'node-fetch';
const client = new ModDexClient({
fetch,
});All request, timeout, and API errors are thrown as ModDexError or one of its subclasses, such as ModDexNotFoundError or ModDexRateLimitError.
import ModDexClient, { ModDexError } from 'moddex-js';
const client = new ModDexClient();
try {
await client.lookup.get('modrinth', 'sodium');
} catch (error) {
if (error instanceof ModDexError) {
console.error(error.status);
console.error(error.code);
console.error(error.message);
}
}pnpm build
pnpm testContributions are always welcome!
Please ensure you run pnpm lint:fix before opening a pull request.
MIT