JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 99
  • Score
    100M100P100Q88649F
  • License MIT

Provide the modrinth described in https://github.com/modrinth/labrinth/wiki/API-Documentation

Package Exports

  • @xmcl/modrinth
  • @xmcl/modrinth/dist/index.esm.js
  • @xmcl/modrinth/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@xmcl/modrinth) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Modrinth API

npm version Downloads Install size npm Build Status

Provide the modrinth described in https://github.com/modrinth/labrinth/wiki/API-Documentation

Currently only the read mod related APIs are implemented.

Usage

Search Mod in Modrinth

You can use keyword to search

    import { searchMods } from '@xmcl/modrinth'
    const searchOptions: SearchOptions = {
        categoryId: 6, // 6 is mod,
    };
    const result: SearchModResult = await searchMods(settingString);
    const totalModsCounts = result.total_hits;
    for (const mod of result.hits) {
        console.log(`${mod.mod_id} ${mod.title} ${mod.description}`); // print mod info
    }

Get Mod in Modrinth

You can get mod detail info via mod id, including the download url

import { getMod, Mod, getModVersion, ModVersionFile, ModVersion } from '@xmcl/modrinth'

const modid: string; // you can get this id from searchMods
const mod: Mod = await getMod(modid) // mod details
const modVersions: string[] = mod.versions;
const oneModVersion: string = modVersions[0];

const modVersion: ModVersion = await getModVersion(oneModVersion);

const files: ModVersionFile[] = modVersion.files;

const { url, name, hashes } = files[0]; // now you can get file name, file hashes and download url of the file