API

OneNav API使用说明。

Token生成

通过API创建、修改、删除分类/链接时必须传递token参数,下面介绍如何拼接计算token

0.9.19及之后的版本

在OneNav后台 - 系统设置 - API,查看用户名并点击生成SecretKey

然后点击页面上的“计算Token”,并将计算后的Token结果复制使用。

0.9.18及之前的版本

首先找到config.php中,USERTOKEN两个参数,比如:

//用户名
define('USER','xiaoz');
//token参数,API需要使用
define('TOKEN','xiaoz.me');

计算方法为:USER + TOKEN,再进行md5加密,上面的示例PHP代码为:

md5('xiaozxiaoz.me');

创建分类目录

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
name 测试分类 string 分类名称
fid 0 int 父级分类ID,如果为0则代表是顶级分类
font_icon fa fa-bookmark-o string CSS字体图标
weight 0 int(1) 分类权重,取值0-99
property 0 int(1) 是否私有,0:公开(默认),1:私有
description string 分类描述

请求成功响应

{
	"code": 0,
	"id": 21
}

请求失败响应

{
	"code": -1000,
	"err_msg": "Categorie already exist!"
}

修改分类目录

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
id 21 int 分类ID
name 测试分类 string 分类名称
fid 0 int 父级分类ID,如果为0则代表是顶级分类
font_icon fa fa-bookmark-o string CSS字体图标
weight 0 int(1) 分类权重,取值0-99
property 0 int(1) 是否私有,0:公开(默认),1:私有
description string 分类描述

请求成功响应

{
	"code": 0,
	"msg": "successful"
}

请求失败响应

{
	"code": -1000,
	"err_msg": "Categorie already exist!"
}

删除分类目录

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
id 21 int 分类ID

请求成功响应

{
	"code": 0,
	"msg": "successful"
}

请求失败响应

{
	"code": -1007,
	"err_msg": "The category delete failed!"
}

查询分类目录列表

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成

请求成功响应

{
	"code": 0,
	"msg": "",
	"count": 6,
	"data": [
		{
			"0": "8",
			"1": "<i class=\"fa fa-external-link\"></i> 常用链接",
			"2": "1607747674",
			"3": "1607865180",
			"4": "99",
			"5": "0",
			"6": "",
			"id": "8",
			"name": "<i class=\"fa fa-external-link\"></i> 常用链接",
			"add_time": "1607747674",
			"up_time": "1607865180",
			"weight": "99",
			"property": "0",
			"description": ""
		},
		{
			"0": "19",
			"1": "<i class=\"fa fa-html5\"></i> 站长工具",
			"2": "1607866471",
			"3": "",
			"4": "80",
			"5": "0",
			"6": "",
			"id": "19",
			"name": "<i class=\"fa fa-html5\"></i> 站长工具",
			"add_time": "1607866471",
			"up_time": "",
			"weight": "80",
			"property": "0",
			"description": ""
		},
		{
			"0": "3",
			"1": "<i class=\"fa fa-linux\"></i> 运维工具",
			"2": "1607699882",
			"3": "1607865657",
			"4": "80",
			"5": "0",
			"6": "",
			"id": "3",
			"name": "<i class=\"fa fa-linux\"></i> 运维工具",
			"add_time": "1607699882",
			"up_time": "1607865657",
			"weight": "80",
			"property": "0",
			"description": ""
		},
		{
			"0": "18",
			"1": "<i class=\"fa fa-video-camera\"></i> 视频影音",
			"2": "1607865982",
			"3": "1607866160",
			"4": "10",
			"5": "0",
			"6": "",
			"id": "18",
			"name": "<i class=\"fa fa-video-camera\"></i> 视频影音",
			"add_time": "1607865982",
			"up_time": "1607866160",
			"weight": "10",
			"property": "0",
			"description": ""
		},
		{
			"0": "4",
			"1": "<i class=\"fa fa-female\"></i> 18+",
			"2": "1607699983",
			"3": "1608046903",
			"4": "0",
			"5": "0",
			"6": "",
			"id": "4",
			"name": "<i class=\"fa fa-female\"></i> 18+",
			"add_time": "1607699983",
			"up_time": "1608046903",
			"weight": "0",
			"property": "0",
			"description": ""
		}
	]
}

请求失败响应

{
	"code": -1000,
	"err_msg": "Categorie already exist!"
}

查询单个链接信息

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
id 1 int 链接ID
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成

请求成功响应

