### Get and Install ClawHub Skills Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/agents.mdx Examples for retrieving skill details and installing a skill from ClawHub. ```bash # Get skill details by slug pinata agents clawhub get clawdhub # Install a skill to your library pinata agents clawhub install ``` -------------------------------- ### Copy Environment Variables Source: https://github.com/pinatacloud/docs/blob/main/files/mpp/self-hosting.mdx Copy the example environment file to start configuring your deployment. ```bash cp .dev.vars.example .dev.vars ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/pinatacloud/docs/blob/main/tools/erc-8004/quickstart.mdx Clone the ERC-8004 repository, navigate to the directory, install dependencies using bun, and copy the environment variable example. ```bash git clone https://github.com/PinataCloud/erc8004 cd erc8004 bun install cp .env.example .env # fill in your values ``` -------------------------------- ### Install Pinata SDK Source: https://github.com/pinatacloud/docs/blob/main/frameworks/hono.mdx Navigate into your project directory and install the Pinata SDK. ```bash cd pinata-server npm i pinata ``` -------------------------------- ### Clone and Install Pinata CLI from Source Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/overview.mdx Build and install the Pinata CLI from its source code. Requires Go to be installed. ```bash git clone https://github.com/PinataCloud/ipfs-cli && cd ipfs-cli && go install . ``` -------------------------------- ### Create New Astro Project Source: https://github.com/pinatacloud/docs/blob/main/frameworks/astro.mdx Run this command in your terminal to start a new Astro project. You can customize the setup based on your preferences. ```bash npm create astro@latest pinata-astro ``` -------------------------------- ### Optimize Image with Public Gateway Source: https://github.com/pinatacloud/docs/blob/main/gateways/image-optimizations.mdx This example demonstrates how to use the `optimizeImage` method on the `get` method of the public gateway to resize and format an image. ```APIDOC ## Optimize Image with Public Gateway ### Description This method allows you to optimize an image served through the public gateway. You can specify various parameters to control the output size, format, quality, and more. ### Method `get(...).optimizeImage(options)` ### Parameters #### Query Parameters (for optimizeImage) - **width** (number) - Optional - The desired width of the image in pixels. - **height** (number) - Optional - The desired height of the image in pixels. - **dpr** (number) - Optional - The device pixel ratio for the image. - **fit** (string) - Optional - How the image should be resized. Options: "scaleDown", "contain", "cover", "crop", "pad". - **gravity** (string) - Optional - Defines the direction for cropping. Options: "auto", "side", or a custom string. - **quality** (number) - Optional - The quality of the output image (1-100). - **format** (string) - Optional - The desired output format. Options: "auto", "webp". - **animation** (boolean) - Optional - Whether to preserve animation for GIF images. - **sharpen** (number) - Optional - The amount of sharpening to apply to the image. - **onError** (boolean) - Optional - Whether to return an error if optimization fails. - **metadata** (string) - Optional - How to handle image metadata. Options: "keep", "copyright", "none". ### Request Example ```typescript const data = await pinata.gateways.public .get("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4") .optimizeImage({ width: 500, height: 500, format: "webp" }); ``` ### Response #### Success Response (200) Returns the optimized image data. ``` -------------------------------- ### Demonstrate Hot Swaps Plugin Functionality Source: https://github.com/pinatacloud/docs/blob/main/gateways/plugins/hot-swaps.mdx This example demonstrates the full lifecycle of using the Hot Swaps plugin: uploading two files, creating a swap between their CIDs, and then fetching the swapped CID through a gateway. Ensure your Pinata SDK is configured with a gateway that has the Hot Swaps plugin installed. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "example.mypinata.cloud", // Gateway has Hot Swaps installed }); async function main() { try { // Upload the first file const file = new File(["The original CID"], "cid.txt", { type: "text/plain", }); const { IpfsHash: CID1 } = await pinata.upload.public.file(file); console.log("This is the original CID hash: ", CID1); // Upload a second file const file2 = new File(["The new CID"], "cid.txt", { type: "text/plain" }); const { IpfsHash: CID2 } = await pinata.upload.public.file(file2); console.log("This is the new CID hash: ", CID2); // Create the swap, so when we visit CID1 we will get the content of CID2 const swap = await pinata.files.public.addSwap({ cid: CID1, swapCid: CID2, }); console.log("Swap created: ", swap); // Fetch CID1 through our gateway that has Hot Swaps installed, get the content of CID2 const data = await pinata.gateways.public.get(CID1); console.log("Result of requestingt CID1 through the gateway: ", data); } catch (error) { console.log(error); } } main(); ``` -------------------------------- ### Create Node.js Project and Install Dependencies Source: https://github.com/pinatacloud/docs/blob/main/frameworks/node-js.mdx Initializes a new Node.js project and installs the Pinata SDK and dotenv for environment variables. ```bash mkdir pinata-starter && cd pinata-starter && npm init -y ``` ```bash npm i pinata dotenv ``` -------------------------------- ### Install Pinata SDK and Dependencies Source: https://github.com/pinatacloud/docs/blob/main/frameworks/astro.mdx After setting up the Astro project, navigate into the project directory and install the Pinata SDK. This command also installs Vercel and Svelte for server-side rendering and UI. ```bash cd pinata-astro && npm i pinata ``` ```bash npx astro add vercel svelte ``` -------------------------------- ### Install Mintlify CLI Source: https://github.com/pinatacloud/docs/blob/main/README.md Use this command to install the Mintlify CLI globally. This tool is required to preview documentation changes locally. ```bash npm i -g mintlify ``` -------------------------------- ### View User Start Log and Network Sockets Source: https://github.com/pinatacloud/docs/blob/main/agents/troubleshooting.mdx Check the last 200 lines of the user start log and list listening network sockets to troubleshoot immediate start script crashes. ```bash tail -n 200 /tmp/user-start.log ss -tlnp ``` -------------------------------- ### Start Local Development Server Source: https://github.com/pinatacloud/docs/blob/main/files/mpp/self-hosting.mdx Run the development server locally. The server will be accessible at http://localhost:8787. ```bash npm run dev ``` -------------------------------- ### Example Signed URL Source: https://github.com/pinatacloud/docs/blob/main/sdk/upload/private/create-signed-url.mdx This is an example of a full signed URL, including various parameters for authentication and expiration. ```string https://uploads.pinata.cloud/v3/files/209bb44c-e987-47c4-a9e3-a88e02d4d8e9?X-Algorithm=PINATA2&X-Date=1734379351&X-Expires=300&X-Method=%5B%22HEAD%22%2C%22PATCH%22%2C%22POST%22%5D&X-User-ID=eb73db21-10fa-4005-b97c-639e19e82d60&X-Signature= ``` -------------------------------- ### Example Wallet Address Source: https://github.com/pinatacloud/docs/blob/main/files/signatures.mdx An example of a valid Ethereum wallet address used for signing. ```plaintext 0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826 ``` -------------------------------- ### Install Pinata CLI using curl Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/overview.mdx Use this command to easily install the Pinata CLI by downloading and executing the install script. ```bash curl -fsSL https://cli.pinata.cloud/install | bash ``` -------------------------------- ### Pinata CLI Agents Skills Examples Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/agents.mdx Provides practical examples for using the `pinata agents skills` commands, such as listing, creating, attaching, and detaching skills. ```bash # List skills in your library pinata agents skills list ``` ```bash # Create a skill from a CID pinata agents skills create --cid --name "My Skill" --env API_KEY ``` ```bash # Attach skills to an agent pinata agents skills attach ``` ```bash # Detach a skill from an agent pinata agents skills detach ``` -------------------------------- ### Example Date Source: https://github.com/pinatacloud/docs/blob/main/files/signatures.mdx An example of a date string in ISO 8601 format, representing when a CID was uploaded. ```plaintext 2024-07-29T18:29:47.355Z ``` -------------------------------- ### Install mppx SDK Dependencies Source: https://github.com/pinatacloud/docs/blob/main/files/mpp/quickstart.mdx Install the necessary client SDK packages for programmatic access in TypeScript/JavaScript applications. ```bash npm install mppx viem ``` -------------------------------- ### Quick Example: Upload, Create Payment, and Attach CID Source: https://github.com/pinatacloud/docs/blob/main/sdk/x402/index.mdx This example demonstrates the full workflow: uploading a private file, creating a payment instruction for USDC, and attaching the file's CID to the instruction. Ensure you have your Pinata JWT and gateway configured. The resulting x402 gateway URL can then be shared to grant access upon payment. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "your-gateway.mypinata.cloud", }); // 1. Upload a private file const file = new File(["premium content"], "content.pdf", { type: "application/pdf" }); const upload = await pinata.upload.private.file(file); // 2. Create a payment instruction const instruction = await pinata.x402.createPaymentInstruction({ name: "Premium Content Access", payment_requirements: [ { asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base pay_to: "0xYourWalletAddress", // YOU receive payments here network: "base", amount: "10000", // $0.01 in USDC }, ], }); // 3. Attach CID to payment instruction await pinata.x402.addCid(instruction.data.id, upload.cid); // 4. Share the x402 gateway URL // https://your-gateway.mypinata.cloud/x402/cid/{cid} ``` -------------------------------- ### SDK List Groups Response Example Source: https://github.com/pinatacloud/docs/blob/main/files/file-groups.mdx An example of the response object when listing groups using the SDK. ```typescript { groups: [ { id: "0191997b-ca28-79e8-9dbc-a8044ad3e547", name: "My New Group 5", created_at: "2024-08-28T14:55:12.448504Z", } ], next_page_token: "MDE5MWIzNGMtMWNmNy03MzExLThmMjYtZmZlZDMzYTVlY" } ``` -------------------------------- ### Install Pinata Expo Hooks Source: https://github.com/pinatacloud/docs/blob/main/tools/pinata-expo-hooks.mdx Install the latest version of `pinata-expo-hooks` using pnpm. ```bash pnpm i pinata-expo-hooks@latest ``` -------------------------------- ### Install Pinata SDK with bun Source: https://github.com/pinatacloud/docs/blob/main/events/hackutd.mdx Install the Pinata SDK using bun. This command adds the Pinata SDK to your project dependencies. ```bash bun i pinata ``` -------------------------------- ### Cron Schedule Examples Source: https://github.com/pinatacloud/docs/blob/main/agents/tasks.mdx Examples of cron expressions for scheduling tasks. Use these for precise timing of task execution. ```text 0 9 * * * # Every day at 9am 0 */6 * * * # Every six hours 0 9 * * 1-5 # Weekdays at 9am ``` -------------------------------- ### Install Pinata SDK with npm Source: https://github.com/pinatacloud/docs/blob/main/events/hackutd.mdx Install the Pinata SDK using npm. This is the first step to integrating Pinata's services into your project. ```bash npm i pinata ``` -------------------------------- ### SDK Upload Response Example Source: https://github.com/pinatacloud/docs/blob/main/quickstart.mdx Example of the JSON response object received after a successful file upload using the SDK. ```typescript { id: "0195f815-5c5e-716d-9240-d3ae380e2002", group_id: null, name: "hello.txt", cid: "bafkreidvbhs33ighmljlvr7zbv2ywwzcmp5adtf4kqvlly67cy56bdtmve", created_at: "2025-04-02T19:58:24.616Z", size: 12, number_of_files: 1, mime_type: "text/plain", vectorized: false, network: "public", } ``` -------------------------------- ### Configure Lifecycle Scripts Source: https://github.com/pinatacloud/docs/blob/main/agents/manifest.mdx Define shell commands for build and start lifecycle hooks. The build script runs after deployment and git pushes, while the start script runs after a successful build or on agent boot. ```json "scripts": { "build": "cd workspace/projects/app && npm install --include=dev", "start": "cd workspace/projects/app && npx vite --host 0.0.0.0" } ``` -------------------------------- ### Upload JSON Source: https://github.com/pinatacloud/docs/blob/main/files/uploading-files.mdx This example shows how to upload a JSON object. The JSON is converted into a Blob and then a File before uploading. It includes both SDK and API examples. ```APIDOC ## Upload JSON ### Description Uploads a JSON object by converting it into a file. ### Method POST ### Endpoint https://uploads.pinata.cloud/v3/files ### Parameters #### Request Body - **file** (File) - Required - A File object containing the JSON data. - **network** (string) - Required - The network to upload to (e.g., "public"). ### Request Example (API) ```json { "file": "", "network": "public" } ``` ### Response #### Success Response (200) - **IpfsHash** (string) - The IPFS hash of the uploaded JSON file. - **PinSize** (string) - The size of the pinned JSON file. - **isDuplicate** (boolean) - Indicates if the JSON file was a duplicate. #### Response Example ```json { "IpfsHash": "Qm...", "PinSize": "567", "isDuplicate": false } ``` ``` -------------------------------- ### Create Payment Instruction with Name Source: https://github.com/pinatacloud/docs/blob/main/sdk/x402/payment-instructions/create.mdx Example demonstrating the required 'name' parameter for creating a payment instruction. ```typescript const instruction = await pinata.x402.createPaymentInstruction({ name: "Premium Content Access", payment_requirements: [ { asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC on Base pay_to: "0x1234567890abcdef1234567890abcdef12345678", network: "base", amount: "10000", // $0.01 in USDC (6 decimals) }, ], }); ``` -------------------------------- ### Browse and Filter ClawHub Skills Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/agents.mdx Examples of how to browse and filter skills from the ClawHub marketplace using the CLI. ```bash # Browse available skills pinata agents clawhub list # Browse featured skills, newest first pinata agents clawhub list --featured --sort newest ``` -------------------------------- ### Full useUpload Hook Example Source: https://github.com/pinatacloud/docs/blob/main/tools/pinata-expo-hooks.mdx A comprehensive example demonstrating the implementation of the `useUpload` hook in an Expo component, including image/document picking, upload initiation, and UI updates for progress and status. ```typescript import { Image } from "expo-image"; import { View, Text, Button, StyleSheet } from "react-native"; import * as ImagePicker from "expo-image-picker"; import * as DocumentPicker from "expo-document-picker"; import { useState } from "react"; import ParallaxScrollView from "@/components/ParallaxScrollView"; import { useUpload } from "pinata-expo-hooks"; const SERVER_URL = "http://localhost:8787"; // Server that returns a presigned_url export default function HomeScreen() { const { upload, // Method to upload a file using a presigned URL progress, // Progress state as integer loading, // Boolean uploading state uploadResponse, // CID for the uploaded file error, // Error state pause, // Pause upload method resume, // Resume upload method cancel, // Cancel current upload method } = useUpload(); const [fileUri, setFileUri] = useState(null); const [fileName, setFileName] = useState(null); const pickImage = async () => { const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (status !== "granted") { alert("Sorry, we need camera roll permissions to make this work!"); return; } const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.All, allowsEditing: false, quality: 1, }); if (!result.canceled && result.assets && result.assets.length > 0) { setFileUri(result.assets[0].uri); setFileName(result.assets[0].uri.split("/").pop() || "image"); } }; // Pick document from device const pickDocument = async () => { try { const result = await DocumentPicker.getDocumentAsync(); if (result.canceled === false) { setFileUri(result.assets[0].uri); setFileName(result.assets[0].name); } } catch (err) { console.error("Error picking document", err); } }; ``` -------------------------------- ### Specify Group ID for Get Request Source: https://github.com/pinatacloud/docs/blob/main/sdk/groups/private/get.mdx Example demonstrating how to pass the `groupId` parameter to the `get` method for fetching group details. ```typescript const groups = await pinata.groups.private.get({ groupId: "3778c10d-452e-4def-8299-ee6bc548bdb0", }); ``` -------------------------------- ### Create Project Files Source: https://github.com/pinatacloud/docs/blob/main/frameworks/node-js.mdx Creates the main index.js file for your application logic and a sample hello-world.txt file. ```bash touch index.js && touch hello-world.txt ``` -------------------------------- ### Get Installed Plugins for Gateway Source: https://github.com/pinatacloud/docs/blob/main/gateways/plugins/getting-started.mdx Retrieve a list of all plugins currently installed on a specific Dedicated Gateway. Requires the gateway ID and your Pinata JWT. ```typescript const gatewayId = "8673cd80-bf53-4bca-b684-bec1d6bdf004" const installPlugin = await fetch(`https://api.pinata.cloud/v3/ipfs/gateway_plugins/${gatewayId}`, { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Bearer ${PINATA_JWT}` } }) ``` ```json { "data": { "gateway_id": "8673cd80-bf53-4bca-b684-bec1d6bdf004", "plugin_id": 1 } } ``` -------------------------------- ### Develop Documentation Locally Source: https://github.com/pinatacloud/docs/blob/main/README.md Run this command at the root of your documentation directory (where mint.json is located) to start a local development server for previewing changes. ```bash mintlify dev ``` -------------------------------- ### Clone MPP Server Repository Source: https://github.com/pinatacloud/docs/blob/main/files/mpp/self-hosting.mdx Clone the MPP Server repository and install its dependencies. ```bash git clone git@github.com:PinataCloud/mpp-server.git cd mpp-server npm install ``` -------------------------------- ### Set Up Viem Local Account Source: https://github.com/pinatacloud/docs/blob/main/files/x402/x402-accessing-paid-content.mdx Use this to create an account from a private key for Viem. ```typescript import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount("0xYOUR_PRIVATE_KEY"); ``` -------------------------------- ### Create Remix App Source: https://github.com/pinatacloud/docs/blob/main/frameworks/remix.mdx Use this command to start a new Remix project named 'pinata-remix'. ```bash npx create-remix@latest pinata-remix ``` -------------------------------- ### Create Agent from Template CLI Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/agents.mdx Example demonstrating how to create an agent using a specified template. First, list available templates, then use the `create` command with the `--template` flag. ```bash # List available templates pinata agents templates list # Create agent from template pinata agents create --name "My IPFS Agent" --template tpchchgg ``` -------------------------------- ### ClawHub Skills Management Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/agents.mdx Commands for browsing, getting details of, and installing skills from the ClawHub marketplace. ```APIDOC ## `pinata agents clawhub list` ### Description Browse available skills from the ClawHub community marketplace. ### Usage `pinata agents clawhub list [--category string -c string] [--sort string -s string] [--featured] [--cursor string] [--help -h]` ### Options - `--category string, -c string`: Filter skills by a specific category. - `--sort string, -s string`: Sort the results by 'popular', 'newest', or 'name'. - `--featured`: Show only featured skills. - `--cursor string`: Use a cursor for paginating through results. ### Examples ```bash # Browse all available skills pinata agents clawhub list # Browse featured skills, sorted by newest first pinata agents clawhub list --featured --sort newest ``` ``` ```APIDOC ## `pinata agents clawhub get` ### Description Get detailed information about a specific skill from ClawHub using its slug. ### Usage `pinata agents clawhub get [--help -h]` ### Parameters #### Path Parameters - **hub-skill-id** (string) - Required - The unique identifier (slug) of the skill to retrieve. ### Examples ```bash # Get details for a skill with the slug 'claudhub' pinata agents clawhub get claudhub ``` ``` ```APIDOC ## `pinata agents clawhub install` ### Description Install a skill from ClawHub into your Pinata library. ### Usage `pinata agents clawhub install [--help -h]` ### Parameters #### Path Parameters - **hub-skill-id** (string) - Required - The unique identifier (slug) of the skill to install. ### Examples ```bash # Install a skill with the ID 'my-skill-id' pinata agents clawhub install my-skill-id ``` ``` -------------------------------- ### Example Workflow for Monetizing Content Source: https://github.com/pinatacloud/docs/blob/main/files/x402/intro.mdx This snippet demonstrates the end-to-end process of uploading a private file, creating a payment instruction, attaching the file's CID, and preparing to share the x402 gateway URL for monetization. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "your-gateway.mypinata.cloud", }); // 1. Upload a private file const file = new File(["premium content"], "content.pdf", { type: "application/pdf" }); const upload = await pinata.upload.private.file(file); // 2. Create a payment instruction const instruction = await pinata.x402.createPaymentInstruction({ name: "Premium Content", payment_requirements: [ { asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", pay_to: "0xYourWalletAddress", // YOU receive payments here network: "base", description: "Access fee", amount: "10000", // $0.01 in USDC }, ], }); // 3. Attach CID to payment instruction await pinata.x402.addCid(instruction.data.id, upload.cid); // 4. Share the x402 gateway URL // https://your-gateway.mypinata.cloud/x402/cid/{cid} ``` -------------------------------- ### Get Swap History with CID Parameter Source: https://github.com/pinatacloud/docs/blob/main/sdk/files/private/get-swap-history.mdx Example of calling getSwapHistory, highlighting the `cid` parameter which specifies the target CID for swap history. ```typescript const history = await pinata.files.private.getSwapHistory({ cid: "bafkreibbvdqf5ekc2crouowv7vtjbcmbjoiysegslmmqc6jrxbaa43xske", domain: "discordpinnie.mypinata.cloud" }) ``` -------------------------------- ### Get Requests by Custom Date Range Source: https://github.com/pinatacloud/docs/blob/main/sdk/analytics/requests.mdx Fetches analytics for requests within a custom date range specified by start and end dates. ```typescript const files = await pinata.analytics.requests .customDates("2024-11-01", "2024-11-20") .cid() ``` -------------------------------- ### Get Bandwidth Analytics with Custom Dates Source: https://github.com/pinatacloud/docs/blob/main/sdk/analytics/bandwidth.mdx Queries bandwidth analytics using a custom start and end date. The date format must be 'YYYY-MM-DD'. ```typescript const files = await pinata.analytics.bandwidth .customDates("2024-11-01", "2024-11-20") .cid() ``` -------------------------------- ### Get Signature for CID via Gateway HEAD Request Source: https://github.com/pinatacloud/docs/blob/main/files/signatures.mdx Retrieve a CID's signature by making a HEAD request to your Dedicated Gateway. The signature will be available in the `pinata-signature` response header. Ensure the Content Addressable Gateway Plugin is installed. ```typescript const signatureReq = await fetch( `https://.mypinata.cloud/ipfs/`, { method: "HEAD", } ); const signature = signatureReq.headers.get("pinata-signature"); ``` -------------------------------- ### Create React Project with Vite Source: https://github.com/pinatacloud/docs/blob/main/frameworks/react.mdx Use Vite to quickly scaffold a new React project. This command initiates the project setup process. ```bash npm create vite@latest ``` -------------------------------- ### Install Pinata CLI using Homebrew Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/overview.mdx For macOS users with Homebrew installed, this command installs the Pinata CLI. ```bash brew install PinataCloud/ipfs-cli/ipfs-cli ``` -------------------------------- ### Set Up Coinbase CDP Wallet Source: https://github.com/pinatacloud/docs/blob/main/files/x402/x402-accessing-paid-content.mdx Initialize a Coinbase SDK client and create a wallet instance. This wallet can then be used to get a default address. ```typescript import { Coinbase, Wallet } from "@coinbase/coinbase-sdk"; const coinbase = new Coinbase({ apiKeyName: "YOUR_API_KEY_NAME", privateKey: "YOUR_PRIVATE_KEY", }); const wallet = await Wallet.create(); const account = await wallet.getDefaultAddress(); ``` -------------------------------- ### Create API Key Source: https://github.com/pinatacloud/docs/blob/main/sdk/keys/create.mdx This example demonstrates how to create a new API key with specific permissions and a maximum usage limit. ```APIDOC ## Create API Key ### Description Creates a new API key with specified name, permissions, and usage limits. ### Method `pinata.keys.create(options)` ### Parameters #### keyName - **keyName** (string) - Required - The name for the API key. #### maxUses (Optional) - **maxUses** (number) - Optional - Limits the number of times the key can be used. #### permissions - **permissions** (KeyPermissions) - Optional - Defines the access level for the API key. - **admin** (boolean) - Optional - Grants admin access to all endpoints if true. - **resources** (ResourcePermission[]) - Optional - Scopes the key to specific resources. - Possible values: "org:read", "org:write", "org:files:read", "org:files:write", "org:groups:read", "org:groups:write", "org:gateways:read", "org:gateways:write", "org:analytics:read", "org:analytics:write" - **endpoints** (Endpoints) - Optional - Scopes the key to specific API endpoints. - **data** (object) - Optional - Permissions for data-related endpoints. - **pinList** (boolean) - Required - Access to list pinned data. - **userPinnedDataTotal** (boolean) - Required - Access to user's total pinned data. - **pinning** (object) - Optional - Permissions for pinning-related endpoints. - **hashMetadata** (boolean) - Required - Access to update hash metadata. - **hashPinPolicy** (boolean) - Required - Access to set hash pin policy. - **pinByHash** (boolean) - Required - Access to pin by hash. - **pinFileToIPFS** (boolean) - Required - Access to pin files to IPFS. - **pinJSONToIPFS** (boolean) - Required - Access to pin JSON to IPFS. - **pinJobs** (boolean) - Required - Access to pin jobs. - **unpin** (boolean) - Required - Access to unpin data. - **userPinPolicy** (boolean) - Required - Access to user pin policy. ### Request Example ```typescript const key = await pinata.keys.create({ keyName: "user 1", permissions: { resources: [ "org:files:read", "org:groups:read" ] }, maxUses: 1, }); ``` ### Response #### Success Response (200) - **JWT** (string) - The JSON Web Token for authentication. - **pinata_api_key** (string) - The generated API key. - **pinata_api_secret** (string) - The generated API secret. ``` -------------------------------- ### Example CID Source: https://github.com/pinatacloud/docs/blob/main/files/signatures.mdx An example of a Content Identifier (CID) that can be signed. ```plaintext bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4 ``` -------------------------------- ### Create SvelteKit Project Source: https://github.com/pinatacloud/docs/blob/main/frameworks/sveltekit.mdx Use npm create to initialize a new SvelteKit project. Select 'Skeleton project' and 'TypeScript syntax' for type checking. Additional options are optional. ```bash npm create svelte@latest pinata-app - Which Svelte app template? Skeleton project - Add type checking with TypeScript? Yes, using TypeScript syntax - Select additional options (use arrow keys/space bar) <- These are optional ``` -------------------------------- ### Create Signed URL with Image Optimizations Source: https://github.com/pinatacloud/docs/blob/main/sdk/gateways/private/create-signed-url.mdx This example demonstrates creating a signed URL for an image and applying image optimizations such as resizing and format conversion. The `optimizeImage` method allows for on-the-fly image processing. ```typescript const data = await pinata.gateways.private .createAccessLink("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4") .optimizeImage({ width: 500, height: 500, format: "webp" }) ``` -------------------------------- ### Skill Metadata Example Source: https://github.com/pinatacloud/docs/blob/main/agents/skills.mdx Define the name and description for your skill using YAML frontmatter in the SKILL.md file. This is the minimum required information for publishing a skill. ```markdown --- name: my-skill description: What this skill does --- # My Skill Instructions the agent should follow when using this skill. ``` -------------------------------- ### Viem Wallet Client and Account Setup Source: https://github.com/pinatacloud/docs/blob/main/files/signatures.mdx Sets up a Viem wallet client using the browser's Ethereum provider and retrieves the connected account's address. This configuration is necessary for interacting with the blockchain and signing transactions. ```typescript import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' export const walletClient = createWalletClient({ chain: mainnet, transport: custom(window.ethereum!), }) export const [account] = await walletClient.getAddresses() ↑ JSON-RPC Account // export const account = privateKeyToAccount(...) ↑ Local Account ``` -------------------------------- ### Agent Console Prompt Example Source: https://github.com/pinatacloud/docs/blob/main/agents/console.mdx This shows the typical prompt you'll see in the agent console, indicating the working directory. ```text --- Agent Console --- Working directory: /home/node/clawd/workspace ~/clawd/workspace $ ``` -------------------------------- ### API Group Object Example Source: https://github.com/pinatacloud/docs/blob/main/files/file-groups.mdx An example of the group information object returned by the API. ```json { "data": { "id": "0191997b-ca28-79e8-9dbc-a8044ad3e547", "name": "My New Group 5", "created_at": "2024-08-28T14:55:12.448504Z" } } ``` -------------------------------- ### SDK Group Object Example Source: https://github.com/pinatacloud/docs/blob/main/files/file-groups.mdx An example of the group information object returned by the SDK. ```typescript { id: "0191997b-ca28-79e8-9dbc-a8044ad3e547", name: "My New Group 5", created_at: "2024-08-28T14:55:12.448504Z", } ``` -------------------------------- ### Clone Agent Template Repository Source: https://github.com/pinatacloud/docs/blob/main/agents/templates/creating.mdx Use this command to clone the starter repository for creating your agent template. Navigate into the cloned directory to begin customization. ```bash git clone https://github.com/PinataCloud/agent-template my-template cd my-template ``` -------------------------------- ### Get File Info Source: https://github.com/pinatacloud/docs/blob/main/tools/cli/ipfs.mdx Get information about a specific file on Pinata by its ID. You can specify the network. ```APIDOC ## `files get` ### Description Get information about a specific file on Pinata by its ID. You can specify the network. ### Usage ``` pinata files get [options] [ID of file] ``` ### Options - `--network string, --net string`: Specify the network (public or private). Uses default if not specified. - `--help, -h`: show help ``` -------------------------------- ### API List Groups Response Example Source: https://github.com/pinatacloud/docs/blob/main/files/file-groups.mdx An example of the response object when listing groups via the API. ```json { "groups": [ { "id": "0191997b-ca28-79e8-9dbc-a8044ad3e547", "name": "My New Group 5", "created_at": "2024-08-28T14:55:12.448504Z" } ], "next_page_token": "MDE5MWIzNGMtMWNmNy03MzExLThmMjYtZmZlZDMzYTVlY" } ``` -------------------------------- ### List All Payment Instructions Source: https://github.com/pinatacloud/docs/blob/main/sdk/x402/payment-instructions/list.mdx Initializes the Pinata SDK and fetches a list of all payment instructions. Ensure you have your PINATA_JWT and gateway configured in your environment variables. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "example-gateway.mypinata.cloud", }); const instructions = await pinata.x402.listPaymentInstructions(); ``` -------------------------------- ### Demonstrate Hot Swaps Functionality Source: https://github.com/pinatacloud/docs/blob/main/files/hot-swaps.mdx Uploads two files, creates a swap between their CIDs, and then retrieves the content of the first CID through a gateway to show it serves the content of the second CID. Ensure your gateway has the Hot Swaps plugin installed. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "example.mypinata.cloud", // Gateway has Hot Swaps installed }); async function main() { try { // Upload the first file const file = new File(["The original CID"], "cid.txt", { type: "text/plain", }); const { cid: CID1 } = await pinata.upload.file(file); console.log("This is the original CID hash: ", CID1); // Upload a second file const file2 = new File(["The new CID"], "cid.txt", { type: "text/plain" }); const { cid: CID2 } = await pinata.upload.file(file2); console.log("This is the new CID hash: ", CID2); // Create the swap, so when we visit CID1 we will get the content of CID2 const swap = await pinata.files.addSwap({ cid: CID1, swapCid: CID2, }); console.log("Swap created: ", swap); // Fetch CID1 through our gateway that has Hot Swaps installed, get the content of CID2 const data = await pinata.gateways.get(CID1); console.log("Result of requestingt CID1 through the gateway: ", data); } catch (error) { console.log(error); } } main(); ``` -------------------------------- ### Upload File using Tempo CLI Source: https://github.com/pinatacloud/docs/blob/main/files/mpp/quickstart.mdx Use the Tempo CLI to get a signed upload URL and then upload a file. This process automatically handles USDC payments. ```bash # 1. Get a signed upload URL (pay USDC automatically) RESPONSE=$(tempo request -X POST \ "https://mpp.pinata.cloud/v1/pin/public?fileSize=1024") # 2. Extract the signed URL URL=$(echo $RESPONSE | jq -r '.url') # 3. Upload your file to the signed URL curl -X POST "$URL" \ -F "file=@your-file.txt" ``` -------------------------------- ### Create API Key with Key Name Source: https://github.com/pinatacloud/docs/blob/main/sdk/keys/create.mdx Example of creating an API key, specifying the key name and setting admin permissions. ```typescript const key = await pinata.keys.create({ keyName: "user 1", permissions: { admin: true, }, maxUses: 1, }); ``` -------------------------------- ### API Upload Response Example Source: https://github.com/pinatacloud/docs/blob/main/quickstart.mdx Example of the JSON response object received after a successful file upload via the API. ```typescript { data: { id: "0195f815-5c5e-716d-9240-d3ae380e2002", group_id: null, name: "hello.txt", cid: "bafkreidvbhs33ighmljlvr7zbv2ywwzcmp5adtf4kqvlly67cy56bdtmve", created_at: "2025-04-02T19:58:24.616Z", size: 12, number_of_files: 1, mime_type: "text/plain", vectorized: false, network: "public", } } ``` -------------------------------- ### API Updated Group Object Example Source: https://github.com/pinatacloud/docs/blob/main/files/file-groups.mdx An example of the updated group information object returned by the API after a name change. ```json { "data": { "id": "01919ac8-a6f5-7e8e-a8a2-6cfe00122b90", "name": "Updated Name", "created_at": "2024-08-28T20:58:46.96779Z" } } ``` -------------------------------- ### Browse and Deploy Agents via CLI Source: https://github.com/pinatacloud/docs/blob/main/agents/templates/overview.mdx Use the Pinata CLI to list available templates and deploy a new agent from a chosen template. ```bash pinata agents templates list # Browse templates pinata agents create --template # Deploy one ``` -------------------------------- ### Complete Integration for Paid Content Access Source: https://github.com/pinatacloud/docs/blob/main/files/x402/x402-accessing-paid-content.mdx Use this TypeScript example to set up your wallet and access paid content via your Pinata gateway. Ensure your PRIVATE_KEY environment variable is set. ```typescript import { wrapFetchWithPayment } from "@x402/fetch"; import { privateKeyToAccount } from "viem/accounts"; // Set up your wallet const account = privateKeyToAccount(process.env.PRIVATE_KEY); const fetchWithPayment = wrapFetchWithPayment(fetch, account); // Access paid content async function accessPaidContent(cid: string) { try { const url = `https://your-gateway.mypinata.cloud/x402/cid/${cid}`; const response = await fetchWithPayment(url); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const content = await response.json(); console.log("Content accessed successfully:", content); return content; } catch (error) { console.error("Failed to access content:", error); throw error; } } // Usage accessPaidContent("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4"); ``` -------------------------------- ### SDK Updated Group Object Example Source: https://github.com/pinatacloud/docs/blob/main/files/file-groups.mdx An example of the updated group information object returned by the SDK after a name change. ```typescript { id: "3778c10d-452e-4def-8299-ee6bc548bdb0", name: "My New Group 2", created_at: "2024-08-28T20:58:46.96779Z" } ``` -------------------------------- ### Example Presigned URL Response Source: https://github.com/pinatacloud/docs/blob/main/frameworks/hono.mdx This is an example of the JSON response you should receive when successfully requesting a presigned URL from the /presigned_url endpoint. ```json {"url":"https://uploads.pinata.cloud/v3/files/redacted?X-Algorithm=PINATA2&X-Date=1743695529&X-Expires=60&X-Method=%5B%22HEAD%22%2C%22PATCH%22%2C%22POST%22%5D&X-Upload-Option-Network=public&X-User-ID=redacted&X-Signature=redacted"} ``` -------------------------------- ### Response Structure for get() Method Source: https://github.com/pinatacloud/docs/blob/main/sdk/gateways/public/get.mdx Defines the expected structure of the response from the `get()` method, including the data and its content type. ```typescript type GetCIDResponse = { data?: JSON | string | Blob | null; contentType: ContentType; }; type ContentType = | "application/json" | "application/xml" | "text/plain" | "text/html" | "text/css" | "text/javascript" | "application/javascript" | "image/jpeg" | "image/png" | "image/gif" | "image/svg+xml" | "audio/mpeg" | "audio/ogg" | "video/mp4" | "application/pdf" | "application/octet-stream" | string; ``` -------------------------------- ### List All Files Source: https://github.com/pinatacloud/docs/blob/main/sdk/files/public/list.mdx Initializes the Pinata SDK and lists all files in your Pinata account. Ensure your PINATA_JWT environment variable is set. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "example-gateway.mypinata.cloud", }); const files = await pinata.files.public.list() ``` -------------------------------- ### Create Next.js App Source: https://github.com/pinatacloud/docs/blob/main/frameworks/next-js.mdx Initialize a new Next.js project using create-next-app. This is the first step for any Next.js application. ```bash npx create-next-app@latest ``` -------------------------------- ### Get sync status Source: https://github.com/pinatacloud/docs/blob/main/agents/snapshots.mdx Retrieve the synchronization status of the agent's workspace by making a GET request to the sync endpoint. ```APIDOC ## Get sync status The same endpoint with `GET` returns sync status — whether storage is configured, when it last synced, and a human-readable message. ### Method GET ### Endpoint https://agents.pinata.cloud/v0/agents/$AGENT_ID/snapshots/sync ### Headers - Authorization: Bearer $PINATA_JWT ``` -------------------------------- ### Install Pinata SDK with yarn Source: https://github.com/pinatacloud/docs/blob/main/events/hackutd.mdx Install the Pinata SDK using yarn. This command adds the Pinata SDK to your project dependencies. ```bash yarn add pinata ``` -------------------------------- ### Submit Template for Review via CLI Source: https://github.com/pinatacloud/docs/blob/main/agents/templates/creating.mdx Submit a validated template repository for review using its URL. This command initiates the marketplace submission process. ```bash # Submit for review pinata agents templates submit https://github.com/user/my-template ``` -------------------------------- ### Install Pinata SDK with pnpm Source: https://github.com/pinatacloud/docs/blob/main/events/hackutd.mdx Install the Pinata SDK using pnpm. This command adds the Pinata SDK to your project dependencies. ```bash pnpm i pinata ``` -------------------------------- ### Upload Blob Source: https://github.com/pinatacloud/docs/blob/main/files/uploading-files.mdx This example demonstrates how to upload a file by passing a Blob object directly or wrapped in a File object. It shows both the SDK and direct API approaches. ```APIDOC ## Upload Blob ### Description Uploads a file using a Blob or File object. ### Method POST ### Endpoint https://uploads.pinata.cloud/v3/files ### Parameters #### Request Body - **file** (File) - Required - The file to upload. - **network** (string) - Required - The network to upload to (e.g., "public"). ### Request Example (API) ```json { "file": "", "network": "public" } ``` ### Response #### Success Response (200) - **IpfsHash** (string) - The IPFS hash of the uploaded file. - **PinSize** (string) - The size of the pinned file. - **isDuplicate** (boolean) - Indicates if the file was a duplicate. #### Response Example ```json { "IpfsHash": "Qm...", "PinSize": "1234", "isDuplicate": false } ``` ``` -------------------------------- ### Example Usage of predictCID Source: https://github.com/pinatacloud/docs/blob/main/files/uploading-files.mdx Demonstrates how to use the `predictCID` function with a local file. This example requires the `fs` module for reading local files. ```typescript import fs from "fs" const file = new File([fs.readFileSync("path/to-file")], "filename.extension"); const cid = await predictCID(file, 1); console.log(cid); ``` -------------------------------- ### Initialize Pinata SDK and List Files Source: https://github.com/pinatacloud/docs/blob/main/sdk/files/private/list.mdx Initializes the Pinata SDK with your JWT and gateway, then lists all files in your account. Ensure you have your PINATA_JWT environment variable set. ```typescript import { PinataSDK } from "pinata"; const pinata = new PinataSDK({ pinataJwt: process.env.PINATA_JWT!, pinataGateway: "example-gateway.mypinata.cloud", }); const files = await pinata.files.pivate.list() ``` -------------------------------- ### Install Gateway Plugin Source: https://github.com/pinatacloud/docs/blob/main/gateways/plugins/getting-started.mdx Install a specific plugin to your Dedicated Gateway. Requires the gateway ID and the plugin ID. Uses your Pinata JWT for authentication. ```typescript const data = JSON.stringify({ plugin_id: 1 }) const gatewayId = "8673cd80-bf53-4bca-b684-bec1d6bdf004" const installPlugin = await fetch(`https://api.pinata.cloud/v3/ipfs/gateway_plugins/${gatewayId}`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${PINATA_JWT}` }, body: data }) ``` ```json { "data": { "gateway_id": "8673cd80-bf53-4bca-b684-bec1d6bdf004", "plugin_id": 1 } } ```