0.参考文章

网易云音乐的常用API

1.热门歌曲

GET:https://music.163.com/discover/toplist

发起请求以获取html,其中有歌名和id

2.搜索歌曲

POST:http://music.163.com/api/search/pc

参数名数据示例说明
s大逆转裁判搜索的关键字
offset0偏移量
limit1每次获取数
type1类型(歌曲:1、专辑:10、歌手:100、歌单:1000、用户:1002、mv:1004)

搜索歌曲的同时,其id、作者信息(artists)、专辑信息(album)全都有。

该接口调用时,必须携带Cookie才能完成访问。在第一次访问时,获取响应头中的Set-Cookie,随后将Cookie保存起来,之后的每一次访问都需要携带Cookie。

以实例的参数,获取的json如下:

{
    "result": {
        "songs": [
            {
                "name": "追求 ~大逆転のとき",
                "id": 33316488,
                "position": 61,
                "alias": [],
                "status": -1,
                "fee": 0,
                "copyrightId": 663018,
                "disc": "2",
                "no": 27,
                "artists": [
                    {
                        "name": "北川保昌",
                        "id": 11989036,
                        "picId": 0,
                        "img1v1Id": 0,
                        "briefDesc": "",
                        "picUrl": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
                        "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
                        "albumSize": 0,
                        "alias": [],
                        "trans": "",
                        "musicSize": 0
                    }
                ],
                "album": {
                    "name": "大逆転裁判 -成歩堂龍ノ介の冒險- 劇伴音楽大全集",
                    "id": 3190532,
                    "type": "专辑",
                    "size": 67,
                    "picId": 109951164502968621,
                    "blurPicUrl": "http://p1.music.126.net/1f3b1jvmrZcrSmznKnK5OQ==/109951164502968621.jpg",
                    "companyId": 0,
                    "pic": 109951164502968621,
                    "picUrl": "http://p1.music.126.net/1f3b1jvmrZcrSmznKnK5OQ==/109951164502968621.jpg",
                    "publishTime": 1436889600000,
                    "description": "",
                    "tags": "",
                    "company": "セルピュータ",
                    "briefDesc": "",
                    "artist": {
                        "name": "",
                        "id": 0,
                        "picId": 0,
                        "img1v1Id": 0,
                        "briefDesc": "",
                        "picUrl": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
                        "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
                        "albumSize": 0,
                        "alias": [],
                        "trans": "",
                        "musicSize": 0
                    },
                    "songs": [],
                    "alias": [
                        "3DS游戏《大逆转裁判 成步堂龙之介的冒险》背景音乐大全集"
                    ],
                    "status": 0,
                    "copyrightId": -1,
                    "commentThreadId": "R_AL_3_3190532",
                    "artists": [
                        {
                            "name": "Capcom Sound Team",
                            "id": 15261873,
                            "picId": 0,
                            "img1v1Id": 0,
                            "briefDesc": "",
                            "picUrl": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
                            "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
                            "albumSize": 0,
                            "alias": [],
                            "trans": "",
                            "musicSize": 0
                        }
                    ],
                    "picId_str": "109951164502968621"
                },
                "starred": false,
                "popularity": 80.0,
                "score": 80,
                "starredNum": 0,
                "duration": 191000,
                "playedNum": 0,
                "dayPlays": 0,
                "hearTime": 0,
                "ringtone": null,
                "crbt": null,
                "audition": null,
                "copyFrom": "",
                "commentThreadId": "R_SO_4_33316488",
                "rtUrl": null,
                "ftype": 0,
                "rtUrls": [],
                "copyright": 2,
                "mvid": 0,
                "bMusic": {
                    "name": null,
                    "id": 98372534,
                    "size": 3071625,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 128000,
                    "playTime": 191000,
                    "volumeDelta": -2.0
                },
                "mp3Url": "http://m2.music.126.net/hmZoNQaqzZALvVp0rE7faA==/0.mp3",
                "hMusic": {
                    "name": null,
                    "id": 98372532,
                    "size": 7678998,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 320000,
                    "playTime": 191000,
                    "volumeDelta": 0.0
                },
                "mMusic": {
                    "name": null,
                    "id": 98372533,
                    "size": 4607416,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 192000,
                    "playTime": 191000,
                    "volumeDelta": -2.0
                },
                "lMusic": {
                    "name": null,
                    "id": 98372534,
                    "size": 3071625,
                    "extension": "mp3",
                    "sr": 44100,
                    "dfsId": 0,
                    "bitrate": 128000,
                    "playTime": 191000,
                    "volumeDelta": -2.0
                },
                "rtype": 0,
                "rurl": null
            }
        ],
        "songCount": 131
    },
    "code": 200
}