{
	"code": 0,
	"data": {
		"id": "2",
		"fid": "19",
		"title": "安装文档",
		"url": "https://www.yuque.com/helloz/onenav/install",
		"description": "OneNav安装文档。",
		"add_time": "1608042226",
		"up_time": "1608042440",
		"weight": "0",
		"property": "0",
		"click": "1"
	}
}

请求失败响应

{
	"code": -1002,
	"err_msg": "Authorization failure!"
}

添加链接

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
url https://www.xiaoz.me string(256) 链接地址,需以http://或https://开头
title 小z博客 string 链接标题
fid 1 int 分类ID
weight 0 int(1) 分类权重,取值0-99
property 0 int(1) 是否私有,0:公开(默认),1:私有
description string 分类描述

请求成功响应

{
	"code": 0,
	"id": "35"
}

请求失败响应

{
	"code": -1011,
	"err_msg": "The URL already exists!"
}

修改链接

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
id 35 int 链接ID
url https://www.xiaoz.me string(256) 链接地址,需以http://或https://开头
title 小z博客 string 链接标题
fid 1 int 分类ID
weight 0 int(1) 分类权重,取值0-99
property 0 int(1) 是否私有,0:公开(默认),1:私有
description string 分类描述

请求成功响应

{
	"code": 0,
	"msg": "successful"
}

请求失败响应

{
	"code": -1008,
	"err_msg": "The title cannot be empty!"
}

删除链接

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
id 21 int 链接ID

请求成功响应

{
	"code": 0,
	"msg": "successful"
}

请求失败响应

{
	"code": -1010,
	"err_msg": "link id not exists!"
}

查询链接列表

接口说明

请求参数

参数名称 请求方法 示例值 类型 是否必须 说明
token POST 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
page GET 1 int 当前页码
limit GET 10 int 每页显示条数

请求成功响应

