LensLoader

atmosphere.LensLoader(client)

Loads lens records from ATProto.

This class fetches lens transformation records. Note that actually using a lens requires installing the referenced code and importing it manually.

Examples

>>> client = AtmosphereClient()
>>> loader = LensLoader(client)
>>>
>>> record = loader.get("at://did:plc:abc/ac.foundation.dataset.lens/xyz")
>>> print(record["name"])
>>> print(record["sourceSchema"])
>>> print(record.get("getterCode", {}).get("repository"))

Methods

Name Description
find_by_schemas Find lenses that transform between specific schemas.
get Fetch a lens record by AT URI.
list_all List lens records from a repository.

find_by_schemas

atmosphere.LensLoader.find_by_schemas(
    source_schema_uri,
    target_schema_uri=None,
    repo=None,
)

Find lenses that transform between specific schemas.

Parameters

Name Type Description Default
source_schema_uri str AT URI of the source schema. required
target_schema_uri Optional[str] Optional AT URI of the target schema. If not provided, returns all lenses from the source. None
repo Optional[str] The DID of the repository to search. None

Returns

Name Type Description
list[dict] List of matching lens records.

get

atmosphere.LensLoader.get(uri)

Fetch a lens record by AT URI.

Parameters

Name Type Description Default
uri str | AtUri The AT URI of the lens record. required

Returns

Name Type Description
dict The lens record as a dictionary.

Raises

Name Type Description
ValueError If the record is not a lens record.

list_all

atmosphere.LensLoader.list_all(repo=None, limit=100)

List lens records from a repository.

Parameters

Name Type Description Default
repo Optional[str] The DID of the repository. Defaults to authenticated user. None
limit int Maximum number of records to return. 100

Returns

Name Type Description
list[dict] List of lens records.