pinataGateway
Usage
Returns
Returns the data in the form ofJSON, string, or Blob as well as the ContentType
Parameters
cid
- Type:
string
optimizeImage (Optional)
- Type: OptimizeImageOptions
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
org:files:write
pinataGateway
import { PinataSDK } from "pinata";
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT!,
pinataGateway: "example-gateway.mypinata.cloud",
});
const file = await pinata.gateways.private.get("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4")
JSON, string, or Blob as well as the ContentType
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;
stringconst data = await pinata.gateways.private.get(
"bafybeibo5zcqeorhqxczodrx52rn7byyrwfvwthz5dspnjlbkd7zkugefi",
);
type OptimizeImageOptions = {
width?: number;
height?: number;
dpr?: number;
fit?: "scaleDown" | "contain" | "cover" | "crop" | "pad";
gravity?: "auto" | "side" | string;
quality?: number;
format?: "auto" | "webp";
animation?: boolean;
sharpen?: number;
onError?: boolean;
metadata?: "keep" | "copyright" | "none";
};
const data = await pinata.gateways.private
.get("bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4")
.optimizeImage({
width: 500,
height: 500,
format: "webp"
})