Getting started overview
Pantry provides a simple backend-as-a-service for storing and managing JSON data via a RESTful API. It is designed for developers who need a quick, no-setup solution for small data storage requirements, such as those found in rapid prototyping, personal projects, or serverless application backends. The core functionality revolves around creating 'Pantries,' which are essentially unique JSON data stores, and then using HTTP requests to read, write, update, or delete data within them.
The process of getting started typically involves:
- Creating a free Pantry account.
- Obtaining your unique Pantry ID(s).
- Making your first API request to store or retrieve data.
Pantry distinguishes itself by offering minimal setup and a focus on ease of use. For public Pantries, explicit API authentication is not required, simplifying initial development steps. For private Pantries, an API key is used to secure access.
Quick Reference Guide
| Step | What to Do | Where |
|---|---|---|
| 1. Sign Up | Register for a free Pantry account. | Pantry homepage |
| 2. Create Pantry | Generate a new Pantry to get a unique ID. | Pantry dashboard |
| 3. Get API Key (Optional) | Retrieve your API key for private Pantries. | Pantry dashboard, Account Settings |
| 4. Make Request | Send a POST/GET request to your Pantry ID endpoint. | Command line (cURL), browser, or code |
| 5. Verify Data | Check the response or view data in the dashboard. | API response, Pantry dashboard |
Create an account and get keys
To begin using Pantry, you need to create an account. Pantry offers a free tier that allows users to create up to five Pantries, which is sufficient for initial testing and small projects. The registration process typically involves providing an email address and setting a password.
- Navigate to the Pantry Website: Open your web browser and go to the Pantry homepage.
- Sign Up: Look for a 'Sign Up' or 'Get Started Free' button and follow the prompts to create your account.
- Dashboard Access: Once registered and logged in, you will be directed to your Pantry dashboard. This is where you manage your Pantries.
- Create Your First Pantry: Within the dashboard, you will find an option to 'Create New Pantry'. Clicking this will generate a new, unique storage instance for your JSON data.
- Obtain Your Pantry ID: Each Pantry you create will have a unique identifier, often referred to as a 'Pantry ID'. This ID is crucial as it forms part of the URL for all your API requests to that specific Pantry. You can find this ID displayed prominently in your dashboard next to each Pantry you create.
- Retrieve API Key (for Private Pantries): While public Pantries do not require an API key for basic operations, if you intend to create private Pantries or perform authenticated actions, you will need your API key. This key is typically found in your account settings or profile section within the Pantry dashboard. Keep this key secure, as it grants access to your private data.
Pantry's design philosophy minimizes the need for complex key management for public data, allowing developers to quickly prototype without immediate security overhead. However, for sensitive data, utilizing private Pantries and securing your API key is essential, similar to how other API keys are managed for cloud services.
Your first request
After setting up your account and obtaining a Pantry ID, you can make your first API call. This example demonstrates how to store data using a POST request and retrieve it using a GET request. We will use curl for these examples, as it is a widely available command-line tool for making HTTP requests.
Before proceeding, ensure you have your unique Pantry ID. For this example, let's assume your Pantry ID is your_pantry_id_here.
Storing Data (POST Request)
To store data in your Pantry, send an HTTP POST request to the Pantry endpoint with your JSON payload in the request body. The Content-Type header should be set to application/json.
curl -X POST \
-H "Content-Type: application/json" \
-d '{"item": "milk", "quantity": 2, "unit": "gallons"}' \
https://pantry.cloud/apiv1/pantry/your_pantry_id_here
Replace your_pantry_id_here with your actual Pantry ID. Upon a successful request, Pantry will return a JSON response indicating the status, typically a 200 OK status code and a confirmation message. The data you sent will now be stored in your Pantry.
Retrieving Data (GET Request)
To retrieve all data currently stored in your Pantry, send an HTTP GET request to the same Pantry endpoint:
curl -X GET \
https://pantry.cloud/apiv1/pantry/your_pantry_id_here
Again, replace your_pantry_id_here with your actual Pantry ID. The response will be the JSON data currently stored in your Pantry. If you previously posted the data from the example above, the response might look similar to this:
{
"item": "milk",
"quantity": 2,
"unit": "gallons"
}
Updating Data (PUT Request)
To completely overwrite the existing data in your Pantry, use an HTTP PUT request. This will replace the entire content of your Pantry with the new JSON payload.
curl -X PUT \
-H "Content-Type: application/json" \
-d '{"item": "eggs", "count": 12}' \
https://pantry.cloud/apiv1/pantry/your_pantry_id_here
After this PUT request, a subsequent GET request would return {"item": "eggs", "count": 12}, as the previous data has been replaced.
Deleting Data (DELETE Request)
To clear all data from your Pantry, send an HTTP DELETE request:
curl -X DELETE \
https://pantry.cloud/apiv1/pantry/your_pantry_id_here
A successful DELETE request will typically return a 200 OK status. Subsequent GET requests to this Pantry will return an empty JSON object ({}).
Common next steps
Once you have successfully made your first API calls with Pantry, consider these common next steps to further integrate and utilize the service:
- Explore the Pantry Dashboard: Familiarize yourself with the Pantry web interface. It allows you to view and manage your Pantries, inspect their contents, and monitor usage without needing to make API calls.
- Implement in Your Application: Integrate Pantry API calls into your chosen programming language or framework. Pantry's documentation provides examples for various languages, including JavaScript and Python.
-
Handle Private Pantries: If your project requires secure data storage, learn how to create private Pantries and use your API key for authentication. This involves sending your API key in the
Authorizationheader for each request, following standard HTTP authorization practices. - Error Handling: Implement robust error handling in your application to gracefully manage scenarios such as network issues, invalid Pantry IDs, or API rate limits. Pantry's API typically returns descriptive JSON error messages.
- Consider Rate Limits: Be aware of any rate limits imposed by Pantry to prevent abuse. For most development and small-scale applications, these limits are generous, but for high-traffic scenarios, it's a consideration.
- Backup Strategy: For critical data, consider implementing a backup strategy. While Pantry stores your data, having local or alternative cloud backups is a good practice for any application.
- Explore Alternatives: Depending on project growth and complexity, you might evaluate alternatives like Firebase Firestore or Supabase for more advanced features like real-time databases, complex querying, or authentication services, though these typically involve more setup.
Troubleshooting the first call
When making your first API calls, you might encounter common issues. Here's how to troubleshoot them:
-
Incorrect Pantry ID:
- Symptom:
404 Not Foundor a similar error message indicating the Pantry doesn't exist. - Solution: Double-check that the Pantry ID in your request URL exactly matches the ID displayed in your Pantry dashboard. IDs are case-sensitive.
- Symptom:
-
Missing or Incorrect Content-Type Header:
- Symptom:
400 Bad Requestor an error stating invalid JSON. - Solution: For
POSTandPUTrequests, ensure you include the header-H "Content-Type: application/json". The request body must also be valid JSON.
- Symptom:
-
Invalid JSON Payload:
- Symptom:
400 Bad Requestwith a message about malformed JSON. - Solution: Verify that your JSON data is correctly formatted. Use an online JSON validator if unsure. Ensure all keys and string values are enclosed in double quotes, and commas are used correctly.
- Symptom:
-
Network Connectivity Issues:
- Symptom: Request timeouts or connection refused errors.
- Solution: Check your internet connection. Ensure no firewalls or proxies are blocking outgoing requests to
pantry.cloud.
-
Using a Private Pantry Without an API Key:
- Symptom:
401 Unauthorizedor403 Forbidden. - Solution: If you've marked your Pantry as private, you must include your API key in the
Authorizationheader:-H "Authorization: Bearer YOUR_API_KEY". Ensure you are using the correct API key from your Pantry account settings.
- Symptom:
-
Rate Limit Exceeded:
- Symptom:
429 Too Many Requests. - Solution: You've sent too many requests in a short period. Wait a moment and retry. For production applications, implement exponential backoff for retries. Review Pantry's rate limit documentation.
- Symptom: