Overview
The operations module provides the core functions for working with Speckle data: sending objects to transports, receiving them back, and serializing/deserializing for custom workflows.Principal Operations
send()
Send a Base object to one or more transports.The object to send
Where to send the object. Defaults to local cache only.
Whether to also save to the local SQLite cache
The object ID (hash) of the sent object
- Send to Server
- Send Complex Object
- Send to Multiple Transports
- Local Cache Only
When you send an object, all nested Base objects are automatically sent too. You don’t need to send them separately.
receive()
Receive a Base object from a transport.The ID of the object to receive
The transport to receive from (e.g., ServerTransport)
The local cache to check first. Defaults to SQLiteTransport
The received object, fully recomposed with all children
- Receive from Server
- Receive with Local Cache
- Receive from Cache Only
receive() automatically reconstructs the entire object tree. All referenced child objects are fetched and recomposed.Serialization
Note: The
serialize() and deserialize() functions below are included for completeness, but most developers won’t need them directly. The send() and receive() operations handle serialization and deserialization implicitly. Use these functions only when you need custom workflows like saving objects to files or working with JSON representations directly.serialize()
Serialize a Base object to a JSON string.The object to serialize
Transports to write detached objects to. If
None, objects are serialized inline without detachmentJSON string representation of the object
- Simple Serialization
- Serialize with Detachment
- Save to File
Without write transports, large nested objects are serialized inline, which can result in huge JSON strings. Use write transports for large objects.
deserialize()
Deserialize a JSON string back into a Base object.JSON string to deserialize
Transport to read detached/referenced objects from. Defaults to SQLiteTransport
The deserialized object
- Simple Deserialization
- Deserialize with References
- Load from File
If the JSON contains references (like
"@displayValue": "hash123..."), you must provide a read_transport that contains those referenced objects.Detachment and Chunking
Large objects are automatically optimized during send:Objects like
Mesh have predefined chunking and detachment rules. See the Mesh documentation for details.Best Practices
Use local cache for better performance
Use local cache for better performance
Always let the local cache work for you:
Handle errors gracefully
Handle errors gracefully
Network operations can fail:
Don't deserialize untrusted JSON
Don't deserialize untrusted JSON
Be careful with deserialization:
Use appropriate transports
Use appropriate transports
Choose the right transport for your use case:
Summary
The operations module provides four essential functions:- ✅ send() - Send objects to transports with automatic chunking/detachment
- ✅ receive() - Receive and recompose objects from transports
- ✅ serialize() - Convert objects to JSON strings
- ✅ deserialize() - Convert JSON strings back to objects