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:{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 datainteger: Whole numbersboolean: True/false valuesunknown: Unstructured data
Formats
did: Decentralized Identifierhandle: User handle (e.g., alice.bsky.social)at-uri: AT Protocol URIat-identifier: Handle or DIDdatetime: ISO 8601 timestampcid: Content Identifiernsid: Namespaced Identifieruri: Generic URIlanguage: BCP 47 language tag
Complex Types
object: Structured data with propertiesarray: List of itemsunion: One of several typesref: Reference to another definitionblob: Binary data
Common Patterns
Pagination
Many queries support cursor-based pagination: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:- com.atproto.identity - Identity resolution
- com.atproto.repo - Repository management
- com.atproto.server - Server operations
- app.bsky.feed - Social feeds and posts
- app.bsky.graph - Social graph