I think this function could be moved to some place under the `api` package, because as I know this conversion is only needed by the `api` part.

The same for the `load_from_data`