# @libp2p/interface-peer-routing

> Peer Routing interface for libp2p

Latest version **1.1.1** (published 2023-05-04) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install @libp2p/interface-peer-routing
pnpm add @libp2p/interface-peer-routing
yarn add @libp2p/interface-peer-routing
bun add @libp2p/interface-peer-routing
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2023-05-04 |
| First published | 2022-06-10 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16.0.0 |
| Dependencies | 3 |
| Unpacked size | 11.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jacobheun, npm-service-account-libp2p, alanshaw, vascosantos, achingbrain, daviddias |
| Keywords | interface, libp2p |

## Links

- npm: https://www.npmjs.com/package/@libp2p/interface-peer-routing
- Repository: https://github.com/libp2p/js-libp2p-interfaces
- Homepage: https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-peer-routing#readme
- Issues: https://github.com/libp2p/js-libp2p-interfaces/issues
- npm.io page: https://npm.io/package/@libp2p/interface-peer-routing

## Dependencies (3)

- [@libp2p/interfaces](https://npm.io/package/@libp2p/interfaces.md) ^3.0.0
- [@libp2p/interface-peer-id](https://npm.io/package/@libp2p/interface-peer-id.md) ^2.0.0
- [@libp2p/interface-peer-info](https://npm.io/package/@libp2p/interface-peer-info.md) ^1.0.0

## Recent versions

- 1.1.1 (latest) — 2023-05-04
- 1.1.1-d853d124 (next) — 2023-06-19
- 1.1.1-ea8a0637 — 2023-06-19
- 1.1.1-ab0e3980 — 2023-06-19
- 1.1.1-3dfc236e — 2023-06-16
- 1.1.1-8c6b6d24 — 2023-06-15
- 1.1.1-d2f1eff4 — 2023-06-15
- 1.1.1-5a9fb4d6 — 2023-06-15
- 1.1.1-883082ca — 2023-06-15
- 1.1.1-1c6702c8 — 2023-06-15
- 1.1.0 — 2023-04-27
- 1.0.8 — 2023-03-09
- 1.0.7 — 2023-01-18
- 1.0.6 — 2023-01-06
- 1.0.5 — 2022-12-19
- … 6 more at https://npm.io/package/@libp2p/interface-peer-routing/versions

## README

# @libp2p/interface-peer-routing <!-- omit in toc -->

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-interfaces.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-interfaces)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-interfaces/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-interfaces/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

> Peer Routing interface for libp2p

## Table of contents <!-- omit in toc -->

- - [Install](#install)
- [Modules that implement the interface](#modules-that-implement-the-interface)
- [Badge](#badge)
- [How to use the battery of tests](#how-to-use-the-battery-of-tests)
  - [Node.js](#nodejs)
- [API](#api)
  - - [findPeer](#findpeer)
  - [API Docs](#api-docs)
  - [License](#license)
  - [Contribution](#contribution)

## Install

```console
$ npm i @libp2p/interface-peer-routing
```

The primary goal of this module is to enable developers to pick and swap their Peer Routing module as they see fit for their libp2p installation, without having to go through shims or compatibility issues. This module and test suite were heavily inspired by abstract-blob-store and interface-stream-muxer.

Publishing a test suite as a module lets multiple modules all ensure compatibility since they use the same test suite.

# Modules that implement the interface

- [JavaScript libp2p-kad-dht](https://github.com/libp2p/js-libp2p-kad-dht)
- [JavaScript libp2p-delegated-peer-routing](https://github.com/libp2p/js-libp2p-delegated-peer-routing)

# Badge

Include this badge in your readme if you make a module that is compatible with the interface-record-store API. You can validate this by running the tests.

![](img/badge.png)

# How to use the battery of tests

## Node.js

TBD

# API

A valid (read: that follows this abstraction) Peer Routing module must implement the following API.

### findPeer

- `findPeer(peerId)`

Query the network for all multiaddresses associated with a `PeerId`.

**Parameters**

- [peerId](https://github.com/libp2p/js-peer-id).

**Returns**

It returns the [peerId](https://github.com/libp2p/js-peer-id) together with the known peers [multiaddrs](https://github.com/multiformats/js-multiaddr), as follows:

`Promise<{ id: PeerId, multiaddrs: Multiaddr[] }>`

## API Docs

- <https://libp2p.github.io/js-libp2p-interfaces/modules/_libp2p_interface_peer_routing.html>

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

---
_Source: https://npm.io/package/@libp2p/interface-peer-routing · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
