{"_id":"@aioznetwork/aioz-pin-sdk","_rev":"2-5ea396c6a329fb5cdd88cc7088bf5e92","name":"@aioznetwork/aioz-pin-sdk","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aioznetwork/aioz-pin-sdk","version":"1.0.0","keywords":["@aioznetwork/aioz-pin-sdk","@aioznetwork","aioz-pin-sdk","pin-sdk","nft-sdk","ipfs-sdk","ipfs","aioz-pin","aioz","aioz-network"],"author":{"name":"aioz"},"license":"ISC","_id":"@aioznetwork/aioz-pin-sdk@1.0.0","maintainers":[{"name":"trieuaioz","email":"trieu.nguyen@aioz.io"},{"name":"phantue99","email":"tue.phan@aioz.io"}],"dist":{"shasum":"a70446a707e7aed3605d5b9cb982ccf1b2184702","tarball":"https://registry.npmjs.org/@aioznetwork/aioz-pin-sdk/-/aioz-pin-sdk-1.0.0.tgz","fileCount":149,"integrity":"sha512-zOXKK5j6bR3iHziDJx53Im3ax6AqeeH8BuCNYucno8opsJnUvycO0UPh8hjpykEcfOx8xONfeo5PnifmpMxQNQ==","signatures":[{"sig":"MEQCIB4L5YCfnrN1JPSiYBDPfArz+xnVGVgl3Y/lvGPTrZm+AiA0T9gkeTRopvB26y3Qc64t2dnkVUU0M8vBY2FC/z5vgg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":197136},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","module":"dist/index.js","engines":{"node":">=16.0.0"},"gitHead":"a5d952147d9ccf92ec1e5952b388ec731c6af225","private":false,"scripts":{"pub":"build && npm publish --access public","build":"rm -rf dist/ && npm run build:esm","watch":"concurrently \"tsc  -w\" \"tsc-alias -w\"","build:esm":"tsc"},"_npmUser":{"name":"phantue99","email":"tue.phan@aioz.io"},"_npmVersion":"10.2.3","description":"Experience seamless file management on our IPFS host with our SDK. Utilize API keys to effortlessly pin, unpin, retrieve, and securely access files through the gateway, ensuring efficient and secure file operations. Simplify decentralized file management ","directories":{},"_nodeVersion":"18.19.0","dependencies":{"uuid":"^9.0.0","axios":"^1.4.0","husky":"^8.0.3","is-ipfs":"6.0.2","ipfs-car":"^1.2.0","@ipld/car":"^3.2.3","crypto-js":"^4.2.0","concurrently":"^8.2.2","multiformats":"^13.1.0","uint8arraylist":"^2.3.2","blockstore-core":"1.0.5","ipfs-unixfs-importer":"^9.0.10"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.1.0","tsc-alias":"^1.8.8","typescript":"^5.3.3","@babel/core":"^7.24.7","@types/node":"^20.12.12","@types/uuid":"^9.0.1","@types/crypto-js":"^4.2.2","@babel/preset-env":"^7.24.7","@babel/preset-typescript":"^7.24.7","babel-plugin-transform-commonjs":"^1.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aioz-pin-sdk_1.0.0_1740109628532_0.5918228459704669","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aioznetwork/aioz-pin-sdk","version":"1.0.1","description":"Experience seamless file management on our IPFS host with our SDK. Utilize API keys to effortlessly pin, unpin, retrieve, and securely access files through the gateway, ensuring efficient and secure file operations. Simplify decentralized file management ","keywords":["@aioznetwork/aioz-pin-sdk","@aioznetwork","aioz-pin-sdk","pin-sdk","nft-sdk","ipfs-sdk","ipfs","aioz-pin","aioz","aioz-network"],"type":"module","module":"dist/index.js","main":"dist/index.js","author":{"name":"aioz"},"license":"ISC","scripts":{"watch":"concurrently \"tsc  -w\" \"tsc-alias -w\"","build":"rm -rf dist/ && npm run build:esm","pub":"npm publish --access public","build:esm":"tsc"},"dependencies":{"@ipld/car":"^3.2.3","axios":"^1.4.0","blockstore-core":"1.0.5","concurrently":"^8.2.2","crypto-js":"^4.2.0","husky":"^8.0.3","ipfs-car":"^1.2.0","ipfs-unixfs-importer":"^9.0.10","is-ipfs":"6.0.2","multiformats":"^13.1.0","uint8arraylist":"^2.3.2","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.24.7","@babel/preset-env":"^7.24.7","@babel/preset-typescript":"^7.24.7","@types/crypto-js":"^4.2.2","@types/node":"^20.12.12","@types/uuid":"^9.0.1","babel-plugin-transform-commonjs":"^1.1.6","tsc-alias":"^1.8.8","tsup":"^8.1.0","typescript":"^5.3.3"},"engines":{"node":">=16.0.0"},"_id":"@aioznetwork/aioz-pin-sdk@1.0.1","gitHead":"10bbc3ef8db012c505949cef570fa6c59f534b01","types":"./dist/index.d.ts","_nodeVersion":"22.14.0","_npmVersion":"11.5.2","dist":{"integrity":"sha512-Nkmf+AJn/aYkb3OrrfrABPUI2YBOWRwomZ5rkgO19jOhVfjuiQ2Pu7hmWObaffzPR3lmvlp0nLAqkYH12BJHlg==","shasum":"aa2f240940bfb402fcb12d2091c05e4116fecba7","tarball":"https://registry.npmjs.org/@aioznetwork/aioz-pin-sdk/-/aioz-pin-sdk-1.0.1.tgz","fileCount":153,"unpackedSize":212097,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDPK2Zh8KyHjoUejF10zv5/8m6RbetRYsIsqNtBxjGfBQIgQ30pEKuY6uNYQSIfNkIwNTWb+Yff93Qd2Mjm4Y13pxw="}]},"_npmUser":{"name":"phantue99","email":"tue.phan@aioz.io"},"directories":{},"maintainers":[{"name":"trieuaioz","email":"trieu.nguyen@aioz.io"},{"name":"phantue99","email":"tue.phan@aioz.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/aioz-pin-sdk_1.0.1_1768895715835_0.9488705685003129"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-21T03:47:08.472Z","modified":"2026-01-20T07:55:16.100Z","1.0.0":"2025-02-21T03:47:08.784Z","1.0.1":"2026-01-20T07:55:15.964Z"},"author":{"name":"aioz"},"license":"ISC","keywords":["@aioznetwork/aioz-pin-sdk","@aioznetwork","aioz-pin-sdk","pin-sdk","nft-sdk","ipfs-sdk","ipfs","aioz-pin","aioz","aioz-network"],"description":"Experience seamless file management on our IPFS host with our SDK. Utilize API keys to effortlessly pin, unpin, retrieve, and securely access files through the gateway, ensuring efficient and secure file operations. Simplify decentralized file management ","maintainers":[{"name":"trieuaioz","email":"trieu.nguyen@aioz.io"},{"name":"phantue99","email":"tue.phan@aioz.io"}],"readme":"# AIOZ Pin SDK\n\n## Description\n\nExperience seamless file management on our IPFS host with our SDK. Utilize API keys to effortlessly pin, unpin, retrieve, and securely access files through the gateway, ensuring efficient and secure file operations. Simplify decentralized file management with ease and confidence.\n\n## Documentation\n\nFor comprehensive documentation and API references, visit:\n- [AIOZ Pin API Documentation](https://aiozpin.network/docs/aioz-pin-api)\n\n## Installation\n\n```\nnpm install aioz-pin-sdk\n```\n\n## Setup\n\nTo start, simply require the AIOZ Pin SDK and set up an instance with your AIOZ Pin API Keys or your JWT key. Don't know what your keys are? Check out your [Account Page](https://aiozpin.network/dashboard/api-keys).\n\nFor more information about the SDK and API, refer to the [AIOZ Pin Documentation](https://aiozpin.network/docs).\n\nIn the example below we provided with 2 ways to call the AIOZ Pin SDK.\n\n```javascript\n// Use the api keys by providing the strings directly\nimport AiozPinClient from 'aioz-pin-sdk'\nconst client = new AiozPinClient('key', 'secret-key')\n```\n\nQuickly test that you can connect to the API with the following call:\n\n```javascript\nclient\n  .testAuthentication()\n  .then((result) => {\n    //handle successful authentication here\n    console.log(result)\n  })\n  .catch((err) => {\n    //handle error here\n    console.log(err)\n  })\n```\n\n## Usage\n\nOnce you've set up your instance, using the AIOZ Pin SDK is easy. Simply call your desired function and handle the results of the promise.\n\n- Pinning\n\n  - [pinByHash](#pinByHash)\n  - [pinFilesToIPFS](#pinFilesToIPFS)\n  - [pinFolderToIPFS](#pinFolderToIPFS)\n  - [unpin](#unpin)\n\n- Nft\n\n  - [pinNft](#pinNft)\n  - [pinNftByHash](#pinNftByHash)\n  - [unpinNft](#unpinNft)\n\n- Data\n  - [testAuthentication](#testAuthentication)\n  - [getPinList](#getPinList)\n  - [getPinByID](#getPinByID)\n  - [getPinByCID](#getPinByCID)\n  - [optimizeImage](#optimizeImage)\n    <br />\n\n<a id=\"pinByHash\"></a>\n\n### `pinByHash`\n\nThe request body when pin a file by CID will look like this:&#x20;\n\n```\n{\n    hash_to_pin: CID,\n    metadata: {\n        name: string,\n        keyvalues: {\n            key1: value1,\n            key2: value2\n        }\n    }\n}\n```\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"file_record_id\": \"string\",\n        \"root_hash\": \"string\",\n        \"cid\": \"string\",\n        \"user_id\": \"string\",\n        \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n        \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": false,\n        \"is_pin_by_hash\": true,\n        \"is_dir\": false,\n        \"metadata\": {\n            \"name\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nclient\n  .pinByHash({\n    hashToPin: 'bafyb...2goq',\n    options: {\n      metadata: {\n        name: 'bafyb...2goq',\n        keyvalues: {\n          description1: 'this is description1',\n          description2: 'this is description2',\n        },\n      },\n    },\n  })\n  .then((res) => console.log({ res }))\n  .catch((err) => console.log({ err }))\n```\n\n<a id=\"pinFilesToIPFS\"></a>\n\n### `pinFilesToIPFS`\n\nThis API allows you to pin a files to IPFS using the provided pinning API key and secret key.\n\nExample metadata:\n\n```\n{\"name\": \"sample name\", \"keyvalues\":{\"key1\": \"value1\",\"key2\": \"value2\"}}\n```\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"file_record_id\": \"string\",\n        \"root_hash\": \"string\",\n        \"cid\": \"string\",\n        \"user_id\": \"string\",\n        \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n        \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": false,\n        \"is_pin_by_hash\": false,\n        \"sub_hash_status\": \"string\",\n        \"is_dir\": false,\n        \"metadata\": {\n            \"name\": \"string\",\n            \"type\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nimport path, { dirname } from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nconst filePath01 = path.join(__dirname, '../assets/file.txt')\nconst filePath02 = path.join(__dirname, '../assets/sample.json')\n\nclient\n  .pinFilesToIPFS({\n    filePaths: [filePath01, filePath02],\n    options: {\n      metadata: {\n        name: 'pin name',\n        keyvalues: {\n          description: 'This is a ipfs files',\n        },\n      },\n    },\n  })\n  .then((res) => console.log({ res }))\n  .catch((err) => console.log({ err }))\n```\n\n<a id=\"pinFolderToIPFS\"></a>\n\n### `pinFolderToIPFS`\n\nThis API allows you to pin a folder to IPFS using the provided pinning API key and secret key.\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"file_record_id\": \"string\",\n        \"root_hash\": \"string\",\n        \"cid\": \"string\",\n        \"user_id\": \"string\",\n        \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n        \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": false,\n        \"is_pin_by_hash\": false,\n        \"sub_hash_status\": \"string\",\n        \"is_dir\": true,\n        \"metadata\": {\n            \"name\": \"string\",\n            \"type\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n---\n\n**NOTE**\nThe `depth` parameter in the `pinFolderToIPFS` function dictates the pinning behavior for files and subdirectories within the specified folder.\n\n- When `depth` is set to `all`, all files within the folder and its subdirectories will be pinned.\n- Setting `depth` to `0` will directly pin files within the specified folder without considering its subdirectories.\n- If `depth` is set to `1`, only one level of subdirectories will be pinned along with the files within the main folder.\n\nEnsure to adjust the `depth` parameter based on your desired pinning depth.\n\n```javascript\nconst folderPath = 'c:/users/pin/folder'\n\nclient\n  .pinFolderToIPFS({\n    depth: 'all',\n    sourcePath: folderPath,\n    options: {\n      metadata: {\n        name: 'pin-name',\n        keyvalues: {\n          description: 'This is a folder',\n        },\n      },\n    },\n  })\n  .then((res) => console.log({ res }))\n  .catch((err) => console.log({ err }))\n```\n\n<a id=\"unpin\"></a>\n\n### `unpin`\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"file_record_id\": \"string\",\n        \"root_hash\": \"string\",\n        \"cid\": \"string\",\n        \"size\": number,\n        \"user_id\": \"string\",\n        \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n        \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": true,\n        \"is_pin_by_hash\": true,\n        \"is_dir\": false,\n        \"metadata\": {\n            \"name\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nclient\n  .unpin('file-id')\n  .then((result) => {\n    //handle results here\n    console.log(result)\n  })\n  .catch((err) => {\n    //handle error here\n    console.log(err)\n  })\n```\n\n<a id=\"pinNft\"></a>\n\n### `pinNft`\n\nThe metadata JSON file will look like this:\n\n```\n{\n    \"name\": \"My Awesome NFT\",\n    \"description\": \"This is an NFT that represents my creativity as a digital artist!\",\n    \"properties\": [\n        {\n            \"trait_type\": \"Color\",\n            \"value\": \"Red\"\n        },\n        {\n            \"trait_type\": \"Rarity\",\n            \"value\": \"Medium\"\n        }\n    ]\n}\n```\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"asset_cid\": \"string\",\n        \"metadata_cid\": \"string\",\n        \"asset_pin_id\": \"string\",\n        \"metadata_pin_id\": \"string\",\n        \"size\": number,\n        \"user_id\": \"string\",\n        \"created_at\": \"2023-01-01T11:11:11.111111Z\",\n        \"updated_at\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": true,\n        \"metadata_asset\": {\n            \"name\": \"string\",\n            \"type\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nimport * as fs from 'fs'\nimport path, { dirname } from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nconst imagePath = path.join(__dirname, './file.txt')\nconst metadataPath = path.join(__dirname, './sample.json')\n\nconst readableStreamForFile = fs.createReadStream(imagePath)\nconst readableStreamMetadataFile = fs.createReadStream(metadataPath)\n\n// pin Nft by metadata object\nclient.pinNft({\n  fileStream: readableStreamForFile,\n  metadata: {\n    name: 'test',\n    description: 'test',\n    properties: [\n      {\n        trait_type: 'Color',\n        value: 'Red',\n      },\n      {\n        trait_type: 'Size',\n        value: 'M',\n      },\n    ],\n  },\n})\n\n// pin Nft by file.json\nclient\n  .pinNftByStreamMetadata({\n    fileStream: readableStreamForFile,\n    metadataStream: readableStreamMetadataFile,\n  })\n  .then((res) => console.log({ res }))\n  .catch((err) => console.log({ err }))\n```\n\n<a id=\"pinNftByHash\"></a>\n\n### `pinNftByHash`\n\nThe metadata JSON file will look like this:\n\n```\n{\n    \"name\": \"My Awesome NFT\",\n    \"description\": \"This is an NFT that represents my creativity as a digital artist!\",\n    \"properties\": [\n        {\n            \"trait_type\": \"Color\",\n            \"value\": \"Red\"\n        },\n        {\n            \"trait_type\": \"Rarity\",\n            \"value\": \"Medium\"\n        }\n    ]\n}\n```\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"asset_cid\": \"string\",\n        \"metadata_cid\": \"string\",\n        \"asset_pin_id\": \"string\",\n        \"metadata_pin_id\": \"string\",\n        \"size\": number,\n        \"user_id\": \"string\",\n        \"created_at\": \"2023-01-01T11:11:11.111111Z\",\n        \"updated_at\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": true,\n        \"metadata_asset\": {\n            \"name\": \"string\",\n            \"type\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nimport * as fs from 'fs'\nimport path, { dirname } from 'path'\nimport { fileURLToPath } from 'url'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\nconst filePath = path.join(__dirname, '../assets/sample.json')\nconst readableStreamMetadataFile = fs.createReadStream(filePath)\n\nclient\n  .pinNftByHash({\n    hashToPin: 'bafkr...w7m',\n    metadata: {\n      name: 'My Awesome NFT',\n      description: 'This is an NFT that represents my creativity as a digital artist!',\n      properties: [\n        {\n          trait_type: 'Color',\n          value: 'Red',\n        },\n        {\n          trait_type: 'Rarity',\n          value: 'Medium',\n        },\n      ],\n    },\n  })\n  .then((res) => console.log({ res }))\n  .catch((err) => console.log({ err }))\n\n// pin nft by hash with metadata stream\nclient\n  .pinNftByHashAndMetadataStream({\n    hashToPin: 'bafk...f73u',\n    metadataStream: readableStreamMetadataFile,\n  })\n  .then((res) => console.log({ res }))\n  .catch((err) => console.log({ err }))\n```\n\n<a id=\"unpinNft\"></a>\n\n### `unpinNft`\n\n##### Example Code\n\n```javascript\nclient\n  .unpinNft('nft-id')\n  .then((result) => {\n    //handle results here\n    console.log(result)\n  })\n  .catch((err) => {\n    //handle error here\n    console.log(err)\n  })\n```\n\n<a id=\"testAuthentication\"></a>\n\n### `testAuthentication`\n\n#### Response\n\n```json\n{\n  \"message\": \"Congratulations! You are communicating with the Web3 IPFS API!\"\n}\n```\n\n##### Example Code\n\n```javascript\nclient\n  .testAuthentication()\n  .then((result) => {\n    //handle successful authentication here\n    console.log(result)\n  })\n  .catch((err) => {\n    //handle error here\n    console.log(err)\n  })\n```\n\n<a id=\"getPinList\"></a>\n\n### `getPinList`\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"totals\": {\n            \"files\": number,\n            \"size\": number\n        },\n        \"pins\": [\n            {\n                \"id\": \"string\",\n                \"file_record_id\": \"string\",\n                \"root_hash\": \"string\",\n                \"cid\": \"string\",\n                \"size\": number,\n                \"user_id\": \"string\",\n                \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n                \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n                \"pinned\": true,\n                \"is_pin_by_hash\": true,\n                \"sub_hash_status\": \"string\",\n                \"is_dir\": false,\n                \"metadata\": {\n                    \"name\": \"string\"\n                },\n                \"status\": \"string\"\n            }\n        ]\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nclient\n  .getPinList({\n    offset: 0,\n    limit: 10,\n    pinned: 'true',\n    sortBy: 'size',\n    sortOrder: 'DESC',\n    metadata: {\n      keyvalues: {\n        bbbn: '',\n      },\n    },\n  })\n  .then((result: PinListResponse) => {\n    console.log({ result: result.data })\n  })\n  .catch((error) => {\n    console.log(error)\n  })\n```\n\n<a id=\"getPinByID\"></a>\n\n### `getPinByID`\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"file_record_id\": \"string\",\n        \"root_hash\": \"string\",\n        \"cid\": \"string\",\n        \"size\": number,\n        \"user_id\": \"string\",\n        \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n        \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": true,\n        \"is_pin_by_hash\": true,\n        \"sub_hash_status\": \"string\",\n        \"is_dir\": false,\n        \"metadata\": {\n            \"name\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nclient\n  .getPinByID('pin id')\n  .then((result) => {\n    console.log({ result })\n  })\n  .catch((error) => {\n    console.log(error)\n  })\n```\n\n<a id=\"getPinByCID\"></a>\n\n### `getPinByCID`\n\n#### Response\n\n```\n{\n    \"data\": {\n        \"id\": \"string\",\n        \"file_record_id\": \"string\",\n        \"root_hash\": \"string\",\n        \"cid\": \"string\",\n        \"size\": number,\n        \"user_id\": \"string\",\n        \"date_pinned\": \"2023-01-01T11:11:11.111111Z\",\n        \"date_unpinned\": \"2023-11-11T11:11:11.111111Z\",\n        \"pinned\": true,\n        \"is_pin_by_hash\": true,\n        \"sub_hash_status\": \"string\",\n        \"is_dir\": false,\n        \"metadata\": {\n            \"name\": \"string\"\n        },\n        \"status\": \"string\"\n    },\n    \"status\": \"success\"\n}\n```\n\n##### Example Code\n\n```javascript\nclient\n  .getPinByCID('bafy...')\n  .then((result) => {\n    //handle results here\n    console.log(result)\n  })\n  .catch((err) => {\n    //handle error here\n    console.log(err)\n  })\n```\n\n<a id=\"optimizeImage\"></a>\n\n### `optimizeImage`\n\nThis API allows you to optimize images stored on IPFS by fetching them through a gateway with various image transformation options. The optimized image is returned as binary data.\n\n**Reference:** [Image Optimization Documentation](https://aiozpin.network/docs/aioz-pin-api/image-optimization)\n\n**Note:** At least one option must be specified in the `config` parameter for the optimization feature to activate.\n\n#### Response\n\nReturns binary image data (ArrayBuffer when `responseType: 'arraybuffer'` is set in `axiosConfig`).\n\n##### Example Code\n\n**Basic usage:**\n\n```javascript\nclient\n  .optimizeImage({\n    cid: 'YOUR CID',\n    gatewayProviderUrl: 'GATEWAY URL',\n    config: {\n      imgWidth: 800,\n      imgQuality: 75,\n      imgFit: 'cover',\n      imgGravity: '0.5x0.5',\n    },\n    axiosConfig: {\n      responseType: 'arraybuffer',\n    },\n  })\n  .then((result) => {\n    // result is an ArrayBuffer containing the optimized image\n    const buffer = Buffer.from(result)\n    console.log(`Image size: ${buffer.length} bytes`)\n  })\n  .catch((error) => {\n    console.log(error)\n  })\n```\n\n**Saving optimized image to file:**\n\n```javascript\nimport { writeFileSync } from 'fs'\nimport { join } from 'path'\n\nclient\n  .optimizeImage({\n    cid: 'YOUR CID',\n    gatewayProviderUrl: 'GATEWAY URL',\n    config: {\n      imgWidth: 800,\n      imgQuality: 100,\n      imgFit: 'cover',\n    },\n    axiosConfig: {\n      responseType: 'arraybuffer',\n    },\n  })\n  .then((result) => {\n    // Convert ArrayBuffer to Buffer for file writing\n    const buffer = Buffer.from(result)\n    \n    // Save the file\n    const outputPath = join(process.cwd(), 'optimized-image.jpg')\n    writeFileSync(outputPath, buffer)\n    \n    console.log(`Image saved successfully to: ${outputPath}`)\n    console.log(`File size: ${buffer.length} bytes`)\n  })\n  .catch((error) => {\n    console.log(error)\n  })\n```\n\n**Advanced configuration example:**\n\n```javascript\nclient\n  .optimizeImage({\n    cid: 'YOUR CID',\n    gatewayProviderUrl: 'GATEWAY URL',\n    config: {\n      imgWidth: 1920,\n      imgHeight: 1080,\n      imgFit: 'crop',\n      imgGravity: '0.5x0.5',\n      imgQuality: 90,\n      imgDpr: 2,\n      imgFormat: 'webp',\n      imgAnim: false,\n      imgSharpen: 5,\n      imgMetadata: 'copyright',\n      imgOnError: 'redirect',\n    },\n    axiosConfig: {\n      responseType: 'arraybuffer',\n    },\n  })\n  .then((result) => {\n    // Handle the optimized image\n    console.log('Image optimized successfully')\n  })\n  .catch((error) => {\n    console.log(error)\n  })\n```\n\n\n\n","readmeFilename":"README.md"}