Unpin a CID from your Infura IPFS account using the kubo-rpc-clinet and nodejs

Hello everyone,

The kubo-rpc-client Javascript library can be used to unpin a CID which is no longer needed from your Infura IPFS account. Keep in mind that after unpinning a particular CID, the content is not automatically deleted from the IPFS network, but will be removed after all unpinned data is garbage collected from time to time.

In order to unpin a CID from your Infura account follow the next steps:

Install the library from the official kubo-rpc-client repository. Note that if you’ve previously used the ipfs-http-client to unpin content from IPFS, it was deprecated and we recommend using the kubo client going forward.
Declare the IPFS client and use the below piece of code in order to remove the no longer needed CID from your Infura IPFS account.
Don’t forget to use your Project ID and Project Secret.

Also keep in mind that the kubo client can only be imported as a module, so for simplicity save the below piece of code as an mjs file, index.mjs for example, before running it in node .

import { create, CID } from 'kubo-rpc-client'
const projectId = '27h....xxxx....Rsj';
const projectSecret = '205....xxxx.....15b';

async function rmCid(){
    const auth =
      'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')
    const client = await create({
        host: 'ipfs.infura.io',
        port: 5001,
        protocol: 'https',
        headers: {
          authorization: auth

      for await (const cid of client.pin.rmAll(CID.parse('bafybeibhz7a5mnbs2s5lkakppq3a3qrfigjlg5wndnxgdvx55mig26ohsi'))) {


Following a successful unpin the removed CID is printed in your output window.