AtmosphereClient
atmosphere.AtmosphereClient(base_url=None, *, _client=None)
ATProto client wrapper for atdata operations.
This class wraps the atproto SDK client and provides higher-level methods for working with atdata records (schemas, datasets, lenses).
Examples
>>> client = AtmosphereClient()
>>> client.login("alice.bsky.social", "app-password")
>>> print(client.did)
'did:plc:...'
Note
The password should be an app-specific password, not your main account password. Create app passwords in your Bluesky account settings.
Attributes
| did |
Get the DID of the authenticated user. |
| handle |
Get the handle of the authenticated user. |
| is_authenticated |
Check if the client has a valid session. |
Methods
create_record
atmosphere.AtmosphereClient.create_record(
collection,
record,
*,
rkey=None,
validate=False,
)
Create a record in the user’s repository.
Parameters
| collection |
str |
The NSID of the record collection (e.g., ‘ac.foundation.dataset.sampleSchema’). |
required |
| record |
dict |
The record data. Must include a ‘$type’ field. |
required |
| rkey |
Optional[str] |
Optional explicit record key. If not provided, a TID is generated. |
None |
| validate |
bool |
Whether to validate against the Lexicon schema. Set to False for custom lexicons that the PDS doesn’t know about. |
False |
Returns
|
AtUri |
The AT URI of the created record. |
delete_record
atmosphere.AtmosphereClient.delete_record(uri, *, swap_commit=None)
Delete a record.
Parameters
| uri |
str | AtUri |
The AT URI of the record to delete. |
required |
| swap_commit |
Optional[str] |
Optional CID for compare-and-swap delete. |
None |
export_session
atmosphere.AtmosphereClient.export_session()
Export the current session for later reuse.
Returns
|
str |
Session string that can be passed to login_with_session(). |
get_blob
atmosphere.AtmosphereClient.get_blob(did, cid)
Download a blob from a PDS.
This resolves the PDS endpoint from the DID document and fetches the blob directly from the PDS.
Parameters
| did |
str |
The DID of the repository containing the blob. |
required |
| cid |
str |
The CID of the blob. |
required |
Returns
|
bytes |
The blob data as bytes. |
get_blob_url
atmosphere.AtmosphereClient.get_blob_url(did, cid)
Get the direct URL for fetching a blob.
This is useful for passing to WebDataset or other HTTP clients.
Parameters
| did |
str |
The DID of the repository containing the blob. |
required |
| cid |
str |
The CID of the blob. |
required |
Returns
|
str |
The full URL for fetching the blob. |
get_record
atmosphere.AtmosphereClient.get_record(uri)
Fetch a record by AT URI.
Parameters
| uri |
str | AtUri |
The AT URI of the record. |
required |
Returns
|
dict |
The record data as a dictionary. |
list_datasets
atmosphere.AtmosphereClient.list_datasets(repo=None, limit=100)
List dataset records.
Parameters
| repo |
Optional[str] |
The DID to query. Defaults to authenticated user. |
None |
| limit |
int |
Maximum number to return. |
100 |
list_lenses
atmosphere.AtmosphereClient.list_lenses(repo=None, limit=100)
List lens records.
Parameters
| repo |
Optional[str] |
The DID to query. Defaults to authenticated user. |
None |
| limit |
int |
Maximum number to return. |
100 |
list_records
atmosphere.AtmosphereClient.list_records(
collection,
*,
repo=None,
limit=100,
cursor=None,
)
List records in a collection.
Parameters
| collection |
str |
The NSID of the record collection. |
required |
| repo |
Optional[str] |
The DID of the repository to query. Defaults to the authenticated user’s repository. |
None |
| limit |
int |
Maximum number of records to return (default 100). |
100 |
| cursor |
Optional[str] |
Pagination cursor from a previous call. |
None |
Returns
|
list[dict] |
A tuple of (records, next_cursor). The cursor is None if there |
|
Optional[str] |
are no more records. |
list_schemas
atmosphere.AtmosphereClient.list_schemas(repo=None, limit=100)
List schema records.
Parameters
| repo |
Optional[str] |
The DID to query. Defaults to authenticated user. |
None |
| limit |
int |
Maximum number to return. |
100 |
login
atmosphere.AtmosphereClient.login(handle, password)
Authenticate with the ATProto PDS.
Parameters
| handle |
str |
Your Bluesky handle (e.g., ‘alice.bsky.social’). |
required |
| password |
str |
App-specific password (not your main password). |
required |
login_with_session
atmosphere.AtmosphereClient.login_with_session(session_string)
Authenticate using an exported session string.
This allows reusing a session without re-authenticating, which helps avoid rate limits on session creation.
Parameters
| session_string |
str |
Session string from export_session(). |
required |
put_record
atmosphere.AtmosphereClient.put_record(
collection,
rkey,
record,
*,
validate=False,
swap_commit=None,
)
Create or update a record at a specific key.
Parameters
| collection |
str |
The NSID of the record collection. |
required |
| rkey |
str |
The record key. |
required |
| record |
dict |
The record data. Must include a ‘$type’ field. |
required |
| validate |
bool |
Whether to validate against the Lexicon schema. |
False |
| swap_commit |
Optional[str] |
Optional CID for compare-and-swap update. |
None |
Returns
|
AtUri |
The AT URI of the record. |
upload_blob
atmosphere.AtmosphereClient.upload_blob(
data,
mime_type='application/octet-stream',
)
Upload binary data as a blob to the PDS.
Parameters
| data |
bytes |
Binary data to upload. |
required |
| mime_type |
str |
MIME type of the data (for reference, not enforced by PDS). |
'application/octet-stream' |
Returns
|
dict |
A blob reference dict with keys: ‘$type’, ‘ref’, ‘mimeType’, ‘size’. |
|
dict |
This can be embedded directly in record fields. |