Installing the library
Add the nostr-sdk
dependency in your Cargo.toml
file:
[dependencies]
nostr-sdk = "0.36"
Alternatively, you can add it directly from git
source:
[dependencies]
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", tag = "v0.36.0" }
Import the library in your code:
#![allow(unused)] fn main() { use nostr_sdk::prelude::*; }
The nostr-sdk
package is available on the public PyPI:
pip install nostr-sdk
Alternatively, you can manually add the dependency in your requrements.txt
, setup.py
, etc.:
nostr-sdk==0.36.0
Import the library in your code:
from nostr_sdk import *
Support matrix
The wheels are distributed for the following python versions
and platforms
.
If your version
/platform
is not currently supported, you can compile the wheel by your self following these instructions.
Python version
3.8 | 3.9 | 3.10 | 3.11 | 3.12 | 3.13 |
---|---|---|---|---|---|
❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
Platform support
OS | x64 | aarch64 | arm | i686 |
---|---|---|---|---|
Linux | ✅ | ✅ | ❌ | ❌ |
macOS | ✅ | ✅ | ❌ | ❌ |
Windows | ✅ | ❌ | ❌ | ❌ |
Known issues
No running event loop
If you receive no running event loop
error at runtime, add the following line to your code:
import asyncio
from nostr_sdk import uniffi_set_event_loop
uniffi_set_event_loop(asyncio.get_running_loop())
The nostr-sdk
package is available on the public npmjs:
npm i @rust-nostr/nostr-sdk
Alternatively, you can manually add the dependency in your package.json
file:
{
"dependencies": {
"@rust-nostr/nostr-sdk": "0.36.0"
}
}
WASM
This library to work require to load the WASM code.
Load in async context
const { loadWasmAsync } = require("@rust-nostr/nostr-sdk");
async function main() {
// Load WASM
await loadWasmAsync();
// ...
}
main();
Load in sync context
const { loadWasmSync } = require("@rust-nostr/nostr-sdk");
function main() {
// Load WASM
loadWasmSync();
// ...
}
main();
To use the Kotlin language bindings for nostr-sdk
in your Android project add the following to your gradle dependencies:
repositories {
mavenCentral()
}
dependencies {
implementation("org.rust-nostr:nostr-sdk:0.36.0")
}
Import the library in your code:
import rust.nostr.sdk.*
Known issues
JNA dependency
Depending on the JVM version you use, you might not have the JNA dependency on your classpath. The exception thrown will be
class file for com.sun.jna.Pointer not found
The solution is to add JNA as a dependency like so:
dependencies {
// ...
implementation("net.java.dev.jna:jna:5.12.0@aar")
}
Xcode
Via File > Add Packages...
, add
https://github.com/rust-nostr/nostr-sdk-swift.git
as a package dependency in Xcode.
Swift Package
Add the following to the dependencies array in your Package.swift
:
.package(url: "https://github.com/rust-nostr/nostr-sdk-swift.git", from: "0.36.0"),
Add the following code to your package:
nostr_sdk:
git:
url: https://github.com/rust-nostr/nostr.git
ref: v0.36.0
path: bindings/nostr-sdk-flutter