# With IPFS, why need libp2p?

**URL:** <https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935>\
**Category:** Uncategorized\
**Created:** [December 30, 2019, 9:22pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935 "2019-12-30T21:22:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![emclab](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/emclab/32/3432_2.png) [@emclab](https://discuss.ipfs.tech/u/emclab)\
**Post date:** [December 30, 2019, 9:22pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/1 "2019-12-30T21:22:35Z")

</div>

I have read some online posts and document about IPFS. My understanding of IPFS is that IPFS is a content addressed distributed file system storing chunk of files on peers on the network. Then I came across libp2p which is confusing me a little bit. My understanding is that libp2p is a library allowing a node device do something (connecting, communicating and such) with peers on IPFS network. My question is that if I can use IPFS to manage files with its CID, then why do I need to use libp2p for the same purpose? Is libp2p providing more fine-tuned way to do the same as IPFS node does?

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [December 30, 2019, 9:31pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/2 "2019-12-30T21:31:19Z")

</div>

libp2p is used for 2 thing, dht (finding other peer and who host the file without any central server (replacing tracker in torrent)) and contacting people, IPFS doesn’t deal with tcp, udp, … so if a new thing is out it should be simpler to add it to IPFS (since nothing is needed in IPFS). (Security and multiplexing (talking of multiple thing over a signle connection)) is handled by libp2p.

Shortly IPFS and IPLD is the file part, libp2p is the network part.

---

<div class="post-metadata">

**Author:** ![emclab](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/emclab/32/3432_2.png) [@emclab](https://discuss.ipfs.tech/u/emclab)\
**Post date:** [December 31, 2019, 3:25am UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/3 "2019-12-31T03:25:46Z")

</div>

Thanks for the info. If I want to create a IPFS node programmatically, then libp2p should do it, shouldn’t it?

---

<div class="post-metadata">

**Author:** ![emclab](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/emclab/32/3432_2.png) [@emclab](https://discuss.ipfs.tech/u/emclab)\
**Post date:** [December 31, 2019, 3:54am UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/4 "2019-12-31T03:54:16Z")

</div>

So programmatically I would call IPFS api for breaking up file and CID and libp2p for anything about sending the file chunks to peers for storage.

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [December 31, 2019, 9:22pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/5 "2019-12-31T21:22:33Z")

</div>

No, IPFS would call libp2p by it self, I’m not even sure if you can create programmatically an IPFS nodes with a custom libp2p one yet.

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [December 31, 2019, 9:24pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/6 "2019-12-31T21:24:15Z")

</div>

To continue comparison, sending a mail programmatically you just call your mail server through its API and the mail server does the SMTP stuff it self.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [January 2, 2020, 9:50am UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/7 "2020-01-02T09:50:30Z")

</div>

Hi,

you have an example on how to create an IPFS node programatically:

- [https://github.com/ipfs/go-ipfs/tree/master/docs/examples/go-ipfs-as-a-library](https://github.com/ipfs/go-ipfs/tree/master/docs/examples/go-ipfs-as-a-library)

The underlying libp2p host is used to setup a few libp2p services as needed by IPFS to do what IPFS does, so there is no need to do things with it and the IPFS APIs offer all the IPFS functionality. Now, if you wanted to add additional p2p services or functionalities you would maybe need to interact with the libp2p host directly (I’m pretty sure some method exposes it).

Also, [https://github.com/hsanjuan/ipfs-lite](https://github.com/hsanjuan/ipfs-lite) allows to create a simpler programmatic “node” (stripped down of much functionality) and explicitally asks you to pass the libp2p host you want to use.

For examples on how to create libp2p hosts etc, there is: [https://github.com/libp2p/go-libp2p-examples](https://github.com/libp2p/go-libp2p-examples)

(I’m assuming we are talking about go-implementations. The Javascript side of things should be similar though).

---

<div class="post-metadata">

**Author:** ![emclab](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/emclab/32/3432_2.png) [@emclab](https://discuss.ipfs.tech/u/emclab)\
**Post date:** [January 2, 2020, 6:31pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/8 "2020-01-02T18:31:20Z")

</div>

Hector, Jorropo,

Thank you for the info and they are helpful. I use Javascript if I can. I am new to both IPFS and libp2p and some of my questions may be obvious to you guys.

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [January 3, 2020, 11:03pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/9 "2020-01-03T23:03:08Z")

</div>

Absolutly no problem, I think the docs should be reworked, they seems very good when knowing how evrythings works but I remember having trouble when starting with it.

---

<div class="post-metadata">

**Author:** ![Akita](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/akita/32/2650_2.png) [@Akita](https://discuss.ipfs.tech/u/Akita)\
**Post date:** [January 3, 2020, 11:06pm UTC](https://discuss.ipfs.tech/t/with-ipfs-why-need-libp2p/6935/10 "2020-01-03T23:06:41Z")

</div>

Docs are being rewrote and there will be a new version soon (2 or 3 weeks). You can see a preview here:

> **[How-tos](https://docs-beta.ipfs.io/how-to/)**
>
> Hands-on guides to using and developing with IPFS to build decentralized web apps and services.
