其他

Pantry

Pantry 是一款为小型项目提供的免费JSON存储服务,允许开发者轻松存储和检索JSON数据,无需复杂设置即可快速上手。

查看官方文档 ↗

接入教程

1. 访问Pantry官网并注册账户
2. 创建一个新的存储桶(Pantry)
3. 获取API密钥用于身份验证
4. 使用HTTP请求存储或检索JSON数据
5. 在项目中集成Pantry的API端点

Python示例:存储和获取数据

python
import requests
import json

# 存储数据
base_url = 'https://getpantry.cloud'
headers = {
    'Content-Type': 'application/json',
    'Pantry-Id': 'YOUR_API_KEY'
}

# 创建篮子(存储桶)
basket_name = 'myBasket'
data_to_store = {'key': 'value', 'items': [1, 2, 3]}

response = requests.post(
    f'{base_url}/api/pantry/YOUR_API_KEY/basket/{basket_name}',
    headers=headers,
    data=json.dumps(data_to_store)
)
print(f'存储状态: {response.status_code}')

# 获取篮子数据
retrieve_response = requests.get(
    f'{base_url}/api/pantry/YOUR_API_KEY/basket/{basket_name}',
    headers=headers
)
if retrieve_response.status_code == 200:
    retrieved_data = retrieve_response.json()
    print(f'获取的数据: {retrieved_data}')

PHP示例:使用cURL存储JSON数据

php
<?php
$baseUrl = 'https://getpantry.cloud';
$apiKey = 'YOUR_API_KEY';
$basketName = 'myBasket';

// 准备要存储的数据
$data = array(
    'project' => 'demo',
    'timestamp' => time(),
    'settings' => array('theme' => 'dark')
);

$jsonData = json_encode($data);

// 存储数据
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$baseUrl/api/pantry/$apiKey/basket/$basketName");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Pantry-Id: ' . $apiKey
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "存储响应代码: $httpCode\n";

// 获取数据
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$baseUrl/api/pantry/$apiKey/basket/$basketName");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Pantry-Id: ' . $apiKey));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$retrievedData = curl_exec($ch);
curl_close($ch);

echo "获取的数据: $retrievedData\n";
?>

JavaScript示例:使用Fetch API

javascript
const baseUrl = 'https://getpantry.cloud';
const apiKey = 'YOUR_API_KEY';
const basketName = 'myBasket';

// 存储数据
async function storeData() {
    const data = {
        user: 'demoUser',
        preferences: {
            language: 'zh-CN',
            notifications: true
        },
        lastUpdated: new Date().toISOString()
    };

    const response = await fetch(
        `${baseUrl}/api/pantry/${apiKey}/basket/${basketName}`,
        {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Pantry-Id': apiKey
            },
            body: JSON.stringify(data)
        }
    );
    
    console.log(`存储状态: ${response.status}`);
    return response.ok;
}

// 获取数据
async function retrieveData() {
    const response = await fetch(
        `${baseUrl}/api/pantry/${apiKey}/basket/${basketName}`,
        {
            headers: {
                'Pantry-Id': apiKey
            }
        }
    );
    
    if (response.ok) {
        const data = await response.json();
        console.log('获取的数据:', data);
        return data;
    } else {
        console.error('获取数据失败');
        return null;
    }
}

// 使用示例
storeData().then(() => {
    retrieveData();
});

常见问题

Pantry是免费的吗?有什么使用限制?

Pantry完全免费使用,主要限制包括:每个API密钥最多创建100个篮子(存储桶),每个篮子最大存储限制为100KB,请求频率限制为每分钟60次。这些限制对于小型项目和原型开发通常足够。

如何保护我的数据安全?

Pantry通过API密钥进行访问控制。每个篮子通过唯一的篮子名称和API密钥组合进行保护。建议不要在前端代码中暴露API密钥,而是通过后端服务器中转请求。数据以明文JSON形式存储,不适合存储敏感个人信息。

Pantry支持哪些数据格式和操作?

Pantry专门设计用于存储和检索JSON数据。支持完整的CRUD操作:创建(POST)、读取(GET)、更新(PUT/POST)和删除(DELETE)篮子。所有数据必须以有效的JSON格式发送,响应也始终是JSON格式。

相似接口推荐

AWS SSO Identity Store

AWS SSO Identity Store是AWS IAM Identity Center(原AWS单点登录)使用的身份存储服务,提供一个统一的位置检索所有身份信息(用户和群组)。该服务简化了身份管理流程,帮助集中管理

待确认
Amazon Honeycode

Amazon Honeycode是一项全托管服务,让您无需编程即可快速为团队构建移动和Web应用。可用于管理项目、客户、运营、审批、资源乃至团队协作等各类事务。

待确认
AWS Glue

AWS Glue 是一项完全托管的提取、转换和加载(ETL)服务,可简化数据准备和集成工作。它自动发现、编目数据,并支持在数据湖和数据仓库之间进行ETL操作。

待确认
亚马逊Glacier

亚马逊S3 Glacier(简称Glacier)是一款针对“冷数据”的存储解决方案。这项超低成本的存储服务为数据备份和归档提供安全、持久且易于使用的存储方案。用户可经济高效地存储数据数月、数年甚至数十年。

待确认