This endpoint returns a link URL where you can download your data as an .mcap or .bag file.
To download your data:
- Make a request to this endpoint.
- Make a
GETrequest to thelinkURL.
One of recordingId, key, importId (deprecated) or all three of deviceId/deviceName, start, and end must be specified.
Note: You can only export a .bag file if you originally uploaded a .bag file.
Output file format.
bag1- output a .bag filemcap- output a .mcap filemcap0- Deprecated. Usemcap.
Output compression format for chunks. Only valid if outputFormat is mcap.
""- no compressionzstd- zstd compressionlz4- LZ4 compression (default)
Include attachments in streamed data. One of recordingId or importId (deprecated) must also be set. Only valid for mcap outputFormat.
If set to "lastPerChannel", then the stream will include the most recent message on each channel, even if it comes before the requested start, as long as it is within the window of replayLookbackSeconds seconds before start.
The default, "" (no policy), means no messages before start are included.
Maximum lookback before start, in seconds. Used only when replayPolicy is lastPerChannel.
Inclusive start of requested time range. If start is provided, end must be too.
Key of a session to stream. Ensure projectId is provided if streaming by sessionKey.
Episode version to stream. Requires episodeId. If omitted, the latest version is selected when the stream link is signed. The signed link continues to use that version.
ID of an episode to stream. start and end default to the episode's time window when omitted and may each be overridden independently.
ID of a project to scope the streaming to. Recommended when streaming by deviceName. Required if the device name exists in multiple projects. Required when streaming by sessionKey.
Equivalent to deviceName, and ignored if deviceName is supplied
- Productionhttps://api.foxglove.dev/v1/data/stream
from foxglove.client import Client, CompressionFormat, OutputFormat
from datetime import datetime, timedelta
token = "<YOUR API TOKEN HERE>"
client = Client(token=token)
bytes = client.download_data(
device_id=device_id,
start=datetime.now() - timedelta(hours=3),
end=datetime.now() - timedelta(hours=1),
topics=["/clock", "/tracked_objects"],
output_format=OutputFormat.mcap,
compression_format=CompressionFormat.lz4,
callback=lambda progress: print(".", end=""),
)
# Or, to download using a recording ID:
bytes = client.download_recording_data(id="rec_0dHT6g6cOfff9m5U")