# Getting raw IPNS data like sequence number

**URL:** <https://discuss.ipfs.tech/t/getting-raw-ipns-data-like-sequence-number/1505>\
**Category:** Help\
**Tags:** ipns\
**Created:** [November 24, 2017, 12:15pm UTC](https://discuss.ipfs.tech/t/getting-raw-ipns-data-like-sequence-number/1505 "2017-11-24T12:15:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rklaehn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/rklaehn/32/244_2.png) [@rklaehn](https://discuss.ipfs.tech/u/rklaehn)\
**Post date:** [November 24, 2017, 12:15pm UTC](https://discuss.ipfs.tech/t/getting-raw-ipns-data-like-sequence-number/1505/1 "2017-11-24T12:15:19Z")

</div>

Is there a way, using ipfs cli or the ipfs API, to get the raw data of an IPNS entry? Basically [this](https://github.com/ipfs/go-ipfs/blob/73cd8b3e98aba252f0eadcc625472103a2dd1d53/namesys/pb/namesys.proto) ?

We want to put a caching layer in front of IPNS to ensure instant resolution and reliability in disconnected mode. We want a cache that is long duration, persistent, and prefers returning an old entry to not resolving at all. In order to implement this in the best possible way, we would like to have the sequence number to ensure that we don’t accept old values.

Would there be a chance to get something like this (persistent IPNS cache and configurable lookup policies) included in mainline ipfs? (no big deal if not, we realise that our use case with mobile devices is a bit peculiar)

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [November 30, 2017, 2:12am UTC](https://discuss.ipfs.tech/t/getting-raw-ipns-data-like-sequence-number/1505/2 "2017-11-30T02:12:34Z")

</div>

> Is there a way, using ipfs cli or the ipfs API, to get the raw data of an IPNS entry?

Sort of. You can directly query the DHT for the IPNS record `ipfs dht get /ipns/QmId`. However, this will _only_ use the DHT and we’re working on adding other methods for resolving IPNS records.

> Would there be a chance to get something like this (persistent IPNS cache and configurable lookup policies) included in mainline ipfs? (no big deal if not, we realise that our use case with mobile devices is a bit peculiar)

You may be interested in the discussion happening at:

> <https://github.com/ipfs/kubo/issues/4435>
>
> cc @vyzo 
> 
> \`\`\`
> USAGE
> ipfs name follow \<ipns-path\> - Track changes to IPNS …names.
> 
> SYNOPSIS
> ipfs name follow \[--pin=true\] \[--allow-expired=true\] \[--\] \<ipns-path\>
> 
> ARGUMENTS
> 
> \<ipns-path\> - IPNS path of the name that should be followed.
> 
> OPTIONS
> 
> --pin bool - Always pin the name's most recent content. Default: true
> --allow-expired bool - Allow lookup even if a name's TTL is reached. Default: true
> 
> DESCRIPTION
> 
> The 'ipfs name follow' command can be used to track changes to an IPNS name.
> A followed name will be refreshed in the background in intervals, so that
> lookups through an 'ipfs' command or the HTTP API are always instant and up-to-date.
> 
> When called with '--pin' (default), after refreshes the name's new content
> is pinned. This is equivalent to 'ipfs pin replace /ipfs/QmOld /ipfs/QmNew'.
> 
> When called with '--allow-expired' (default), lookups of the name through
> the 'ipfs' command or the HTTP API always return the last known content,
> even if the TTL has been reached and the name has expired. If this is the
> case, a warning is printed along with whatever is the command's respones.
> 
> The combination of '--pin' and '--allow-expired' allows for convenient
> offline use cases. For example, on a long flight I'd like to have IPFS docs
> with me, and I'd like them to be usable at /ipns/docs.ipfs.io as always.
> 
> Open question: pubsub
> 
> Open question: refresh after ttl/2 or whatever
> - /ipns/QmFoo: ttl = ipns-ttl
> - /ipns/dnslink.net: ttl = min(dns-ttl, ipns-ttl)
> 
> Open question: storage of followings
> \`\`\`

(specifically, the `--allow-expired` flag).

---

<div class="post-metadata">

**Author:** ![rklaehn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/rklaehn/32/244_2.png) [@rklaehn](https://discuss.ipfs.tech/u/rklaehn)\
**Post date:** [November 30, 2017, 8:41am UTC](https://discuss.ipfs.tech/t/getting-raw-ipns-data-like-sequence-number/1505/3 "2017-11-30T08:41:50Z")

</div>

> [@stebalien](#):
>
> > [@](#):
> >
> > Is there a way, using ipfs cli or the ipfs API, to get the raw data of an IPNS entry?
> 
> Sort of. You can directly query the DHT for the IPNS record ipfs dht get /ipns/QmId. However, this will only use the DHT and we’re working on adding other methods for resolving IPNS records.

I thought so. But it did not work for me because I tried to resolve just the IPNS name without the /ipns/ prefix. Now that I tried it with the prefix, it works.

So you get the raw protobuf encoded data and would have to decode it yourself, right?

> [@stebalien](#):
>
> You may be interested in the discussion happening at: [ipfs name follow · Issue #4435 · ipfs/kubo · GitHub](https://github.com/ipfs/go-ipfs/issues/4435)  
> (specifically, the --allow-expired flag).

Wow. You made my day. This is **exactly** what we wanted to implement as a proxy in front of IPFS. We even wanted to do the pinning part. Currently we have a brute force thing that just pins a number of names name every 60s, but that is obviously a very ugly and temporary solution.

So _thank you_! I will comment in the issue.

This would be extremely useful in many cases. Finally a way for somebody that runs a private IPFS node to easily contribute to the distribution of some selected content…

One question: you keep talking about using pubsub to publish IPNS entries. Currently pubsub is experimental and disabled by default. Does that mean that a better algorithm than floodsub is in the pipeline?

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [November 30, 2017, 10:55pm UTC](https://discuss.ipfs.tech/t/getting-raw-ipns-data-like-sequence-number/1505/4 "2017-11-30T22:55:28Z")

</div>

> [@rklaehn](#):
>
> So you get the raw protobuf encoded data and would have to decode it yourself, right?

Yes.

> [@rklaehn](#):
>
> One question: you keep talking about using pubsub to publish IPNS entries. Currently pubsub is experimental and disabled by default. Does that mean that a better algorithm than floodsub is in the pipeline?

We’ve been working on improving floodsub but, in terms of more efficient algorithms, we’re still exploring the design space.
