Skip to main content

What is Lexicon?

Lexicon is the schema system used by the AT Protocol to define the structure of data across the network. It provides a standardized way to describe records, queries, procedures, and subscriptions.

Core Concepts

Schema Types

Lexicon supports several types of schemas:
  • Records: Data structures stored in repositories (e.g., posts, profiles, follows)
  • Queries: Read-only operations that return data (e.g., get profile, get timeline)
  • Procedures: Write operations that modify state (e.g., create record, delete record)
  • Subscriptions: Real-time event streams (e.g., repository updates)

NSID Format

Every lexicon is identified by a Namespaced Identifier (NSID) using reverse domain notation:
The format is: {authority}.{name}.{name}

Lexicon Namespaces

com.atproto.*

Core AT Protocol lexicons that provide fundamental functionality:
  • identity: DID and handle resolution
  • repo: Repository and record management
  • server: Account and session management
  • sync: Repository synchronization
  • admin: Administrative operations
  • moderation: Content reporting
  • label: Content labeling system

app.bsky.*

Bluesky application-specific lexicons:
  • actor: User profiles and preferences
  • feed: Posts, likes, reposts, and feeds
  • graph: Social graph (follows, blocks, lists)
  • notification: Notification system
  • labeler: Custom labeling services
  • embed: Rich embeds (images, videos, links)
  • richtext: Text formatting and facets

Data Types

Lexicon supports various data types:

Primitives

  • string: Text data
  • integer: Whole numbers
  • boolean: True/false values
  • unknown: Unstructured data

Formats

  • did: Decentralized Identifier
  • handle: User handle (e.g., alice.bsky.social)
  • at-uri: AT Protocol URI
  • at-identifier: Handle or DID
  • datetime: ISO 8601 timestamp
  • cid: Content Identifier
  • nsid: Namespaced Identifier
  • uri: Generic URI
  • language: BCP 47 language tag

Complex Types

  • object: Structured data with properties
  • array: List of items
  • union: One of several types
  • ref: Reference to another definition
  • blob: Binary data

Common Patterns

Pagination

Many queries support cursor-based pagination:
Response:

Authentication

Most write operations and some read operations require authentication via JWT:

Error Handling

Lexicons define specific error types:

Example Lexicon Structure

Using Lexicons

With TypeScript SDK

Direct HTTP API

Next Steps

Explore the specific lexicon namespaces:

Resources