pocketdb api
1.0.0
Pocketdb.js手工制作的REST API - Pocket Database包装器for telegra.ph
// GET https://pocketdb-api.vercel.app/get?token=my-token&key=users
{
"success" : true ,
"result" : {
"list" : [ "users" ] ,
"data" : [ {
"name" : "John Doe" ,
"age" : 24 ,
"email" : "[email protected]"
} ]
} ,
"request" : {
"endpoint" : "/get" ,
"token" : "my-token" ,
"key" : "users"
}
}pocketdb-api在 /web/index.html上提供在线用法

| 端点 | 方法 | 参数 |
|---|---|---|
/set | 邮政 | 钥匙, *令牌 |
/get | 得到 | 钥匙,令牌 |
* - 选修的
/set POST https://pocketdb-api.vercel.app/set?token=...&key=...
使用令牌使用/set时,它将使用请求主体中提供的JSON内容修改或创建与指定密钥关联的数据。
await fetch ( "https://pocketdb-api.vercel.app/set?token=...&key=users" , {
method : "post" ,
body : JSON . stringify ( {
name : "John Doe" ,
age : 24 ,
email : "[email protected]"
} )
} )输出看起来像这样:
{
"success" : true ,
"result" : {
"list" : [ "users" ]
} ,
"request" : {
"endpoint" : "/set" ,
"key" : "users" ,
"value" : {
"name" : "John Doe" ,
"age" : 24 ,
"email" : "[email protected]"
} ,
"token" : "..."
}
} /set无令牌 POST https://pocketdb-api.vercel.app/set?&key=...
使用/set无令牌时,它将使用请求主体中提供的JSON内容启动新的数据库并插入与提供密钥关联的数据。
await fetch ( "https://pocketdb-api.vercel.app/set?key=users" , {
method : "post" ,
body : JSON . stringify ( {
name : "John Doe" ,
age : 24 ,
email : "[email protected]"
} )
} )输出看起来像这样:
{
"success" : true ,
"result" : {
"list" : [ "users" ] ,
"token" : "..."
} ,
"request" : {
"endpoint" : "/set" ,
"key" : "users" ,
"value" : {
"name" : "John Doe" ,
"age" : 24 ,
"email" : "[email protected]"
}
}
} /get GET https://pocketdb-api.vercel.app/get?token=...&key=...
该端点检索与提供的密钥关联的数据内容,并以JSON格式返回。
await fetch ( "https://pocketdb-api.vercel.app/get?token=...&key=users" )输出看起来像这样:
{
"success" : true ,
"result" : {
"list" : [ "users" ] ,
"data" : {
"name" : "John Doe" ,
"age" : 24 ,
"email" : "[email protected]"
}
} ,
"request" : {
"endpoint" : "/get" ,
"key" : "users" ,
"token" : "..."
}
} | 端点 | 错误 | 信息 | 原因 |
|---|---|---|---|
/set | INCOMPLETE_PARAM | 不完整的参数。请查看文档https://github.com/creuserr/pocketdb-api/blob/main/main/readme.md#documentation,以获取更多信息。 | 需要参数key 。以及json的身体。 |
/set | INVALID_BODY | 身体未正确编码。请查看文档https://github.com/creuserr/pocketdb-api/blob/main/main/readme.md#documentation,以获取更多信息。 | 身体必须是有效的串起的JSON。弦是预期的 |
/set | INVALID_METHOD | 帖子是端点 /集合接受的唯一方法 | 端点/set仅接受POST方法。 |
/get | INCOMPLETE_PARAM | 不完整的参数。请查看文档https://github.com/creuserr/pocketdb-api/blob/main/main/readme.md#documentation,以获取更多信息。 | 需要参数key和token 。 |
/get | INVALID_METHOD | 获得是终点 /获取的唯一方法 | 端点/get仅接受GET方法。 |
/set或/get | INTERNAL_ERROR | 错误信息 | 此错误可能会因升高错误而异。可能的原因包括无效的JSON,连接失败,未找到数据库(不存在令牌)或未找到键。 |
// Example Error:
// POST https://pocketdb-api.vercel.app/get?token=...&key=...
{
"success" : false ,
"error" : "INVALID_METHOD" ,
"message" : "GET is the only method accepted for the endpoint /get" ,
"request" : {
"token" : "..." ,
"key" : "..." ,
"endpoint" : "/get"
}
}