{"id":20954298,"url":"https://github.com/pinatacloud/ipfs-gateway-tools","last_synced_at":"2025-05-14T04:32:30.870Z","repository":{"id":42123276,"uuid":"360973884","full_name":"PinataCloud/ipfs-gateway-tools","owner":"PinataCloud","description":"A toolkit for working with IPFS gateways and CIDs","archived":false,"fork":false,"pushed_at":"2022-11-11T01:59:25.000Z","size":1020,"stargazers_count":61,"open_issues_count":4,"forks_count":19,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-15T22:17:44.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PinataCloud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-23T18:31:15.000Z","updated_at":"2024-10-29T17:56:25.000Z","dependencies_parsed_at":"2022-09-01T03:01:06.786Z","dependency_job_id":null,"html_url":"https://github.com/PinataCloud/ipfs-gateway-tools","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinataCloud%2Fipfs-gateway-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinataCloud%2Fipfs-gateway-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinataCloud%2Fipfs-gateway-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PinataCloud%2Fipfs-gateway-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PinataCloud","download_url":"https://codeload.github.com/PinataCloud/ipfs-gateway-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225275661,"owners_count":17448389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T01:14:04.204Z","updated_at":"2024-11-19T01:14:05.062Z","avatar_url":"https://github.com/PinataCloud.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IPFS Gateway Tools\n\nIPFS Gateway Tools\n\n## Overview\n\nThis toolkit contains helper functions for working with IPFS gateway URLs and transforming them as desired.\n\nThis package comes with a distributions for the browser and for NodeJS. Take care to ensure you are importing or requiring in the right version.\n\n## Installation\n\n```\nnpm install --save @pinata/ipfs-gateway-tools\n```\n\n## Browser Setup\n\nTo require this in your project simply include the library at the top of your file like so:\n\n```javascript\nimport IPFSGatewayTools from \"@pinata/ipfs-gateway-tools/dist/browser\";\nconst gatewayTools = new IPFSGatewayTools();\n```\n\n## NodeJS Setup\n\n```javascript\nconst IPFSGatewayTools = require(\"@pinata/ipfs-gateway-tools/dist/node\");\nconst gatewayTools = new IPFSGatewayTools();\n```\n\n## Usage\n\nThe IPFS gateway toolkit currently contains the following functions:\n\n- [containsCID](#containsCID-anchor)\n- [convertToDesiredGateway](#convertToDesiredGateway-anchor)\n\n\u003ca name=\"containsCID-anchor\"\u003e\u003c/a\u003e\n\n### containsCID\n\n##### `ipfsGatewayTools.containsCID(url)`\n\n##### Params\n\n- `url` - A gateway url that should take one of the following forms:\n  - `ipfs://CID`\n  - `ipfs://ipfs/CID`\n  - `https://example-gateway.com/ipfs/CID`\n  - `https://example-gateway.com/ipfs/CID/exampleFile.json`\n  - `https://example-gateway.com/ipns/CID`\n\n#### Response\n\n```\n{\n    containsCid: (Boolean) - True if the url contains a CID,\n    cid: (string) - The CID that the url contains if \"containsCid\" is true\n}\n```\n\n\u003ca name=\"convertToDesiredGateway-anchor\"\u003e\u003c/a\u003e\n\n### convertToDesiredGateway\n\n##### `ipfsGatewayTools.convertToDesiredGateway(sourceUrl, desiredGatewayPrefix)`\n\n##### Params\n\n- `sourceUrl` - A gateway url that should take one of the following forms:\n  - `ipfs://CID`\n  - `ipfs://ipfs/CID`\n  - `https://example-gateway.com/ipfs/CID`\n  - `https://example-gateway.com/ipfs/CID/exampleFile.json`\n  - `https://example-gateway.com/ipns/CID`\n- `desiredGatewayPrefix` - The desired gateway you want to convert your source URL to. A few examples of this would be:\n  - `https://mygateway.mypinata.cloud`\n  - `https://ipfs.io`\n\n#### Response\n\nReturns a string that uses the desired source gateway prefix.\n\nExample code:\n\n```javascript\nconst sourceUrl =\n  \"https://exampleGateway.com/ipfs/bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m\";\nconst desiredGatewayPrefix = \"https://mygateway.mypinata.cloud\";\nconst convertedGatewayUrl = ipfsGatewayTools.convertToDesiredGateway(\n  sourceUrl,\n  desiredGatewayPrefix\n);\n\n//In the example above, the resulting value for convertedGatewayUrl would be: https://mygateway.mypinata.cloud/ipfs/bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m\n```\n\n## Questions? Issues? Suggestions?\n\nFeel free to file a github issue or email us at team@pinata.cloud\n\nWe'd love to hear from you!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinatacloud%2Fipfs-gateway-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinatacloud%2Fipfs-gateway-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinatacloud%2Fipfs-gateway-tools/lists"}