3.根据id播放歌曲

GET:http://music.163.com/api/song/enhance/player/url

参数名数据示例说明
id1891469546歌曲id
ids[1891469546][歌曲id]
br3200000歌曲码率,可选值有64000,128000,198000,320000

音乐链接就在url中

{
    "data": [
        {
            "id": 1891469546,
            "url": "http://m801.music.126.net/20211108174014/6b94ab904908b72fb81b62c98e5a3447/jdymusic/obj/wo3DlMOGwrbDjj7DisKw/11469316999/ffab/9a09/92ff/b01c9b0aae5a4aba0c9cc5f306a8ec5d.mp3",
            "br": 128000,
            "size": 3280187,
            "md5": "b01c9b0aae5a4aba0c9cc5f306a8ec5d",
            "code": 200,
            "expi": 1200,
            "type": "mp3",
            "gain": 0.0,
            "fee": 8,
            "uf": null,
            "payed": 0,
            "flag": 4,
            "canExtend": false,
            "freeTrialInfo": null,
            "level": "standard",
            "encodeType": "mp3",
            "freeTrialPrivilege": {
                "resConsumable": false,
                "userConsumable": false
            },
            "freeTimeTrialPrivilege": {
                "resConsumable": false,
                "userConsumable": false,
                "type": 0,
                "remainTime": 0
            },
            "urlSource": 0
        }
    ],
    "code": 200
}

4.歌词

GET:http://music.163.com/api/song/media

参数名数据示例说明
id1840459406歌曲id
{
    "songStatus": 1,
    "lyricVersion": 5,
    "lyric": "\n\n[00:00.638]Super Idol的笑容\n[00:02.043]都没你的甜\n[00:03.907]八月正午的阳光\n[00:05.863]都没你耀眼\n[00:07.539]热爱 105 °C的你\n[00:10.062]滴滴清纯的蒸馏水\n[00:15.396]你不知道你有多可爱\n[00:17.971]跌倒后会傻笑着再站起来\n[00:22.284]你从来都不轻言失败\n[00:25.255]对梦想的执着一直不曾更改\n[00:29.108]很安心 当你对我说\n[00:32.206]不怕有我在\n[00:33.817]放着让我来\n[00:36.151]勇敢追自己的梦想\n[00:38.874]那坚定的模样\n[00:42.174]Super Idol的笑容\n[00:44.258]都没你的甜\n[00:45.965]八月正午的阳光\n[00:47.774]都没你耀眼\n[00:49.519]热爱 105 °C的你\n[00:51.978]滴滴清纯的蒸馏水\n[00:56.389]在这独一无二\n[00:58.085]属于我的时代\n[00:59.975]不怕失败来一场\n[01:02.121]痛快的热爱\n[01:03.930]热爱 105°C的你\n[01:06.114]滴滴清纯的蒸馏水\n[01:10.263]在这独一无二\n[01:11.741]属于我的时代\n[01:13.903]莫忘了初心常在\n[01:15.577]痛快去热爱\n[01:17.341]热爱 105°C的你\n[01:20.242]滴滴清纯的蒸馏水\n[01:22.691]喝一口又活力全开\n[01:29.605]再次回到最佳状态\n[01:36.940]喝一口哟\n[01:40.068]你不知道你有多可爱\n[01:42.532]跌倒后会傻笑着再站起来\n[01:46.544]你从来都不轻言失败\n[01:49.225]对梦想的执着一直不曾更改\n[01:53.112]很安心 当你对我说\n[01:56.018]不怕有我在\n[01:58.171]放着让我来\n[02:00.385]勇敢追自己的梦想\n[02:03.170]那坚定的模样\n[02:06.389]Super Idol的笑容\n[02:08.470]都没你的甜\n[02:10.186]八月正午的阳光\n[02:11.914]都没你耀眼\n[02:13.626]热爱 105°C的你\n[02:16.333]滴滴清纯的蒸馏水\n[02:20.601]在这独一无二\n[02:21.909]属于我的时代\n[02:24.228]不怕失败来一场\n[02:25.971]痛快的热爱\n[02:27.624]热爱 105°C的你\n[02:30.178]滴滴清纯的蒸馏水\n[02:34.443]在这独一无二\n[02:35.932]属于我的时代\n[02:38.027]莫忘了初心常在\n[02:39.755]痛快去热爱\n[02:41.584]热爱 105°C的你\n[02:44.158]滴滴清纯的蒸馏水\n[02:46.864]喝一口又活力全开\n[02:53.729]再次回到最佳状态\n[03:00.945]喝一口又活力全开\n",
    "code": 200
}

5.特别声明

本文仅供学习交流使用,请勿用作任何商业用途!

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