{"id":18584421,"url":"https://github.com/ipfs-examples/js-ipfs-traverse-ipld-graphs","last_synced_at":"2025-07-18T00:04:03.164Z","repository":{"id":104999699,"uuid":"376842880","full_name":"ipfs-examples/js-ipfs-traverse-ipld-graphs","owner":"ipfs-examples","description":"Example of resolving IPLD graphs with the dag API using JS-IPFS","archived":false,"fork":false,"pushed_at":"2025-05-01T08:39:25.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-21T17:46:09.847Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ipfs-examples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-14T14:00:01.000Z","updated_at":"2025-05-01T07:35:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"60396e16-c53f-4d84-9054-b0d8b5b4a43d","html_url":"https://github.com/ipfs-examples/js-ipfs-traverse-ipld-graphs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"ipfs-examples/example-fork-go-template","purl":"pkg:github/ipfs-examples/js-ipfs-traverse-ipld-graphs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-examples%2Fjs-ipfs-traverse-ipld-graphs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-examples%2Fjs-ipfs-traverse-ipld-graphs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-examples%2Fjs-ipfs-traverse-ipld-graphs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-examples%2Fjs-ipfs-traverse-ipld-graphs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipfs-examples","download_url":"https://codeload.github.com/ipfs-examples/js-ipfs-traverse-ipld-graphs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-examples%2Fjs-ipfs-traverse-ipld-graphs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265682923,"owners_count":23810768,"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-07T00:27:28.328Z","updated_at":"2025-07-18T00:04:03.140Z","avatar_url":"https://github.com/ipfs-examples.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://js.ipfs.io\" title=\"JS IPFS\"\u003e\n    \u003cimg src=\"https://ipfs.io/ipfs/Qme6KJdKcp85TYbLxuLV7oQzMiLremD7HMoXLZEmgo6Rnh/js-ipfs-sticker.png\" alt=\"IPFS in JavaScript logo\" width=\"244\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003e\u003cb\u003eTraverse IPLD graphs\u003c/b\u003e\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003e\u003ci\u003eResolve through IPLD graphs with the dag API\u003c/i\u003e\u003c/b\u003e\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/jlord/forkngo/gh-pages/badges/cobalt.png\" width=\"200\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://github.com/ipfs/js-ipfs/tree/master/docs\"\u003eExplore the docs\u003c/a\u003e\n  ·\n  \u003ca href=\"https://codesandbox.io/\"\u003eView Demo\u003c/a\u003e\n  ·\n  \u003ca href=\"https://github.com/ipfs-examples/js-ipfs-examples/issues\"\u003eReport Bug\u003c/a\u003e\n  ·\n  \u003ca href=\"https://github.com/ipfs-examples/js-ipfs-examples/issues\"\u003eRequest Feature/Example\u003c/a\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Table of Contents](#table-of-contents)\n- [About The Project](#about-the-project)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation and Running example](#installation-and-running-example)\n- [Usage](#usage)\n  - [IPLD Formats](#ipld-formats)\n  - [create nodes to build a graph](#create-nodes-to-build-a-graph)\n  - [retrieve a node from a graph](#retrieve-a-node-from-a-graph)\n  - [resolve a path in a graph](#resolve-a-path-in-a-graph)\n  - [resolve through graphs of different kind](#resolve-through-graphs-of-different-kind)\n- [traverse through a slice of the ethereum blockchain](#traverse-through-a-slice-of-the-ethereum-blockchain)\n- [traverse through a git repo](#traverse-through-a-git-repo)\n  - [Video of the demos](#video-of-the-demos)\n- [References](#references)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n- [Want to hack on IPFS?](#want-to-hack-on-ipfs)\n\n## About The Project\n\n- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs)\n- Look into other [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser\n- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node\n- Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it\n- Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs\n- Check out https://docs.ipfs.io for tips, how-tos and more\n- See https://blog.ipfs.io for news and more\n- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io\n\n## Getting Started\n\n### Prerequisites\n\nMake sure you have installed all of the following prerequisites on your development machine:\n\n- Git - [Download \u0026 Install Git](https://git-scm.com/downloads). OSX and Linux machines typically have this already installed.\n- Node.js - [Download \u0026 Install Node.js](https://nodejs.org/en/download/) and the npm package manager.\n\n### Installation and Running example\n\n```console\n\u003e npm install\n\u003e npm start\n```\n\n## Usage\n\nIPLD stands for [`InterPlanetary Linked-Data`](https://ipld.io/), it is the data model of the content-addressable web. It gives IPFS the ability to resolve through any kind of content-addressed graph, as long as the [adapter for the format is available](https://github.com/ipld/interface-ipld-format#modules-that-implement-the-interface).\n\nThis tutorial goes through several operations over IPLD graphs using the [DAG API](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core/API/dag).\n\n### IPLD Formats\n\n[IPLD](https://docs.ipld.io/) can read many datatypes, all of which are represented as blocks in the blockstore of your IPFS node. In order to turn a block into a data structure it can use, IPLD uses different codecs to turn `Uint8Arrays` into JavaScript objects and back.\n\nBy default IPFS is bundled with [dag-pb](https://www.npmjs.com/package/ipld-dag-pb), [dag-cbor](https://www.npmjs.com/package/ipld-dag-cbor) and [raw](https://www.npmjs.com/package/ipld-raw) codecs which allow reading UnixFS files and JavaScript objects from the blockstore.\n\nTo configure other types, we must pass the `ipld.formats` option to the `IPFS.create()` function:\n\n```javascript\nimport * as IPFS from 'ipfs'\nimport * as ipldGit from 'ipld-git'\nimport * as ipldZcash from 'ipld-zcash'\nimport * as ipldBitcoin from 'ipld-bitcoin'\nimport * as ipldEth from 'ipld-ethereum'\n\nconst node = await IPFS.create({\n  ipld: {\n    formats: [\n      ipldGit,\n      ipldZcash,\n      ipldBitcoin,\n      ...Object.values(ipldEth), // this format exports multiple codecs so flatten into a list\n      // etc, etc\n    ],\n  },\n});\n```\n\nSee [ipld/interface-ipld-format](https://github.com/ipld/interface-ipld-format) for a list of modules that implement the `ipld-format` interface.\n\n### [create nodes to build a graph](./put.js)\n\n### [retrieve a node from a graph](./get.js)\n\n### [resolve a path in a graph](./get-path.js)\n\n### [resolve through graphs of different kind](./get-path-accross-formats.js)\n\n## [traverse through a slice of the ethereum blockchain](./eth.js)\n\n## [traverse through a git repo](./git.js)\n\nThe example objects contained in \"git-objects\" have already been decompressed with zlib. An example of how to do this:\n\n    $ cat .git/objects/7d/df25817f57c2090a9568cdb17106a76dad7d04 | zlib-flate -uncompress \u003e 7ddf25817f57c2090a9568cdb17106a76dad7d04\n\n### Video of the demos\n\nFind a video with a walkthrough of this examples on Youtube:\n\n[![](https://ipfs.io/ipfs/QmYkeiPtVTR8TdgBNa4u46RvjfnbUFUxSDdb8BqDpqDEer)](https://youtu.be/drULwJ_ZDRQ?t=1m29s)\n\n_For more examples, please refer to the [Documentation](#documentation)_\n\n## References\n\n- Documentation:\n  - [IPFS CONFIG](https://github.com/ipfs/js-ipfs/blob/master/docs/CONFIG.md)\n  - [DAG](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/DAG.md)\n  - [BLOCK](https://github.com/ipfs/js-ipfs/blob/master/docs/core-api/BLOCK.md)\n  - [MULTIFORMATS](https://github.com/multiformats/js-multiformats)\n  - [IPLD](https://github.com/ipfs/js-ipfs/blob/master/docs/IPLD.md)\n- Tutorials:\n  - [Merkle DAGs](https://proto.school/merkle-dags)\n\n## Documentation\n\n- [Config](https://docs.ipfs.io/)\n- [Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api)\n- [Examples](https://github.com/ipfs-examples/js-ipfs-examples)\n- [Development](https://github.com/ipfs/js-ipfs/blob/master/docs/DEVELOPMENT.md)\n- [Tutorials](https://proto.school)\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the IPFS Project\n2. Create your Feature Branch (`git checkout -b feature/amazing-feature`)\n3. Commit your Changes (`git commit -a -m 'feat: add some amazing feature'`)\n4. Push to the Branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## Want to hack on IPFS?\n\n[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)\n\nThe IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:\n\nRead the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md).\n\n- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge\n- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now\n- **Perform code reviews** More eyes will help\n  a. speed the project along\n  b. ensure quality, and\n  c. reduce possible future bugs.\n- **Add tests**. There can never be enough tests.\n- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs-examples%2Fjs-ipfs-traverse-ipld-graphs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipfs-examples%2Fjs-ipfs-traverse-ipld-graphs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs-examples%2Fjs-ipfs-traverse-ipld-graphs/lists"}