On this page
Guide
Overview
This guide helps users understand how to use the OneKey provider API to easily build network applications using the Nostr protocol.
OneKey provider API is specified by NIP-07 .
Install
1. Download OneKey Wallet
Download the OneKey Wallet . Install the OneKey browser extension.
2. API Injection Explanation
- The OneKey browser extension injects
Provider APIinto visited websites. - Two types of APIs are provided:
window.nostrandwindow.$onekey.nostr. - It is recommended to use
window.$onekey.nostr.
Prefer
window.$onekey.nostrto select OneKey specifically. The globalwindow.nostrmay belong to another wallet when multiple extensions are installed.
Detecting Provider API support
Check that a provider is available before making requests:
const provider = (window.$onekey && window.$onekey.nostr) || window.nostr;
if (!provider) {
throw new Error("No provider is available.");
}API
Choose an API for the operation your application needs.
More Interfaces: View Details
Event
- Key Operations: Such as account switching
- More Information: View More
Handling requests
Run wallet requests from an async function or an ES module. Catch rejected promises and show the error in your application. Request connections, signatures, and payments from a user action, and disable the triggering button while a request is pending.