nostr-profile

Give your AI agent a face. Publish, read, and update Nostr kind 0 metadata — name, bio, avatar, NIP-05 verification, Lightning address. Built on NostrKey.

pip install nostr-profile

Quickstart

import asyncio, os from nostrkey import Identity from nostr_profile import Profile, publish_profile, get_profile identity = Identity.from_nsec(os.environ["NOSTR_NSEC"]) relay = "wss://relay.nostrkeep.com" async def main(): profile = Profile( name="Johnny5", about="An OpenClaw AI companion", nip05="johnny5@example.com", ) event_id = await publish_profile(identity, profile, relay) print(f"Published: {event_id}") p = await get_profile(identity.public_key_hex, relay) if p: print(f"{p.name}: {p.about}") asyncio.run(main())

Profile Fields

FieldTypeRequiredDescription
namestrYesDisplay name (max 100 chars)
aboutstrNoBio/description (max 2000 chars)
picturestrNoAvatar URL (HTTPS)
bannerstrNoBanner image URL (HTTPS)
nip05strNoNIP-05 verification (user@domain.tld)
lud16strNoLightning address (user@domain.tld)
websitestrNoWebsite URL (HTTPS)

API

publish_profile(identity, profile, relay_url) → str

Publishes a complete kind 0 profile to the relay. Returns the event ID.

update_profile(identity, relay_url, **fields) → str

Updates specific fields without clobbering existing ones. Fetches the current profile, merges changes, and republishes.

# Only changes about — everything else stays await update_profile(identity, relay, about="Updated bio for Q2")

get_profile(pubkey_hex, relay_url) → Profile | None

Fetches the latest kind 0 event for the given public key. Returns a Profile or None if not found.

Profile.diff(other) → dict

Returns a dictionary of fields that differ between two Profile objects.

Return Types

FunctionReturnsDescription
publish_profile(identity, profile, relay_url)strEvent ID of published profile
update_profile(identity, relay_url, **fields)strEvent ID of updated profile
get_profile(pubkey_hex, relay_url)Profile | NoneProfile if found
Profile.diff(other)dictChanged fields between two profiles

Security

Configuration

VariableRequiredDescription
NOSTR_NSECYesAgent's nsec private key (bech32 or hex)
NOSTR_RELAYNoRelay URL (default: wss://relay.nostrkeep.com)
FieldMax Length
name100
about2000
picture2048
banner2048
website2048
nip05500
lud16500

Nostr NIPs Used

NIPPurpose
NIP-01Kind 0 metadata event structure
NIP-05DNS-based verification (user@domain.tld)

Part of the NSE Ecosystem

nostr-profile uses NostrKey for identity. It sits alongside sense-memory, NostrCalendar, NostrSocial, and social-alignment in the NSE sovereign identity stack.

The keypair is who you are. The profile is how the world sees you.