API 概述

API 文档

Music Getter 提供完整的 Node.js 编程接口,你可以在项目中将其作为库使用。

导出模块

import { 
class Meting
Meting
,
const download: DownloadManager
download
} from 'music-getter';
import type { Music, MusicResponse, SearchOptions } from 'music-getter';

核心模块

  • Meting API — 音乐资源获取客户端,支持搜索、获取歌曲/歌单/歌词/封面等
  • Download API — 下载管理器,支持队列下载和进度显示

类型定义

快速示例

import { 
class Meting
Meting
,
const download: DownloadManager
download
} from 'music-getter';
const
const meting: Meting
meting
= new
new Meting(server?: string): Meting
Meting
('netease');
const meting: Meting
meting
.
Meting.format(enable: boolean): Meting
format
(true);
// 搜索歌曲 const
const results: any
results
=
var JSON: JSON

An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.

JSON
.
JSON.parse(text: string, reviver?: (this: any, key: string, value: any) => any): any

Converts a JavaScript Object Notation (JSON) string into an object.

@paramtext A valid JSON string.@paramreviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.@throws{SyntaxError} If text is not valid JSON.
parse
(await
const meting: Meting
meting
.
Meting.search(keyword: string, options?: SearchOptions): Promise<string>
search
('Daylight', {
SearchOptions.limit?: number | undefined
limit
: 5 }));
// 下载第一首
const download: DownloadManager
download
.
DownloadManager.add(url: string | (() => Promise<string>), output: string): void
add
(
const results: any
results
[0].url_id, './Daylight.mp3');
await
const download: DownloadManager
download
.
DownloadManager.startAll(): Promise<void>
startAll
();

Meting API

Download API