Introduction

DotPassport SDK

DotPassport Logo

The Official JavaScript/TypeScript SDK for DotPassport - Web3 Reputation & Identity

npm versionarrow-up-right Bundle Sizearrow-up-right TypeScriptarrow-up-right License: MITarrow-up-right Testsarrow-up-right Coverage

Getting StartedAPI ReferenceWidgetsExamplesContributing


What is DotPassport?

DotPassport is a comprehensive reputation and identity system for the Polkadot ecosystem. It aggregates on-chain activity across parachains to provide a unified reputation score, verifiable badges, and identity management for Web3 users.

This SDK provides:

  • API Client - Programmatic access to all DotPassport APIs

  • Embeddable Widgets - Ready-to-use UI components for displaying reputation data

  • Full TypeScript Support - Complete type definitions for type-safe development


Table of Contents


🚀 Quick Start

Install the SDK

Use the API Client

Embed a Widget

That's it! You now have a fully functional reputation widget on your page.


📦 Installation

NPM / Yarn / PNPM

CDN (Browser)

Requirements

Requirement
Version

Node.js

16.0+

TypeScript

5.0+ (optional)

Browser

ES2020 compatible


🔧 Environment Configuration

By default, the SDK connects to the production API (https://api.dotpassport.com). For local development, you have several options:

Option 2: Per-Client Configuration

Option 3: Environment Variable (Node.js only)

Helper Functions


✨ Features

🔌 Complete API Coverage

Access all DotPassport endpoints including profiles, scores, badges, and metadata.

🎨 Beautiful Embeddable Widgets

Drop-in widgets with zero configuration. Supports light/dark themes and full customization.

🛡️ Type-Safe Development

Written in TypeScript with complete type definitions. Catch errors at compile time.

🌳 Tree-Shakeable

Import only what you need. Unused code is automatically eliminated.

⚡ Lightweight & Fast

  • Core client: ~3KB gzipped

  • Each widget: ~5KB gzipped

  • Zero external dependencies (widgets)

🔄 Built-in Caching

Smart caching for widget data with configurable TTL to minimize API calls.


📡 API Client

The DotPassportClient provides programmatic access to all DotPassport API endpoints.

Initialization

Profile Methods

Score Methods

Badge Methods

Metadata Methods

AbortSignal Support

All methods support AbortSignal for request cancellation:


🎨 Embeddable Widgets

DotPassport SDK includes four beautiful, customizable widgets that work with any framework.

Widget Types

Widget
Description
Use Case

Reputation

Total score with category breakdown

User dashboards, profiles

Badge

Earned badges display

Achievement showcases

Profile

User profile card

Social features, identity

Category

Single category deep-dive

Detailed score analysis


Reputation Widget

Displays total reputation score with category breakdown

Reputation Widget Light
Reputation Widget Dark
Reputation Widget with Categories
Reputation Widget Score Only

Badge Widget

Shows badges earned by the user

Badge Widget Light
Badge Widget Dark
Badge Widget with Dates

Profile Widget

User profile card with social links and identities

Profile Widget

Category Widget

Detailed breakdown of a specific reputation category

Category Widget Light
Category Widget Dark
Category Widget with Breakdown
Category Widget Score Only

⚙️ Configuration Reference

Common Widget Options

Option
Type
Default
Description

apiKey

string

required

Your DotPassport API key

address

string

required

Polkadot address to display

type

string

'reputation'

Widget type

theme

'light' | 'dark' | 'auto'

'light'

Color theme

compact

boolean

false

Compact display mode

className

string

''

Custom CSS class

onLoad

() => void

-

Callback when loaded

onError

(error: Error) => void

-

Error callback

Reputation Widget Options

Option
Type
Default
Description

showCategories

boolean

true

Show category breakdown

maxCategories

number

6

Max categories to display

Badge Widget Options

Option
Type
Default
Description

badgeKey

string

-

Show single specific badge

maxBadges

number

10

Max badges to display

showProgress

boolean

true

Show earned dates

Profile Widget Options

Option
Type
Default
Description

showAvatar

boolean

true

Display user avatar

showBio

boolean

true

Display user bio

showSocials

boolean

true

Display social links

showIdentities

boolean

true

Display chain identities

Category Widget Options

Option
Type
Default
Description

categoryKey

string

required

Category key to display

showTitle

boolean

true

Show category title

showDescription

boolean

true

Show description

showBreakdown

boolean

true

Show score breakdown

showAdvice

boolean

true

Show improvement tips

showScoreOnly

boolean

false

Minimal view


🔗 Framework Integration

React

Vue 3

Svelte

Vanilla JavaScript


🔐 Wallet Integration

Connect DotPassport SDK with popular Polkadot wallets to display reputation data for connected users.

Talisman Wallet

SubWallet

React Hook Example

📖 Detailed Wallet Guides:


🎨 Custom Styling

Widgets support CSS variable overrides for custom styling:


❌ Error Handling

The SDK provides structured error handling through DotPassportError:

Error Codes Reference

Code
Name
Description

400

Bad Request

Invalid request parameters

401

Unauthorized

Invalid or missing API key

403

Forbidden

Access denied to resource

404

Not Found

User, badge, or category not found

429

Too Many Requests

Rate limit exceeded

500

Server Error

Internal server error


📘 TypeScript Support

The SDK is written in TypeScript with complete type definitions.

Importing Types

Type-Safe Usage


📖 Examples

Complete Dashboard Example

Widget with Event Handling


🧪 Testing

The SDK includes comprehensive test coverage with 236+ tests.

Running Tests

Coverage

Metric
Coverage

Statements

86%+

Branches

86%+

Functions

86%+

Lines

86%+


🤝 Contributing

We welcome contributions from the community! Here's how you can help:

Ways to Contribute

  • 🐛 Report Bugs - Open an issue with a clear description

  • 💡 Suggest Features - Share your ideas for improvements

  • 📝 Improve Docs - Help make our documentation better

  • 🔧 Submit PRs - Fix bugs or add new features

Development Setup

Code Style

  • We use ESLint and Prettier for code formatting

  • Write TypeScript with strict type checking

  • Add tests for new features

  • Update documentation for API changes

Pull Request Process

  1. Create a feature branch: git checkout -b feature/amazing-feature

  2. Make your changes and commit: git commit -m 'Add amazing feature'

  3. Push to your fork: git push origin feature/amazing-feature

  4. Open a Pull Request with a clear description

Commit Convention

We follow Conventional Commitsarrow-up-right:


👨‍💻 Author

Sachin

Sachin

GitHubarrow-up-right Twitterarrow-up-right

Building the future of Web3 identity and reputation


📄 License

This project is licensed under the MIT License - see the LICENSEarrow-up-right file for details.



⬆ Back to Top


Made with ❤️ by the DotPassport Team

Empowering Web3 identity and reputation

Last updated