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"
}
}