@helia/delegated-routing-v1-http-api-client
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

Helia logo

ipfs.tech Discuss codecov CI

A Delegated Routing V1 HTTP API client

About

A client implementation of the IPFS Delegated Routing V1 HTTP API that can be used to interact with any compliant server implementation.

Example

import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import { CID } from 'multiformats/cid'

const client = createDelegatedRoutingV1HttpApiClient('https://example.org')

for await (const prov of getProviders(CID.parse('QmFoo'))) {
  // ...
}

How to use with libp2p

The client can be configured as a libp2p service, this will enable it as both a ContentRouting and a PeerRouting implementation

Example

import { createDelegatedRoutingV1HttpApiClient } from '@helia/delegated-routing-v1-http-api-client'
import { createLibp2p } from 'libp2p'
import { peerIdFromString } from '@libp2p/peer-id'

const client = createDelegatedRoutingV1HttpApiClient('https://example.org')
const libp2p = await createLibp2p({
  // other config here
  services: {
    delegatedRouting: client
  }
})

// later this will use the configured HTTP gateway
await libp2p.peerRouting.findPeer(peerIdFromString('QmFoo'))

Readme

Keywords

Package Sidebar

Install

npm i @helia/delegated-routing-v1-http-api-client

Weekly Downloads

2,352

Version

3.0.1

License

Apache-2.0 OR MIT

Unpacked Size

277 kB

Total Files

20

Last publish

Collaborators

  • npm-service-account-ipfs
  • achingbrain