网易云音乐
ALAPI 官方文档
搜索获取网易云音乐数据
基本说明:
接口地址:https://v2.alapi.cn/api/music/search
返回格式:json
请求方式:get/post
请求示例:https://v2.alapi.cn/api/music/search?keyword=我爱你&token=token
请求参数说明:
名称 类型 必填 说明
token string 必填 请求token 扫码关注公众号
keyword string 必填 要查询的歌曲名
limit int 选填 返回数量
offset int 选填 偏移数量,用于分页
type int 选填 搜索类型 默认为 1 即单曲
返回参数说明:
名称 类型 说明
- - -
JSON返回示例:
{
	"code": 200,
	"msg": "success",
	"data": {
		"songs": [{
			"id": 458231315,
			"name": "我愛你",
			"artists": [{
				"id": 1193188,
				"name": "Ayasa绚沙",
				"picUrl": null,
				"alias": [],
				"albumSize": 0,
				"picId": 0,
				"img1v1Url": "https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
				"img1v1": 0,
				"trans": null
			}],
			"album": {
				"id": 35157350,
				"name": "BEST I",
				"artist": {
					"id": 0,
					"name": "",
					"picUrl": null,
					"alias": [],
					"albumSize": 0,
					"picId": 0,
					"img1v1Url": "https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
					"img1v1": 0,
					"trans": null
				},
				"publishTime": 1485273600000,
				"size": 16,
				"copyrightId": -1,
				"status": 0,
				"picId": 109951163984548450,
				"mark": 0
			},
			"duration": 230826,
			"copyrightId": 739012,
			"status": 0,
			"alias": [],
			"rtype": 0,
			"ftype": 0,
			"mvid": 0,
			"fee": 1,
			"rUrl": null,
			"mark": 139264
		}],
		"songCount": 600
	},
	"Author": {
		"name": "Alone88",
		"desc": "由Alone88提供的免费API 服务,官方文档:www.alapi.cn"
	}
}
服务级错误码参照
错误码 说明
500 处理异常
完整教学代码示例
<?php

/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2020/02/01 00:16
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://v1.alapi.cn/api/music/search?keyword=我爱你';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://v1.alapi.cn/api/music/search"
)

func main() {
	queryUrl := fmt.Sprintf("%s?keyword=我爱你",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}