{
	"code": 0,
	"msg": "",
	"count": 30,
	"data": [
		{
			"0": "34",
			"1": "20",
			"2": "transmission",
			"3": "http://192.168.50.6:32769/transmission/web/",
			"4": "transmission",
			"5": "1608299921",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "0",
			"10": "<i class=\"fa fa-wifi\"></i> LAN",
			"id": "34",
			"fid": "20",
			"title": "transmission",
			"url": "http://192.168.50.6:32769/transmission/web/",
			"description": "transmission",
			"add_time": "1608299921",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "0",
			"category_name": "<i class=\"fa fa-wifi\"></i> LAN"
		},
		{
			"0": "32",
			"1": "19",
			"2": "顶级域名注册商",
			"3": "https://www.icann.org/registrar-reports/accreditation-qualified-list.html",
			"4": "icann认证顶级域名注册商列表。",
			"5": "1608126988",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "1",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "32",
			"fid": "19",
			"title": "顶级域名注册商",
			"url": "https://www.icann.org/registrar-reports/accreditation-qualified-list.html",
			"description": "icann认证顶级域名注册商列表。",
			"add_time": "1608126988",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "1",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		},
		{
			"0": "31",
			"1": "3",
			"2": "CSR文件生成工具",
			"3": "https://www.chinassl.net/ssltools/generator-csr.html",
			"4": "免费CSR生成工具,生成CSR工具,在线CSR生产工具,生成ECC CSR工具,ECC证书CSR生成工具,ECC CSR文件生成,Certificate Signing Request Generator tools",
			"5": "1608105958",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "0",
			"10": "<i class=\"fa fa-linux\"></i> 运维工具",
			"id": "31",
			"fid": "3",
			"title": "CSR文件生成工具",
			"url": "https://www.chinassl.net/ssltools/generator-csr.html",
			"description": "免费CSR生成工具,生成CSR工具,在线CSR生产工具,生成ECC CSR工具,ECC证书CSR生成工具,ECC CSR文件生成,Certificate Signing Request Generator tools",
			"add_time": "1608105958",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "0",
			"category_name": "<i class=\"fa fa-linux\"></i> 运维工具"
		},
		{
			"0": "30",
			"1": "4",
			"2": "嘿嘿,不给你看。",
			"3": "https://www.yuque.com/helloz/onenav",
			"4": "此分类是私有链接,你看不到哦。",
			"5": "1608046983",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "20",
			"10": "<i class=\"fa fa-female\"></i> 18+",
			"id": "30",
			"fid": "4",
			"title": "嘿嘿,不给你看。",
			"url": "https://www.yuque.com/helloz/onenav",
			"description": "此分类是私有链接,你看不到哦。",
			"add_time": "1608046983",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "20",
			"category_name": "<i class=\"fa fa-female\"></i> 18+"
		},
		{
			"0": "29",
			"1": "19",
			"2": "在线图片转icon格式",
			"3": "https://app.xunjiepdf.com/img2icon",
			"4": "迅捷在线图片格式转换软件免费版为您免费提供在线图片格式转换,图片转icon,图片转换成icon等免费图片格式转换服务!",
			"5": "1607869485",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "1",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "29",
			"fid": "19",
			"title": "在线图片转icon格式",
			"url": "https://app.xunjiepdf.com/img2icon",
			"description": "迅捷在线图片格式转换软件免费版为您免费提供在线图片格式转换,图片转icon,图片转换成icon等免费图片格式转换服务!",
			"add_time": "1607869485",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "1",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		},
		{
			"0": "28",
			"1": "19",
			"2": "在线扒站高级版",
			"3": "https://ishow.fun/",
			"4": "动态网页扒站,免费仿站,扒站工具高级版,在线扒站高级版,手机扒站,在线扒站工具,扒站软件,扒网站工具高级版,仿站工具,网站下载器,单页扒站小工具",
			"5": "1607869040",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "6",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "28",
			"fid": "19",
			"title": "在线扒站高级版",
			"url": "https://ishow.fun/",
			"description": "动态网页扒站,免费仿站,扒站工具高级版,在线扒站高级版,手机扒站,在线扒站工具,扒站软件,扒网站工具高级版,仿站工具,网站下载器,单页扒站小工具",
			"add_time": "1607869040",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "6",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		},
		{
			"0": "27",
			"1": "19",
			"2": "NameBeta",
			"3": "https://namebeta.com/",
			"4": "域名比价工具。",
			"5": "1607868954",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "5",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "27",
			"fid": "19",
			"title": "NameBeta",
			"url": "https://namebeta.com/",
			"description": "域名比价工具。",
			"add_time": "1607868954",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "5",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		},
		{
			"0": "26",
			"1": "19",
			"2": "哪煮米",
			"3": "https://www.nazhumi.com/",
			"4": "哪煮米是一家专业的域名比价平台,提供超过1500种域名后缀,超过50家全球域名注册商的在线比价,一键选到你满意的注册商",
			"5": "1607868904",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "6",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "26",
			"fid": "19",
			"title": "哪煮米",
			"url": "https://www.nazhumi.com/",
			"description": "哪煮米是一家专业的域名比价平台,提供超过1500种域名后缀,超过50家全球域名注册商的在线比价,一键选到你满意的注册商",
			"add_time": "1607868904",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "6",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		},
		{
			"0": "25",
			"1": "19",
			"2": "Domain Availability and Price",
			"3": "https://www.domcomp.com/",
			"4": "Considering to register, renew or transfer a domain? Check domain name availability and compare domain prices for 714 extensions across 38 providers with Domcomp. You can find cheap domains to buy or get the cheapest price for your desired URL name with up-to-date coupon. Lookup and compare now!",
			"5": "1607868880",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "3",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "25",
			"fid": "19",
			"title": "Domain Availability and Price",
			"url": "https://www.domcomp.com/",
			"description": "Considering to register, renew or transfer a domain? Check domain name availability and compare domain prices for 714 extensions across 38 providers with Domcomp. You can find cheap domains to buy or get the cheapest price for your desired URL name with up-to-date coupon. Lookup and compare now!",
			"add_time": "1607868880",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "3",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		},
		{
			"0": "24",
			"1": "19",
			"2": "钻磊二级域名分发",
			"3": "https://dns.txizd.cn/",
			"4": "钻磊二级域名分发(dns.txizd.cn)成立于2019-3-2,是一家专门提供二级域名解析分发的平台,域名均免费提供使用,不收取任何费用,提供的域名当中有已备案域名和未备案域名,域名后缀多可自主选择解析,欢迎大家来钻磊域名解析网使用。",
			"5": "1607868853",
			"6": null,
			"7": "0",
			"8": "0",
			"9": "8",
			"10": "<i class=\"fa fa-html5\"></i> 站长工具",
			"id": "24",
			"fid": "19",
			"title": "钻磊二级域名分发",
			"url": "https://dns.txizd.cn/",
			"description": "钻磊二级域名分发(dns.txizd.cn)成立于2019-3-2,是一家专门提供二级域名解析分发的平台,域名均免费提供使用,不收取任何费用,提供的域名当中有已备案域名和未备案域名,域名后缀多可自主选择解析,欢迎大家来钻磊域名解析网使用。",
			"add_time": "1607868853",
			"up_time": null,
			"weight": "0",
			"property": "0",
			"click": "8",
			"category_name": "<i class=\"fa fa-html5\"></i> 站长工具"
		}
	]
}

