Verify content with api /dag/export

Hey! I need to consume the IPFS http api endpoint /api/v0/dag/export (HTTP API | IPFS Docs) to verify content hash from an IPFS gateway. Which JS tooling do I need to use and what would be the best way to implement it?

you can use: GitHub - olizilla/ipfs-get: Get and verify a file by CID from an IPFS gateway over http
it’ll fetch a content-addressed archive from /api/v0/dag/export and write the files to disk.

Or there is GitHub - web3-storage/ipfs-car: Convert files to content-addressable archives and back
which gives you pack and unpack functions you can use in your apps to pack files in to content addressed archives or unpack them back to the source files.

If you want to work with IPLD data that isn’t dag-pb unixfs (e.g not files you `ipfs add’ed) then check out the wonderful GitHub - ipld/js-car: Content Addressable aRchive format reader and writer for JavaScript which provides the foundations for the previous two modules.

1 Like

Thank you so much for the answer! I have been taking a look and seems like it is what I need. Anyway I still do not found how can I recreate the CID from the CAR content so I can verify the content source.

This is what I have:

  1. Get CAR with: Fetch /dag/export/arg=Qme…

  2. Unpack CAR with ipfs car library

  3. Recreate CID with the CAR content ??