Skip to main content

Download data

Request

This endpoint returns a link URL where you can download your data as an .mcap or .bag file.

To download your data:

  1. Make a request to this endpoint.
  2. Make a GET request to the link URL.

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.

Security
ApiKey(Required scopes: data.stream)
Bodyapplication/jsonrequired
topicsArray of strings

List of topics to include in the exported file (defaults to all topics)

outputFormatstring

Output file format.

  • bag1 - output a .bag file
  • mcap - output a .mcap file
  • mcap0 - Deprecated. Use mcap.
Enum:"bag1""mcap""mcap0"
compressionFormatstring

Output compression format for chunks. Only valid if outputFormat is mcap.

  • "" - no compression
  • zstd - zstd compression
  • lz4 - LZ4 compression (default)
Default:"lz4"
Enum:"""zstd""lz4"
includeAttachmentsboolean

Include attachments in streamed data. One of recordingId or importId (deprecated) must also be set. Only valid for mcap outputFormat.

isHostedboolean

true if the import is hosted

replayPolicystring

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.

Enum:"lastPerChannel"""
replayLookbackSecondsnumber, >= 0

Maximum lookback before start, in seconds. Used only when replayPolicy is lastPerChannel.

deviceIdstring, non-empty

ID of device associated with the exported data

deviceNamestring, non-empty

Name of device associated with the exported data.

startstring, (date-time)

Inclusive start of requested time range. If start is provided, end must be too.

endstring, (date-time)

Inclusive end of requested time range. If end is provided, start must be too.

recordingIdstring, non-empty

ID of the recording to stream

recordingKeystring, non-empty

Key of recording to stream

sessionIdstring, non-empty

ID of a session to stream

sessionKeystring, non-empty

Key of a session to stream. Ensure projectId is provided if streaming by sessionKey.

episodeVersioninteger, [ 1 .. 2147483647 ]

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.

episodeIdstring, non-empty

ID of an episode to stream. start and end default to the episode's time window when omitted and may each be overridden independently.

projectIdstring, non-empty

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.

device.idstring, non-emptydeprecated

Equivalent to deviceId, and ignored if deviceId is supplied

device.namestring, non-emptydeprecated

Equivalent to deviceName, and ignored if deviceName is supplied

importIdstring, non-emptydeprecated

ID of the import to stream

keystring, non-emptydeprecated

Key of recording to 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")

Responses

Success

Bodyapplication/json
Response
{ "link": "string" }