请求失败响应

{
	"code": -1000,
	"err_msg": "Authorization failure!"
}

错误码对照表

所有API请求错误码可参考如下表格进行对照,如有疑问,请反馈。此对照表已经废弃,默认情况下0200代表成功,其余状态码一律为失败。

code err_msg 描述
-1000 Categorie already exist! 分类目录已存在
-1002 Authorization failure! token认证失败
-1003 The category ID cannot be empty! 分类目录ID不能为空
-1004 The category name cannot be empty! 分类目录名不能为空
-1005 The category name already exists! 分类目录名已存在
-1006 The category is not empty and cannot be deleted! 分类目录不为空,无法删除
-1007 The category delete failed! 分类目录删除失败
-1008 The title cannot be empty! 链接标题不能为空
-1009 URL cannot be empty! URL不能为空
-1010 URL is not valid! URL链接不合法
-1011 The URL already exists! URL链接已经存在
-1012 link id not exists! 链接ID不存在

获取单个分类目录信息

接口说明

请求参数

参数名称 示例值 类型 是否必须 说明
id 1 int 分类ID
token 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成

请求成功响应

{
	"code": 0,
	"data": {
		"id": "22",
		"name": "你好啊",
		"add_time": "1646715733",
		"up_time": "",
		"weight": "0",
		"property": "1",
		"description": "第三代",
		"font_icon": "fa fa-linux"
	}
}

请求失败响应

{
	"code": -1002,
	"err_msg": "Authorization failure!"
}

获取当前主题自定义参数

接口说明

返回参数说明

{
    "code": 200,
    "data": {
        "full_width_mode": "on",
        "link_description": "hide",
        "favicon": "online"
    },
    "msg": ""
}

查询用户是否登录

返回值

{
    "code": 200,
    "data": "true",
    "msg": ""
}

如果失败,返回:

{
    "code": -1002,
    "err_msg": "Authorization failure!"
}

查询指定分类下的链接列表

接口说明

请求参数

参数名称 请求方法 示例值 类型 是否必须 说明
token POST 5c7d0c90cf9e0ce560956179e8e82e7d string(32) 请参考token生成
category_id GET 1 int 分类ID
page GET 1 int 当前页码
limit GET 10 int 每页显示条数

请求成功响应

{
    "code": 0,
    "msg": "",
    "count": 2,
    "data": [
        {
            "id": "20",
            "0": "20",
            "fid": "19",
            "1": "19",
            "title": "百度一下,你就知道",
            "2": "百度一下,你就知道",
            "url": "https:\/\/www.baidu.com\/index.php?tn=22073068_2_dg",
            "3": "https:\/\/www.baidu.com\/index.php?tn=22073068_2_dg",
            "description": "",
            "4": "",
            "add_time": "1650551209",
            "5": "1650551209",
            "up_time": null,
            "6": null,
            "weight": "0",
            "7": "0",
            "property": "0",
            "8": "0",
            "click": "2",
            "9": "2",
            "topping": "0",
            "10": "0",
            "url_standby": null,
            "11": null,
            "category_name": "默认分类",
            "12": "默认分类"
        },
        {
            "id": "19",
            "0": "19",
            "fid": "19",
            "1": "19",
            "title": "你好",
            "2": "你好",
            "url": "magnet:?xt=urn:btih:d212b7968eacb056301410bb6473436e51f2e395",
            "3": "magnet:?xt=urn:btih:d212b7968eacb056301410bb6473436e51f2e395",
            "description": "",
            "4": "",
            "add_time": "1650275033",
            "5": "1650275033",
            "up_time": null,
            "6": null,
            "weight": "0",
            "7": "0",
            "property": "0",
            "8": "0",
            "click": "0",
            "9": "0",
            "topping": "0",
            "10": "0",
            "url_standby": "",
            "11": "",
            "category_name": "默认分类",
            "12": "默认分类"
        }   
    ]
}

请求失败响应

{
	"code": -1000,
	"err_msg": "Authorization failure!"
}