---
sidebar:
  hidden: true
title: roboto.domain.topics.topic_schema
---
## Module Contents

### TopicSchema

```python
class roboto.domain.topics.topic_schema.TopicSchema(
    record: roboto.domain.topics.record.TopicSchemaRecord,
    fields: list[roboto.domain.topics.record.SchemaFieldRecord],
    roboto_client: roboto.http.RobotoClient,
)
```

`from roboto import TopicSchema`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/topics/topic_schema.py#L20-L111)

Describes the field structure of a topic's messages.

A topic schema is identified by a name (e.g., `"sensor_msgs/Imu"`) and a content-based checksum deterministically derived from its fields. Schemas are deduplicated within an organization: topics whose fields share the same names, paths, and data types reference the same schema.

Use [`from_id()`](/reference/python-sdk/roboto/domain/topics/topic_schema#roboto.domain.topics.topic_schema.TopicSchema.from_id) when you already know the `schema_id`. [`Topic.get_schema()`](/reference/python-sdk/roboto/domain/topics/topic#roboto.domain.topics.topic.Topic.get_schema) retrieves the schema associated with a specific topic.

**Usage**

Retrieve a schema and inspect its fields:

```python
from roboto.domain.topics import TopicSchema
schema = TopicSchema.from_id("ts_abc123")
print(schema.name, schema.checksum)
for field in schema.fields:
    print(field.path_in_schema, field.data_type)
```

**Parameters**

- **record** (`roboto.domain.topics.record.TopicSchemaRecord`)
- **fields** (`list[roboto.domain.topics.record.SchemaFieldRecord]`)
- **roboto_client** (`roboto.http.RobotoClient`)

**Properties**

- **TopicSchema.checksum** (`str`): Content-based checksum of the schema's field set.

- **TopicSchema.fields** (`list[roboto.domain.topics.record.SchemaFieldRecord]`): Field definitions belonging to this schema.

- **TopicSchema.name** (`str | None`): Informational label for the schema (e.g. `"sensor_msgs/Imu"`). Not part of identity; may be `None`.

  Return type: `Optional[str]`

- **TopicSchema.record** (`roboto.domain.topics.record.TopicSchemaRecord`): Underlying schema record.

- **TopicSchema.schema_id** (`str`): Unique identifier for this schema.

#### TopicSchema.from_id()

```python
@classmethod
def from_id(
    schema_id: str,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> TopicSchema
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/topics/topic_schema.py#L46-L76)

Retrieve a schema by its ID.

**Parameters**

- **schema_id** (`str`): Unique identifier of the schema to retrieve.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): HTTP client for API communication. If None, uses the default client.

**Returns**

- `TopicSchema`: A [`TopicSchema`](/reference/python-sdk/roboto/domain/topics/topic_schema#roboto.domain.topics.topic_schema.TopicSchema) for the given `schema_id`.

**Raises**

- [`RobotoNotFoundException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): No schema with this ID exists.

**Usage**

```python
from roboto.domain.topics import TopicSchema
schema = TopicSchema.from_id("ts_abc123")
for field in schema.fields:
    print(field.path_in_schema, field.data_type)
```
