# Access ipld block through gateway

**URL:** <https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033>\
**Category:** Uncategorized\
**Created:** [April 24, 2021, 1:01pm UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033 "2021-04-24T13:01:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludwigschubi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/ludwigschubi/32/4953_2.png) [@ludwigschubi](https://discuss.ipfs.tech/u/ludwigschubi)\
**Post date:** [April 24, 2021, 1:01pm UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033/1 "2021-04-24T13:01:44Z")

</div>

Hello ipfs-newbie here, I have a question in regards to accessing/distributing the cid of ipld blocks created with:

```javascript
import Block from "@ipld/block/defaults";

const block = Block.encoder(obj, "dag-cbor");
const data = block.encode();
const cid = await block.cid();

// js-ipfs uses an older CID value type so we must convert to string
await ipfs.block.put(data, { cid: cid.toString() });

```

how can i resolve the bafy hash cid through a gateway ([similar to this question](https://discuss.ipfs.tech/t/accessing-dag-objects-via-the-gateway/2072)) / how can i use dnslink to map a human readable url to the cid?

---

<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:** [April 26, 2021, 11:03am UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033/2 "2021-04-26T11:03:42Z")

</div>

Technically you can access using the Read API. ie:

[https://dweb.link/api/v0/dag/get?arg=QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n](https://dweb.link/api/v0/dag/get?arg=QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n)

(also `block/get`).

I don’t think you can DNS-link this as the gateway endpoint itself seems to only like dag-pb/unixfs DAGs.

---

<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:** [April 26, 2021, 11:25am UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033/3 "2021-04-26T11:25:57Z")

</div>

There is work related to make dag-cbor accessible: [feat: serve CBOR encoded DAG nodes from the gateway by alanshaw · Pull Request #8037 · ipfs/go-ipfs · GitHub](https://github.com/ipfs/go-ipfs/pull/8037)

---

<div class="post-metadata">

**Author:** ![ludwigschubi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/ludwigschubi/32/4953_2.png) [@ludwigschubi](https://discuss.ipfs.tech/u/ludwigschubi)\
**Post date:** [April 27, 2021, 12:44pm UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033/4 "2021-04-27T12:44:53Z")

</div>

Hey @hector, thank you for your answers. Glad this is being worked on.

One more question tho. Let’s say i encode my data as dag-pb can i then use pathing through the gateway like `https://dweb.link/v0/dag/get?arg=<cid><uri-encoded-path>`?

---

<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:** [April 27, 2021, 12:48pm UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033/5 "2021-04-27T12:48:20Z")

</div>

> [@ludwigschubi](#):
>
> One more question tho. Let’s say i encode my data as dag-pb can i then use pathing through the gateway like `https://dweb.link/v0/dag/get?arg=<cid><uri-encoded-path>` ?

No, you will have to wait to the feature above for pathing on arbitrary ipld objects to work I think.

---

<div class="post-metadata">

**Author:** ![ludwigschubi](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/ludwigschubi/32/4953_2.png) [@ludwigschubi](https://discuss.ipfs.tech/u/ludwigschubi)\
**Post date:** [April 27, 2021, 12:57pm UTC](https://discuss.ipfs.tech/t/access-ipld-block-through-gateway/11033/6 "2021-04-27T12:57:16Z")

</div>

Okay i will try it out later just to make sure
