返回首页

【音乐】咪咕音乐

浏览: 2416 最后更新: 2025-02-12 14:33:35

接口说明

咪咕VIP音乐

接口基本信息

API地址

https://api-v2.cenguigui.cn/api/mg_music/

请求方式

GET

返回格式

JSON

接口状态

正常启用

参数说明

以下参数为接口所需调用信息

参数 是否必填 类型 说明 示例
msg歌曲名字/歌手名字
n选择对应歌曲序号,为空则返回列表
type返回格式,可填text,默认json
br1=默认最高音质,2=HQ高品质MP3

请求示例

HTTP请求

https://api-v2.cenguigui.cn/api/mg_music/?msg=周杰伦&n=1&type=json

调用示例

代码示例

返回结果

HTTP 200 OK
{
    "code": 200,
    "msg": "请求成功",
    "data": {
        "title": "最后的战役",
        "singer": "周杰伦",
        "cover": "https://d.musicapp.migu.cn/data/oss/resource/00/2h/7m/b2.webp",
        "lrc_url": "https://d.musicapp.migu.cn/data/oss/resource/00/2f/7a/en",
        "link": "https://music.migu.cn/v3/music/song/60054701920",
        "music_url": "http://freetyst.nf.migu.cn/public/product9th/product46/2023/08/1117/2009%E5%B9%B406%E6%9C%8826%E6%97%A5%E5%8D%9A%E5%B0%94%E6%99%AE%E6%96%AF/%E6%A0%87%E6%B8%85%E9%AB%98%E6%B8%85/MP3_320_16_Stero/60054701920171436.mp3?channelid=02&msisdn=33db7bcb-673c-4cb2-8903-d9db62941103&Tim=1717328958153&Key=c475d77b99e85d10"
    }
}

调用示例

// JavaScript调用示例
fetch("https://api-v2.cenguigui.cn/api/mg_music/?msg=周杰伦&n=1&type=json", {
  method: "GET",
  headers: {
    "Content-Type": "application/json"
  }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));
# Python调用示例
import requests

url = "https://api-v2.cenguigui.cn/api/mg_music/?msg=周杰伦&n=1&type=json"

response = requests.get(url)

print(response.json())
// Java调用示例
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class ApiExample {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newBuilder()
                .version(HttpClient.Version.HTTP_2)
                .connectTimeout(Duration.ofSeconds(10))
                .build();
                
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://api-v2.cenguigui.cn/api/mg_music/?msg=周杰伦&n=1&type=json"))
                .build();
                
        client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
                .thenApply(HttpResponse::body)
                .thenAccept(System.out::println)
                .join();
    }
}
<?php
// PHP调用示例
$url = "https://api-v2.cenguigui.cn/api/mg_music/?msg=周杰伦&n=1&type=json";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);
?>
// C#调用示例
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        using var client = new HttpClient();
        var url = "https://api-v2.cenguigui.cn/api/mg_music/?msg=周杰伦&n=1&type=json";
        
        var response = await client.GetAsync(url);
        
        var result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}