Installing the library

Rust

Add the nostr-sdk dependency in your Cargo.toml file:

[dependencies]
nostr-sdk = "0.42"

Alternatively, you can add it directly from git source:

[dependencies]
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", tag = "v0.42.0" }

Info

To use a specific commit, use rev instead of tag.

Import the library in your code:

use nostr_sdk::prelude::*;
Python

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.42.1

Import the library in your code:

from nostr_sdk import *

Requirements and supported platforms

Requires Python 3.9 or above.

The following OS and architectures are supported:

OSx86_64aarch64armv7i686riscv64
Android
Linux (GLIBC)✅*
Linux (MUSL)✅*
macOS
Windows

Are you interested in other platforms? Open an issue here.

* PyPI currently doesn't allow uploading riscv64 wheels

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())
JavaScript

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.42.1"
    }
}

WASM

This library to work require to load the WASM code.

Load in async context

import { loadWasmAsync } from "@rust-nostr/nostr-sdk";

async function main() {
    // Load WASM
    await loadWasmAsync();

    // ...
}

main();

Load in sync context

import { loadWasmSync } from "@rust-nostr/nostr-sdk";

function main() {
    // Load WASM
    loadWasmSync();

    // ...
}

main();
Kotlin

Add the following library to your Gradle dependencies:

Android

repositories {
    mavenCentral()
}

dependencies { 
    implementation("org.rust-nostr:nostr-sdk:0.42.1")
}

JVM

repositories {
    mavenCentral()
}

dependencies { 
    implementation("org.rust-nostr:nostr-sdk-jvm:0.42.1")
}

Import the library

Import the library in your code:

import rust.nostr.sdk.*

Supported platforms

The following OS and architectures are supported:

OSx86_64aarch64armv7i686riscv64Package
Androidnostr-sdk
Linux (GLIBC)nostr-sdk-jvm
Linux (MUSL)nostr-sdk-jvm
macOSnostr-sdk-jvm
Windowsnostr-sdk-jvm

Are you interested in other platforms? Open an issue here.

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:

Android
dependencies {
    implementation("net.java.dev.jna:jna:5.15.0@aar")
}
JVM
dependencies {
    implementation("net.java.dev.jna:jna:5.15.0")
}
Swift

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 dependency array in your Package.swift:

.package(url: "https://github.com/rust-nostr/nostr-sdk-swift.git", from: "0.42.1"),

Supported platforms

The following OS and architectures are supported:

OSx86_64aarch64armv7i686
iOS (>=14.0)
iOS Simulator
Mac Catalyst
macOS (>=12.0)
visionOS (>=1.0)
watchOS
tvOS

Are you interested in other platforms? Open an issue here.

C#

Import the library

The Nostr.Sdk package is available on nuget:

dotnet add package Nostr.Sdk --version 0.42.1

Requirements and supported platforms

Requires .NET 6.0 or above.

The following OS and architectures are supported:

OSx86_64aarch64armv7i686riscv64
Android
Linux (GLIBC)
Linux (MUSL)
macOS
Windows

Are you interested in other platforms? Open an issue here.

Flutter

Add the following code to your package:

nostr_sdk:
    git:
        url: https://github.com/rust-nostr/nostr-sdk-flutter.git
        ref: 22f12c9ba52daebe8ba98f65f02ffe63fab886a8