# `Lexicon`

A class in `fastatp.lexicon` ([source](https://github.com/jacoblapenna/fastatp/blob/main/fastatp/lexicon.py#L32)).

Based on `BaseModel`.

Base class for user-defined, atproto-conforming record types.

Subclasses declare their NSID as a bare class attribute:

    class PressureReading(Lexicon):
        nsid = "com.example.telemetry.pressureReading"
        pressure_psi: int

Subclasses register themselves globally by NSID at definition time; the
last definition for an NSID wins (re-definition is allowed to support
notebooks and hot reload).

## Attributes

- `model_config`
- `nsid: str`
- `record_key: str`

## Methods

### `to_json_dict`

```python
to_json_dict() -> dict[str, Any]
```

JSON-mode dict including `$type`; omitted optionals are dropped.

### `to_json`

```python
to_json() -> str
```

### `from_json_dict`

```python
from_json_dict(data: dict[str, Any]) -> L
```

### `to_dag_cbor`

```python
to_dag_cbor() -> bytes
```

Canonical DAG-CBOR bytes of this record (atproto data-model forms).

### `cid`

```python
cid() -> Any
```

The record's CID (CIDv1, dag-cbor, sha-256) — identical to atproto.

### `to_lexicon_json`

```python
to_lexicon_json() -> dict[str, Any]
```

Emit a valid `lexicon: 1` schema document for this class.
