JSPM

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

An implementation of modrinth API (https://docs.modrinth.com/api-spec)

Package Exports

  • @xmcl/modrinth
  • @xmcl/modrinth/dist/index.browser.mjs
  • @xmcl/modrinth/dist/index.js
  • @xmcl/modrinth/dist/index.mjs

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://docs.modrinth.com/api-spec

Usage

This package is depending on undici for HTTP in nodejs, and the browser version will use browser fetch instead of undici.

Search Project in Modrinth

You can use keyword to search

import { ModrinthV2Client, SearchResult } from '@xmcl/modrinth'
const client = new ModrinthV2Client()
const searchOptions: SearchOptions = {
    query: "shader", // searching shader
};
const result: SearchResult = await client.searchProjects(settingString);
const totalProjectCounts = result.total_hits;
for (const project of result.hits) {
    console.log(`${project.project_id} ${project.title} ${project.description}`); // print project info
}

Get Project in Modrinth

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

import { ModrinthV2Client, ProjectVersionFile, ProjectVersion } from '@xmcl/modrinth'

const client = new ModrinthV2Client()
const projectId: string; // you can get this id from searchProjects
const project: project = await client.getProject(projectId) // project details
const versions: string[] = project.versions;
const oneVersion: string = versions[0];

const modVersion: ModVersion = await getProjectVersion(oneVersion);

const files: ProjectVersionFile[] = modVersion.files;

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