# Stream ## List videos `stream.list(StreamListParams**kwargs) -> SyncSinglePage[Video]` **get** `/accounts/{account_id}/stream` Lists up to 1000 videos from a single request. For a specific range, refer to the optional parameters. ### Parameters - `account_id: str` The account identifier tag. - `asc: Optional[bool]` Lists videos in ascending order of creation. - `creator: Optional[str]` A user-defined identifier for the media creator. - `end: Optional[Union[str, datetime]]` Lists videos created before the specified date. - `include_counts: Optional[bool]` Includes the total number of videos associated with the submitted query parameters. - `search: Optional[str]` Provides a partial word match of the `name` key in the `meta` field. Slow for medium to large video libraries. May be unavailable for very large libraries. - `start: Optional[Union[str, datetime]]` Lists videos created after the specified date. - `status: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `type: Optional[str]` Specifies whether the video is `vod` or `live`. - `video_name: Optional[str]` Provides a fast, exact string match on the `name` key in the `meta` field. ### Returns - `class Video: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `created: Optional[datetime]` The date and time the media item was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `duration: Optional[float]` The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready. - `input: Optional[Input]` - `height: Optional[int]` The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready. - `width: Optional[int]` The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready. - `live_input: Optional[str]` The live input ID used to upload a video with Stream Live. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the media item was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `ready_to_stream: Optional[bool]` Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `ready_to_stream_at: Optional[datetime]` Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `size: Optional[float]` The size of the media item in bytes. - `status: Optional[Status]` Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details. - `error_reason_code: Optional[str]` Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use. - `error_reason_text: Optional[str]` Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state. - `pct_complete: Optional[str]` Indicates the progress as a percentage between 0 and 100. - `state: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail: Optional[str]` The media item's thumbnail URI. This field is omitted until encoding is complete. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `uploaded: Optional[datetime]` The date and time the media item was uploaded. - `upload_expiry: Optional[datetime]` The date and time when the video upload URL is no longer valid for direct user uploads. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "range": 1000, "result": [ { "allowedOrigins": [ "example.com" ], "created": "2014-01-02T02:20:00Z", "creator": "creator-id_abcde12345", "duration": 0, "input": { "height": 0, "width": 0 }, "liveInput": "fc0a8dc887b16759bfd9ad922230a014", "maxDurationSeconds": 1, "meta": { "name": "video12345.mp4" }, "modified": "2014-01-02T02:20:00Z", "playback": { "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd", "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8" }, "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch", "readyToStream": true, "readyToStreamAt": "2014-01-02T02:20:00Z", "requireSignedURLs": true, "scheduledDeletion": "2014-01-02T02:20:00Z", "size": 4190963, "status": { "errorReasonCode": "ERR_NON_VIDEO", "errorReasonText": "The file was not recognized as a valid video file.", "pctComplete": "pctComplete", "state": "inprogress" }, "thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg", "thumbnailTimestampPct": 0.529241, "uid": "ea95132c15732412d22c1476fa83f27a", "uploaded": "2014-01-02T02:20:00Z", "uploadExpiry": "2014-01-02T02:20:00Z", "watermark": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } ], "total": 35586 } ``` ## Retrieve video details `stream.get(stridentifier, StreamGetParams**kwargs) -> Video` **get** `/accounts/{account_id}/stream/{identifier}` Fetches details for a single video. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `class Video: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `created: Optional[datetime]` The date and time the media item was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `duration: Optional[float]` The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready. - `input: Optional[Input]` - `height: Optional[int]` The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready. - `width: Optional[int]` The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready. - `live_input: Optional[str]` The live input ID used to upload a video with Stream Live. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the media item was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `ready_to_stream: Optional[bool]` Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `ready_to_stream_at: Optional[datetime]` Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `size: Optional[float]` The size of the media item in bytes. - `status: Optional[Status]` Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details. - `error_reason_code: Optional[str]` Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use. - `error_reason_text: Optional[str]` Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state. - `pct_complete: Optional[str]` Indicates the progress as a percentage between 0 and 100. - `state: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail: Optional[str]` The media item's thumbnail URI. This field is omitted until encoding is complete. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `uploaded: Optional[datetime]` The date and time the media item was uploaded. - `upload_expiry: Optional[datetime]` The date and time when the video upload URL is no longer valid for direct user uploads. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) video = client.stream.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(video.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "allowedOrigins": [ "example.com" ], "created": "2014-01-02T02:20:00Z", "creator": "creator-id_abcde12345", "duration": 0, "input": { "height": 0, "width": 0 }, "liveInput": "fc0a8dc887b16759bfd9ad922230a014", "maxDurationSeconds": 1, "meta": { "name": "video12345.mp4" }, "modified": "2014-01-02T02:20:00Z", "playback": { "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd", "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8" }, "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch", "readyToStream": true, "readyToStreamAt": "2014-01-02T02:20:00Z", "requireSignedURLs": true, "scheduledDeletion": "2014-01-02T02:20:00Z", "size": 4190963, "status": { "errorReasonCode": "ERR_NON_VIDEO", "errorReasonText": "The file was not recognized as a valid video file.", "pctComplete": "pctComplete", "state": "inprogress" }, "thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg", "thumbnailTimestampPct": 0.529241, "uid": "ea95132c15732412d22c1476fa83f27a", "uploaded": "2014-01-02T02:20:00Z", "uploadExpiry": "2014-01-02T02:20:00Z", "watermark": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } } ``` ## Initiate video uploads using TUS `stream.create(StreamCreateParams**kwargs)` **post** `/accounts/{account_id}/stream` Initiates a video upload using the TUS protocol. On success, the server responds with a status code 201 (created) and includes a `location` header to indicate where the content should be uploaded. Refer to https://tus.io for protocol details. ### Parameters - `account_id: str` The account identifier tag. - `body: object` - `tus_resumable: Literal["1.0.0"]` Specifies the TUS protocol version. This value must be included in every upload request. Notes: The only supported version of TUS protocol is 1.0.0. - `"1.0.0"` - `upload_length: int` Indicates the size of the entire upload in bytes. The value must be a non-negative integer. - `direct_user: Optional[bool]` Provisions a URL to let your end users upload videos directly to Cloudflare Stream without exposing your API token to clients. - `upload_creator: Optional[str]` A user-defined identifier for the media creator. - `upload_metadata: Optional[str]` Comma-separated key-value pairs following the TUS protocol specification. Values are Base-64 encoded. Supported keys: `name`, `requiresignedurls`, `allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`, `maxdurationseconds`. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.stream.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", body={}, tus_resumable="1.0.0", upload_length=0, ) ``` #### Response ```json {} ``` ## Edit video details `stream.edit(stridentifier, StreamEditParams**kwargs) -> Video` **post** `/accounts/{account_id}/stream/{identifier}` Edit details for a single video. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `allowed_origins: Optional[SequenceNotStr[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `creator: Optional[str]` A user-defined identifier for the media creator. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[Union[str, datetime]]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `upload_expiry: Optional[Union[str, datetime]]` The date and time when the video upload URL is no longer valid for direct user uploads. ### Returns - `class Video: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `created: Optional[datetime]` The date and time the media item was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `duration: Optional[float]` The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready. - `input: Optional[Input]` - `height: Optional[int]` The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready. - `width: Optional[int]` The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready. - `live_input: Optional[str]` The live input ID used to upload a video with Stream Live. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the media item was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `ready_to_stream: Optional[bool]` Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `ready_to_stream_at: Optional[datetime]` Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `size: Optional[float]` The size of the media item in bytes. - `status: Optional[Status]` Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details. - `error_reason_code: Optional[str]` Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use. - `error_reason_text: Optional[str]` Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state. - `pct_complete: Optional[str]` Indicates the progress as a percentage between 0 and 100. - `state: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail: Optional[str]` The media item's thumbnail URI. This field is omitted until encoding is complete. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `uploaded: Optional[datetime]` The date and time the media item was uploaded. - `upload_expiry: Optional[datetime]` The date and time when the video upload URL is no longer valid for direct user uploads. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) video = client.stream.edit( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(video.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "allowedOrigins": [ "example.com" ], "created": "2014-01-02T02:20:00Z", "creator": "creator-id_abcde12345", "duration": 0, "input": { "height": 0, "width": 0 }, "liveInput": "fc0a8dc887b16759bfd9ad922230a014", "maxDurationSeconds": 1, "meta": { "name": "video12345.mp4" }, "modified": "2014-01-02T02:20:00Z", "playback": { "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd", "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8" }, "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch", "readyToStream": true, "readyToStreamAt": "2014-01-02T02:20:00Z", "requireSignedURLs": true, "scheduledDeletion": "2014-01-02T02:20:00Z", "size": 4190963, "status": { "errorReasonCode": "ERR_NON_VIDEO", "errorReasonText": "The file was not recognized as a valid video file.", "pctComplete": "pctComplete", "state": "inprogress" }, "thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg", "thumbnailTimestampPct": 0.529241, "uid": "ea95132c15732412d22c1476fa83f27a", "uploaded": "2014-01-02T02:20:00Z", "uploadExpiry": "2014-01-02T02:20:00Z", "watermark": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } } ``` ## Delete video `stream.delete(stridentifier, StreamDeleteParams**kwargs)` **delete** `/accounts/{account_id}/stream/{identifier}` Deletes a video and its copies from Cloudflare Stream. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.stream.delete( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) ``` #### Response ```json {} ``` ## Domain Types ### Allowed Origins - `str` ### Video - `class Video: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `created: Optional[datetime]` The date and time the media item was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `duration: Optional[float]` The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready. - `input: Optional[Input]` - `height: Optional[int]` The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready. - `width: Optional[int]` The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready. - `live_input: Optional[str]` The live input ID used to upload a video with Stream Live. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the media item was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `ready_to_stream: Optional[bool]` Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `ready_to_stream_at: Optional[datetime]` Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `size: Optional[float]` The size of the media item in bytes. - `status: Optional[Status]` Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details. - `error_reason_code: Optional[str]` Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use. - `error_reason_text: Optional[str]` Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state. - `pct_complete: Optional[str]` Indicates the progress as a percentage between 0 and 100. - `state: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail: Optional[str]` The media item's thumbnail URI. This field is omitted until encoding is complete. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `uploaded: Optional[datetime]` The date and time the media item was uploaded. - `upload_expiry: Optional[datetime]` The date and time when the video upload URL is no longer valid for direct user uploads. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. # Audio Tracks ## List additional audio tracks on a video `stream.audio_tracks.get(stridentifier, AudioTrackGetParams**kwargs) -> SyncSinglePage[Audio]` **get** `/accounts/{account_id}/stream/{identifier}/audio` Lists additional audio tracks on a video. Note this API will not return information for audio attached to the video upload. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `class Audio: …` - `default: Optional[bool]` Denotes whether the audio track will be played by default in a player. - `label: Optional[str]` A string to uniquely identify the track amongst other audio track labels for the specified video. - `status: Optional[Literal["queued", "ready", "error"]]` Specifies the processing status of the video. - `"queued"` - `"ready"` - `"error"` - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.audio_tracks.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "default": true, "label": "director commentary", "status": "queued", "uid": "ea95132c15732412d22c1476fa83f27a" } ] } ``` ## Edit additional audio tracks on a video `stream.audio_tracks.edit(straudio_identifier, AudioTrackEditParams**kwargs) -> Audio` **patch** `/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}` Edits additional audio tracks on a video. Editing the default status of an audio track to `true` will mark all other audio tracks on the video default status to `false`. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `audio_identifier: str` The unique identifier for an additional audio track. - `default: Optional[bool]` Denotes whether the audio track will be played by default in a player. - `label: Optional[str]` A string to uniquely identify the track amongst other audio track labels for the specified video. ### Returns - `class Audio: …` - `default: Optional[bool]` Denotes whether the audio track will be played by default in a player. - `label: Optional[str]` A string to uniquely identify the track amongst other audio track labels for the specified video. - `status: Optional[Literal["queued", "ready", "error"]]` Specifies the processing status of the video. - `"queued"` - `"ready"` - `"error"` - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) audio = client.stream.audio_tracks.edit( audio_identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(audio.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "default": true, "label": "director commentary", "status": "queued", "uid": "ea95132c15732412d22c1476fa83f27a" } } ``` ## Delete additional audio tracks on a video `stream.audio_tracks.delete(straudio_identifier, AudioTrackDeleteParams**kwargs) -> AudioTrackDeleteResponse` **delete** `/accounts/{account_id}/stream/{identifier}/audio/{audio_identifier}` Deletes additional audio tracks on a video. Deleting a default audio track is not allowed. You must assign another audio track as default prior to deletion. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `audio_identifier: str` The unique identifier for an additional audio track. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) audio_track = client.stream.audio_tracks.delete( audio_identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(audio_track) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "ok" } ``` ## Add audio tracks to a video `stream.audio_tracks.copy(stridentifier, AudioTrackCopyParams**kwargs) -> Audio` **post** `/accounts/{account_id}/stream/{identifier}/audio/copy` Adds an additional audio track to a video using the provided audio track URL. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `label: str` A string to uniquely identify the track amongst other audio track labels for the specified video. - `url: Optional[str]` An audio track URL. The server must be publicly routable and support `HTTP HEAD` requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` requests with a `content-range` header that includes the size of the file. ### Returns - `class Audio: …` - `default: Optional[bool]` Denotes whether the audio track will be played by default in a player. - `label: Optional[str]` A string to uniquely identify the track amongst other audio track labels for the specified video. - `status: Optional[Literal["queued", "ready", "error"]]` Specifies the processing status of the video. - `"queued"` - `"ready"` - `"error"` - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) audio = client.stream.audio_tracks.copy( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", label="director commentary", ) print(audio.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "default": true, "label": "director commentary", "status": "queued", "uid": "ea95132c15732412d22c1476fa83f27a" } } ``` ## Domain Types ### Audio - `class Audio: …` - `default: Optional[bool]` Denotes whether the audio track will be played by default in a player. - `label: Optional[str]` A string to uniquely identify the track amongst other audio track labels for the specified video. - `status: Optional[Literal["queued", "ready", "error"]]` Specifies the processing status of the video. - `"queued"` - `"ready"` - `"error"` - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. ### Audio Track Delete Response - `str` # Videos ## Storage use `stream.videos.storage_usage(VideoStorageUsageParams**kwargs) -> VideoStorageUsageResponse` **get** `/accounts/{account_id}/stream/storage-usage` Returns information about an account's storage use. ### Parameters - `account_id: str` The account identifier tag. - `creator: Optional[str]` A user-defined identifier for the media creator. ### Returns - `class VideoStorageUsageResponse: …` - `creator: Optional[str]` A user-defined identifier for the media creator. - `total_storage_minutes: Optional[int]` The total minutes of video content stored in the account. - `total_storage_minutes_limit: Optional[int]` The storage capacity alloted for the account. - `video_count: Optional[int]` The total count of videos associated with the account. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) response = client.stream.videos.storage_usage( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(response.video_count) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "creator": "creator-id_abcde12345", "totalStorageMinutes": 0, "totalStorageMinutesLimit": 0, "videoCount": 0 } } ``` ## Domain Types ### Video Storage Usage Response - `class VideoStorageUsageResponse: …` - `creator: Optional[str]` A user-defined identifier for the media creator. - `total_storage_minutes: Optional[int]` The total minutes of video content stored in the account. - `total_storage_minutes_limit: Optional[int]` The storage capacity alloted for the account. - `video_count: Optional[int]` The total count of videos associated with the account. # Clip ## Clip videos given a start and end time `stream.clip.create(ClipCreateParams**kwargs) -> Clip` **post** `/accounts/{account_id}/stream/clip` Clips a video based on the specified start and end times provided in seconds. ### Parameters - `account_id: str` The account identifier tag. - `clipped_from_video_uid: str` The unique video identifier (UID). - `end_time_seconds: int` Specifies the end time for the video clip in seconds. - `start_time_seconds: int` Specifies the start time for the video clip in seconds. - `allowed_origins: Optional[SequenceNotStr[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `creator: Optional[str]` A user-defined identifier for the media creator. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `watermark: Optional[Watermark]` - `uid: Optional[str]` The unique identifier for the watermark profile. ### Returns - `class Clip: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `clipped_from_video_uid: Optional[str]` The unique video identifier (UID). - `created: Optional[datetime]` The date and time the clip was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `end_time_seconds: Optional[int]` Specifies the end time for the video clip in seconds. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the live input was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `start_time_seconds: Optional[int]` Specifies the start time for the video clip in seconds. - `status: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `watermark: Optional[Watermark]` - `uid: Optional[str]` The unique identifier for the watermark profile. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) clip = client.stream.clip.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", clipped_from_video_uid="023e105f4ecef8ad9ca31a8372d0c353", end_time_seconds=0, start_time_seconds=0, ) print(clip.clipped_from_video_uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "allowedOrigins": [ "example.com" ], "clippedFromVideoUID": "023e105f4ecef8ad9ca31a8372d0c353", "created": "2014-01-02T02:20:00Z", "creator": "creator-id_abcde12345", "endTimeSeconds": 0, "maxDurationSeconds": 1, "meta": { "name": "video12345.mp4" }, "modified": "2014-01-02T02:20:00Z", "playback": { "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd", "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8" }, "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch", "requireSignedURLs": true, "startTimeSeconds": 0, "status": "inprogress", "thumbnailTimestampPct": 0.529241, "watermark": { "uid": "ea95132c15732412d22c1476fa83f27a" } } } ``` ## Domain Types ### Clip - `class Clip: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `clipped_from_video_uid: Optional[str]` The unique video identifier (UID). - `created: Optional[datetime]` The date and time the clip was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `end_time_seconds: Optional[int]` Specifies the end time for the video clip in seconds. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the live input was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `start_time_seconds: Optional[int]` Specifies the start time for the video clip in seconds. - `status: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `watermark: Optional[Watermark]` - `uid: Optional[str]` The unique identifier for the watermark profile. # Copy ## Upload videos from a URL `stream.copy.create(CopyCreateParams**kwargs) -> Video` **post** `/accounts/{account_id}/stream/copy` Uploads a video to Stream from a provided URL. ### Parameters - `account_id: str` The account identifier tag. - `url: str` A video's URL. The server must be publicly routable and support `HTTP HEAD` requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` requests with a `content-range` header that includes the size of the file. - `allowed_origins: Optional[SequenceNotStr[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `creator: Optional[str]` A user-defined identifier for the media creator. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[Union[str, datetime]]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `watermark: Optional[Watermark]` - `uid: Optional[str]` The unique identifier for the watermark profile. - `upload_creator: Optional[str]` A user-defined identifier for the media creator. ### Returns - `class Video: …` - `allowed_origins: Optional[List[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `created: Optional[datetime]` The date and time the media item was created. - `creator: Optional[str]` A user-defined identifier for the media creator. - `duration: Optional[float]` The duration of the video in seconds. A value of `-1` means the duration is unknown. The duration becomes available after the upload and before the video is ready. - `input: Optional[Input]` - `height: Optional[int]` The video height in pixels. A value of `-1` means the height is unknown. The value becomes available after the upload and before the video is ready. - `width: Optional[int]` The video width in pixels. A value of `-1` means the width is unknown. The value becomes available after the upload and before the video is ready. - `live_input: Optional[str]` The live input ID used to upload a video with Stream Live. - `max_duration_seconds: Optional[int]` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `modified: Optional[datetime]` The date and time the media item was last modified. - `playback: Optional[Playback]` - `dash: Optional[str]` DASH Media Presentation Description for the video. - `hls: Optional[str]` The HLS manifest for the video. - `preview: Optional[str]` The video's preview page URI. This field is omitted until encoding is complete. - `ready_to_stream: Optional[bool]` Indicates whether the video is playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `ready_to_stream_at: Optional[datetime]` Indicates the time at which the video became playable. The field is empty if the video is not ready for viewing or the live stream is still in progress. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `size: Optional[float]` The size of the media item in bytes. - `status: Optional[Status]` Specifies a detailed status for a video. If the `state` is `inprogress` or `error`, the `step` field returns `encoding` or `manifest`. If the `state` is `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the approximate percent of completion. If the `state` is `error`, `errorReasonCode` and `errorReasonText` provide additional details. - `error_reason_code: Optional[str]` Specifies why the video failed to encode. This field is empty if the video is not in an `error` state. Preferred for programmatic use. - `error_reason_text: Optional[str]` Specifies why the video failed to encode using a human readable error message in English. This field is empty if the video is not in an `error` state. - `pct_complete: Optional[str]` Indicates the progress as a percentage between 0 and 100. - `state: Optional[Literal["pendingupload", "downloading", "queued", 4 more]]` Specifies the processing status for all quality levels for a video. - `"pendingupload"` - `"downloading"` - `"queued"` - `"inprogress"` - `"ready"` - `"error"` - `"live-inprogress"` - `thumbnail: Optional[str]` The media item's thumbnail URI. This field is omitted until encoding is complete. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `uploaded: Optional[datetime]` The date and time the media item was uploaded. - `upload_expiry: Optional[datetime]` The date and time when the video upload URL is no longer valid for direct user uploads. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) video = client.stream.copy.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", url="https://example.com/myvideo.mp4", ) print(video.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "allowedOrigins": [ "example.com" ], "created": "2014-01-02T02:20:00Z", "creator": "creator-id_abcde12345", "duration": 0, "input": { "height": 0, "width": 0 }, "liveInput": "fc0a8dc887b16759bfd9ad922230a014", "maxDurationSeconds": 1, "meta": { "name": "video12345.mp4" }, "modified": "2014-01-02T02:20:00Z", "playback": { "dash": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.mpd", "hls": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/manifest/video.m3u8" }, "preview": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/watch", "readyToStream": true, "readyToStreamAt": "2014-01-02T02:20:00Z", "requireSignedURLs": true, "scheduledDeletion": "2014-01-02T02:20:00Z", "size": 4190963, "status": { "errorReasonCode": "ERR_NON_VIDEO", "errorReasonText": "The file was not recognized as a valid video file.", "pctComplete": "pctComplete", "state": "inprogress" }, "thumbnail": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/thumbnails/thumbnail.jpg", "thumbnailTimestampPct": 0.529241, "uid": "ea95132c15732412d22c1476fa83f27a", "uploaded": "2014-01-02T02:20:00Z", "uploadExpiry": "2014-01-02T02:20:00Z", "watermark": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } } ``` # Direct Upload ## Upload videos via direct upload URLs `stream.direct_upload.create(DirectUploadCreateParams**kwargs) -> DirectUploadCreateResponse` **post** `/accounts/{account_id}/stream/direct_upload` Creates a direct upload that allows video uploads without an API key. ### Parameters - `account_id: str` The account identifier tag. - `max_duration_seconds: int` The maximum duration in seconds for a video upload. Can be set for a video that is not yet uploaded to limit its duration. Uploads that exceed the specified duration will fail during processing. A value of `-1` means the value is unknown. - `allowed_origins: Optional[SequenceNotStr[AllowedOrigins]]` Lists the origins allowed to display the video. Enter allowed origin domains in an array and use `*` for wildcard subdomains. Empty arrays allow the video to be viewed on any origin. - `creator: Optional[str]` A user-defined identifier for the media creator. - `expiry: Optional[Union[str, datetime]]` The date and time after upload when videos will not be accepted. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing videos. - `require_signed_urls: Optional[bool]` Indicates whether the video can be a accessed using the UID. When set to `true`, a signed token must be generated with a signing key to view the video. - `scheduled_deletion: Optional[Union[str, datetime]]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `thumbnail_timestamp_pct: Optional[float]` The timestamp for a thumbnail image calculated as a percentage value of the video's duration. To convert from a second-wise timestamp to a percentage, divide the desired timestamp by the total duration of the video. If this value is not set, the default thumbnail image is taken from 0s of the video. - `watermark: Optional[Watermark]` - `uid: Optional[str]` The unique identifier for the watermark profile. - `upload_creator: Optional[str]` A user-defined identifier for the media creator. ### Returns - `class DirectUploadCreateResponse: …` - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `upload_url: Optional[str]` The URL an unauthenticated upload can use for a single `HTTP POST multipart/form-data` request. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) direct_upload = client.stream.direct_upload.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", max_duration_seconds=1, ) print(direct_upload.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "scheduledDeletion": "2014-01-02T02:20:00Z", "uid": "ea95132c15732412d22c1476fa83f27a", "uploadURL": "www.example.com/samplepath", "watermark": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } } ``` ## Domain Types ### Direct Upload Create Response - `class DirectUploadCreateResponse: …` - `scheduled_deletion: Optional[datetime]` Indicates the date and time at which the video will be deleted. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. If specified, must be at least 30 days from upload time. - `uid: Optional[str]` A Cloudflare-generated unique identifier for a media item. - `upload_url: Optional[str]` The URL an unauthenticated upload can use for a single `HTTP POST multipart/form-data` request. - `watermark: Optional[Watermark]` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. # Keys ## List signing keys `stream.keys.get(KeyGetParams**kwargs) -> SyncSinglePage[KeyGetResponse]` **get** `/accounts/{account_id}/stream/keys` Lists the video ID and creation date and time when a signing key was created. ### Parameters - `account_id: str` Identifier. ### Returns - `class KeyGetResponse: …` - `id: Optional[str]` Identifier. - `created: Optional[datetime]` The date and time a signing key was created. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.keys.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "023e105f4ecef8ad9ca31a8372d0c353", "created": "2014-01-02T02:20:00Z" } ] } ``` ## Create signing keys `stream.keys.create(KeyCreateParams**kwargs) -> Keys` **post** `/accounts/{account_id}/stream/keys` Creates an RSA private key in PEM and JWK formats. Key files are only displayed once after creation. Keys are created, used, and deleted independently of videos, and every key can sign any video. ### Parameters - `account_id: str` Identifier. - `body: object` ### Returns - `class Keys: …` - `id: Optional[str]` Identifier. - `created: Optional[datetime]` The date and time a signing key was created. - `jwk: Optional[str]` The signing key in JWK format. - `pem: Optional[str]` The signing key in PEM format. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) keys = client.stream.keys.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", body={}, ) print(keys.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "created": "2014-01-02T02:20:00Z", "jwk": "eyJ1c2UiOiJzaWciLCJrdHkiOiJSU0EiLCJraWQiOiI1MjEzY2ZhMTIxZjcwYjhjMTM4MDY4NmZmYzM3MWJhMyIsImFsZyI6IlJTMjU2IiwibiI6IjBUandqT2laV21KNDN2ZjNUbzREb1htWFd0SkdOR3lYZmh5dHRMYUJnRjEtRVFXUURLaG9LYm9hS21xakNBc21za3V0YkxVN1BVOGRrUU5ER1p3S3VWczA4elNaNGt4aTR0RWdQUFp5dDdkWEMtbFlSWW95ckFHRjRBWGh5MzI5YkhDUDFJbHJCQl9Ba0dnbmRMQWd1bnhZMHJSZ2N2T3ppYXc2S0p4Rm5jMlVLMFdVOGIwcDRLS0hHcDFLTDlkazBXVDhkVllxYmVSaUpqQ2xVRW1oOHl2OUNsT1ZhUzRLeGlYNnhUUTREWnc2RGFKZklWM1F0Tmd2cG1ieWxOSmFQSG5zc3JodDJHS1A5NjJlS2poUVJsaWd2SFhKTE9uSm9KZkxlSUVIWi1peFdmY1RETUg5MnNHdm93MURPanhMaUNOMXpISy1oN2JMb1hUaUxnYzRrdyIsImUiOiJBUUFCIiwiZCI6IndpQWEwaU5mWnNYSGNOcVMxSWhnUmdzVHJHay1TcFlYV2lReDZHTU9kWlJKekhGazN0bkRERFJvNHNKZTBxX0dEOWkzNlEyZkVadS15elpEcEJkc3U5OHNtaHhNU19Ta0s5X3VFYUo1Zm96V2IyN3JRRnFoLVliUU9MUThkUnNPRHZmQl9Hb2txWWJzblJDR3kzWkFaOGZJZ25ocXBUNEpiOHdsaWxpMUgxeFpzM3RnTWtkTEluTm1yMFAtcTYxZEtNd3JYZVRoSWNEc0kyb2Z1LTFtRm1MWndQb2ZGbmxaTW9QN1pfRU5pUGNfWGtWNzFhaHBOZE9pcW5ablZtMHBCNE5QS1UweDRWTjQyYlAzWEhMUmpkV2hJOGt3SC1BdXhqb3BLaHJ0R2tvcG1jZFRkM1ZRdElaOGRpZHByMXpBaEpvQi16ZVlIaTFUel9ZSFFld0FRUSIsInAiOiIyVTZFVUJka3U3TndDYXoyNzZuWGMxRXgwVHpNZjU4U0UtU2M2eUNaYWk2TkwzVURpWi1mNHlIdkRLYnFGUXdLWDNwZ0l2aVE3Y05QYUpkbE9NeS1mU21GTXU3V3hlbVZYamFlTjJCMkRDazhQY0NEOVgxU2hhR3E1ZUdSSHNObVUtSDNxTG1FRGpjLWliazRHZ0RNb2lVYjQ2OGxFZHAwU2pIOXdsOUdsYTgiLCJxIjoiOW5ucXg5ZnNNY2dIZ29DemhfVjJmaDhoRUxUSUM5aFlIOVBCTG9aQjZIaE1TWG1ja1BSazVnUlpPWlFEN002TzlMaWZjNmFDVXdEbjBlQzU2YkFDNUNrcWxjODJsVDhzTWlMeWJyTjh3bWotcjNjSTBGQTlfSGQySEY1ZkgycnJmenVqd0NWM3czb09Ud3p4d1g3c2xKbklRanphel91SzEyWEtucVZZcUYwIiwiZHAiOiJxQklTUTlfVUNWaV9Ucng0UU9VYnZoVU9jc2FUWkNHajJiNzNudU9YeElnOHFuZldSSnN4RG5zd2FKaXdjNWJjYnZ3M1h0VGhRd1BNWnhpeE1UMHFGNlFGWVY5WXZibnJ6UEp4YkdNdTZqajZYc2lIUjFlbWU3U09lVDM4Xzg0aFZyOXV6UkN2RWstb0R0MHlodW9YVzFGWVFNRTE2cGtMV0ZkUjdRUERsQUUiLCJkcSI6Im5zQUp3eXZFbW8tdW5wU01qYjVBMHB6MExCRjBZNFMxeGRJYXNfLVBSYzd0dThsVFdWMl8teExEOFR6dmhqX0lmY0RJR3JJZGNKNjlzVVZnR1M3ZnZkcng3Y21uNjFyai1XcmU0UVJFRC1lV1dxZDlpc2FVRmg5UGVKZ2tCbFZVVnYtdnladVlWdFF2a1NUU05ZR3RtVXl2V2xKZDBPWEFHRm9jdGlfak9aVSIsInFpIjoib0dYaWxLQ2NKRXNFdEE1eG54WUdGQW5UUjNwdkZLUXR5S0F0UGhHaHkybm5ya2VzN1RRaEFxMGhLRWZtU1RzaE1hNFhfd05aMEstX1F0dkdoNDhpeHdTTDVLTEwxZnFsY0k2TF9XUnF0cFQxS21LRERlUHR2bDVCUzFGbjgwSGFwR215cmZRWUU4S09QR2UwUl82S1BOZE1vc3dYQ3Nfd0RYMF92ZzNoNUxRIn0=", "pem": "LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcGdJQkFBS0NBUUVBMFRqd2pPaVpXbUo0M3ZmM1RvNERvWG1YV3RKR05HeVhmaHl0dExhQmdGMStFUVdRCkRLaG9LYm9hS21xakNBc21za3V0YkxVN1BVOGRrUU5ER1p3S3VWczA4elNaNGt4aTR0RWdQUFp5dDdkWEMrbFkKUllveXJBR0Y0QVhoeTMyOWJIQ1AxSWxyQkIvQWtHZ25kTEFndW54WTByUmdjdk96aWF3NktKeEZuYzJVSzBXVQo4YjBwNEtLSEdwMUtMOWRrMFdUOGRWWXFiZVJpSmpDbFVFbWg4eXY5Q2xPVmFTNEt4aVg2eFRRNERadzZEYUpmCklWM1F0Tmd2cG1ieWxOSmFQSG5zc3JodDJHS1A5NjJlS2poUVJsaWd2SFhKTE9uSm9KZkxlSUVIWitpeFdmY1QKRE1IOTJzR3ZvdzFET2p4TGlDTjF6SEsraDdiTG9YVGlMZ2M0a3dJREFRQUJBb0lCQVFEQ0lCclNJMTlteGNkdwoycExVaUdCR0N4T3NhVDVLbGhkYUpESG9ZdzUxbEVuTWNXVGUyY01NTkdqaXdsN1NyOFlQMkxmcERaOFJtNzdMCk5rT2tGMnk3M3l5YUhFeEw5S1FyMys0Um9ubCtqTlp2YnV0QVdxSDVodEE0dER4MUd3NE85OEg4YWlTcGh1eWQKRUliTGRrQm54OGlDZUdxbFBnbHZ6Q1dLV0xVZlhGbXplMkF5UjBzaWMyYXZRLzZyclYwb3pDdGQ1T0Vod093agphaCs3N1dZV1l0bkEraDhXZVZreWcvdG44UTJJOXo5ZVJYdlZxR2sxMDZLcWRtZFdiU2tIZzA4cFRUSGhVM2paCnMvZGNjdEdOMWFFanlUQWY0QzdHT2lrcUd1MGFTaW1aeDFOM2RWQzBobngySjJtdlhNQ0VtZ0g3TjVnZUxWUFAKOWdkQjdBQkJBb0dCQU5sT2hGQVhaTHV6Y0Ftczl1K3AxM05STWRFOHpIK2ZFaFBrbk9zZ21Xb3VqUzkxQTRtZgpuK01oN3d5bTZoVU1DbDk2WUNMNGtPM0RUMmlYWlRqTXZuMHBoVEx1MXNYcGxWNDJuamRnZGd3cFBEM0FnL1Y5ClVvV2hxdVhoa1I3RFpsUGg5Nmk1aEE0M1BvbTVPQm9BektJbEcrT3ZKUkhhZEVveC9jSmZScFd2QW9HQkFQWjUKNnNmWDdESElCNEtBczRmMWRuNGZJUkMweUF2WVdCL1R3UzZHUWVoNFRFbDVuSkQwWk9ZRVdUbVVBK3pPanZTNApuM09tZ2xNQTU5SGd1ZW13QXVRcEtwWFBOcFUvTERJaThtNnpmTUpvL3E5M0NOQlFQZngzZGh4ZVh4OXE2Mzg3Cm84QWxkOE42RGs4TThjRis3SlNaeUVJODJzLzdpdGRseXA2bFdLaGRBb0dCQUtnU0VrUGYxQWxZdjA2OGVFRGwKRzc0VkRuTEdrMlFobzltKzk1N2psOFNJUEtwMzFrU2JNUTU3TUdpWXNIT1czRzc4TjE3VTRVTUR6R2NZc1RFOQpLaGVrQldGZldMMjU2OHp5Y1d4akx1bzQrbDdJaDBkWHBudTBqbms5L1AvT0lWYS9iczBRcnhKUHFBN2RNb2JxCkYxdFJXRURCTmVxWkMxaFhVZTBEdzVRQkFvR0JBSjdBQ2NNcnhKcVBycDZVakkyK1FOS2M5Q3dSZEdPRXRjWFMKR3JQL2owWE83YnZKVTFsZHYvc1N3L0U4NzRZL3lIM0F5QnF5SFhDZXZiRkZZQmt1MzczYThlM0pwK3RhNC9scQozdUVFUkEvbmxscW5mWXJHbEJZZlQzaVlKQVpWVkZiL3I4bWJtRmJVTDVFazBqV0JyWmxNcjFwU1hkRGx3QmhhCkhMWXY0em1WQW9HQkFLQmw0cFNnbkNSTEJMUU9jWjhXQmhRSjAwZDZieFNrTGNpZ0xUNFJvY3RwNTY1SHJPMDAKSVFLdElTaEg1a2s3SVRHdUYvOERXZEN2djBMYnhvZVBJc2NFaStTaXk5WDZwWENPaS8xa2FyYVU5U3BpZ3czago3YjVlUVV0UlovTkIycVJwc3EzMEdCUENqanhudEVmK2lqelhUS0xNRndyUDhBMTlQNzRONGVTMAotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=" } } ``` ## Delete signing keys `stream.keys.delete(stridentifier, KeyDeleteParams**kwargs) -> KeyDeleteResponse` **delete** `/accounts/{account_id}/stream/keys/{identifier}` Deletes signing keys and revokes all signed URLs generated with the key. ### Parameters - `account_id: str` Identifier. - `identifier: str` Identifier. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) key = client.stream.keys.delete( identifier="023e105f4ecef8ad9ca31a8372d0c353", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(key) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "ok" } ``` ## Domain Types ### Keys - `class Keys: …` - `id: Optional[str]` Identifier. - `created: Optional[datetime]` The date and time a signing key was created. - `jwk: Optional[str]` The signing key in JWK format. - `pem: Optional[str]` The signing key in PEM format. ### Key Get Response - `class KeyGetResponse: …` - `id: Optional[str]` Identifier. - `created: Optional[datetime]` The date and time a signing key was created. ### Key Delete Response - `str` # Live Inputs ## List live inputs `stream.live_inputs.list(LiveInputListParams**kwargs) -> LiveInputListResponse` **get** `/accounts/{account_id}/stream/live_inputs` Lists the live inputs created for an account. To get the credentials needed to stream to a specific live input, request a single live input. ### Parameters - `account_id: str` Identifier. - `include_counts: Optional[bool]` Includes the total number of videos associated with the submitted query parameters. ### Returns - `class LiveInputListResponse: …` - `live_inputs: Optional[List[LiveInput]]` - `created: Optional[datetime]` The date and time the live input was created. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `modified: Optional[datetime]` The date and time the live input was last modified. - `uid: Optional[str]` A unique identifier for a live input. - `range: Optional[int]` The total number of remaining live inputs based on cursor position. - `total: Optional[int]` The total number of live inputs that match the provided filters. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) live_inputs = client.stream.live_inputs.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(live_inputs.live_inputs) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "liveInputs": [ { "created": "2014-01-02T02:20:00Z", "deleteRecordingAfterDays": 45, "enabled": true, "meta": { "name": "test stream 1" }, "modified": "2014-01-02T02:20:00Z", "uid": "66be4bf738797e01e1fca35a7bdecdcd" } ], "range": 1000, "total": 35586 } } ``` ## Retrieve a live input `stream.live_inputs.get(strlive_input_identifier, LiveInputGetParams**kwargs) -> LiveInput` **get** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}` Retrieves details of an existing live input. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. ### Returns - `class LiveInput: …` Details about a live input. - `created: Optional[datetime]` The date and time the live input was created. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `modified: Optional[datetime]` The date and time the live input was last modified. - `recording: Optional[Recording]` Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied. - `allowed_origins: Optional[List[str]]` Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin. - `hide_live_viewer_count: Optional[bool]` Disables reporting the number of live viewers when this property is set to `true`. - `mode: Optional[Literal["off", "automatic"]]` Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input. - `"off"` - `"automatic"` - `require_signed_urls: Optional[bool]` Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input. - `timeout_seconds: Optional[int]` Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used. - `rtmps: Optional[Rtmps]` Details for streaming to an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use when streaming via RTMPS to a live input. - `url: Optional[str]` The RTMPS URL you provide to the broadcaster, which they stream live video to. - `rtmps_playback: Optional[RtmpsPlayback]` Details for playback from an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use for playback via RTMPS. - `url: Optional[str]` The URL used to play live video over RTMPS. - `srt: Optional[Srt]` Details for streaming to a live input using SRT. - `passphrase: Optional[str]` The secret key to use when streaming via SRT to a live input. - `stream_id: Optional[str]` The identifier of the live input to use when streaming via SRT. - `url: Optional[str]` The SRT URL you provide to the broadcaster, which they stream live video to. - `srt_playback: Optional[SrtPlayback]` Details for playback from an live input using SRT. - `passphrase: Optional[str]` The secret key to use for playback via SRT. - `stream_id: Optional[str]` The identifier of the live input to use for playback via SRT. - `url: Optional[str]` The URL used to play live video over SRT. - `status: Optional[Literal["connected", "reconnected", "reconnecting", 5 more]]` The connection status of a live input. - `"connected"` - `"reconnected"` - `"reconnecting"` - `"client_disconnect"` - `"ttl_exceeded"` - `"failed_to_connect"` - `"failed_to_reconnect"` - `"new_configuration_accepted"` - `uid: Optional[str]` A unique identifier for a live input. - `web_rtc: Optional[WebRtc]` Details for streaming to a live input using WebRTC. - `url: Optional[str]` The WebRTC URL you provide to the broadcaster, which they stream live video to. - `web_rtc_playback: Optional[WebRtcPlayback]` Details for playback from a live input using WebRTC. - `url: Optional[str]` The URL used to play live video over WebRTC. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) live_input = client.stream.live_inputs.get( live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(live_input.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "created": "2014-01-02T02:20:00Z", "deleteRecordingAfterDays": 45, "enabled": true, "meta": { "name": "test stream 1" }, "modified": "2014-01-02T02:20:00Z", "recording": { "allowedOrigins": [ "example.com" ], "hideLiveViewerCount": false, "mode": "off", "requireSignedURLs": false, "timeoutSeconds": 0 }, "rtmps": { "streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "url": "rtmps://live.cloudflare.com:443/live/" }, "rtmpsPlayback": { "streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "url": "rtmps://live.cloudflare.com:443/live/" }, "srt": { "passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "streamId": "f256e6ea9341d51eea64c9454659e576", "url": "srt://live.cloudflare.com:778" }, "srtPlayback": { "passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "streamId": "f256e6ea9341d51eea64c9454659e576", "url": "rtmps://live.cloudflare.com:443/live/" }, "status": "connected", "uid": "66be4bf738797e01e1fca35a7bdecdcd", "webRTC": { "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/publish" }, "webRTCPlayback": { "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/play" } } } ``` ## Create a live input `stream.live_inputs.create(LiveInputCreateParams**kwargs) -> LiveInput` **post** `/accounts/{account_id}/stream/live_inputs` Creates a live input, and returns credentials that you or your users can use to stream live video to Cloudflare Stream. ### Parameters - `account_id: str` Identifier. - `default_creator: Optional[str]` Sets the creator ID asssociated with this live input. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `recording: Optional[Recording]` Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied. - `allowed_origins: Optional[SequenceNotStr[str]]` Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin. - `hide_live_viewer_count: Optional[bool]` Disables reporting the number of live viewers when this property is set to `true`. - `mode: Optional[Literal["off", "automatic"]]` Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input. - `"off"` - `"automatic"` - `require_signed_urls: Optional[bool]` Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input. - `timeout_seconds: Optional[int]` Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used. ### Returns - `class LiveInput: …` Details about a live input. - `created: Optional[datetime]` The date and time the live input was created. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `modified: Optional[datetime]` The date and time the live input was last modified. - `recording: Optional[Recording]` Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied. - `allowed_origins: Optional[List[str]]` Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin. - `hide_live_viewer_count: Optional[bool]` Disables reporting the number of live viewers when this property is set to `true`. - `mode: Optional[Literal["off", "automatic"]]` Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input. - `"off"` - `"automatic"` - `require_signed_urls: Optional[bool]` Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input. - `timeout_seconds: Optional[int]` Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used. - `rtmps: Optional[Rtmps]` Details for streaming to an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use when streaming via RTMPS to a live input. - `url: Optional[str]` The RTMPS URL you provide to the broadcaster, which they stream live video to. - `rtmps_playback: Optional[RtmpsPlayback]` Details for playback from an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use for playback via RTMPS. - `url: Optional[str]` The URL used to play live video over RTMPS. - `srt: Optional[Srt]` Details for streaming to a live input using SRT. - `passphrase: Optional[str]` The secret key to use when streaming via SRT to a live input. - `stream_id: Optional[str]` The identifier of the live input to use when streaming via SRT. - `url: Optional[str]` The SRT URL you provide to the broadcaster, which they stream live video to. - `srt_playback: Optional[SrtPlayback]` Details for playback from an live input using SRT. - `passphrase: Optional[str]` The secret key to use for playback via SRT. - `stream_id: Optional[str]` The identifier of the live input to use for playback via SRT. - `url: Optional[str]` The URL used to play live video over SRT. - `status: Optional[Literal["connected", "reconnected", "reconnecting", 5 more]]` The connection status of a live input. - `"connected"` - `"reconnected"` - `"reconnecting"` - `"client_disconnect"` - `"ttl_exceeded"` - `"failed_to_connect"` - `"failed_to_reconnect"` - `"new_configuration_accepted"` - `uid: Optional[str]` A unique identifier for a live input. - `web_rtc: Optional[WebRtc]` Details for streaming to a live input using WebRTC. - `url: Optional[str]` The WebRTC URL you provide to the broadcaster, which they stream live video to. - `web_rtc_playback: Optional[WebRtcPlayback]` Details for playback from a live input using WebRTC. - `url: Optional[str]` The URL used to play live video over WebRTC. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) live_input = client.stream.live_inputs.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(live_input.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "created": "2014-01-02T02:20:00Z", "deleteRecordingAfterDays": 45, "enabled": true, "meta": { "name": "test stream 1" }, "modified": "2014-01-02T02:20:00Z", "recording": { "allowedOrigins": [ "example.com" ], "hideLiveViewerCount": false, "mode": "off", "requireSignedURLs": false, "timeoutSeconds": 0 }, "rtmps": { "streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "url": "rtmps://live.cloudflare.com:443/live/" }, "rtmpsPlayback": { "streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "url": "rtmps://live.cloudflare.com:443/live/" }, "srt": { "passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "streamId": "f256e6ea9341d51eea64c9454659e576", "url": "srt://live.cloudflare.com:778" }, "srtPlayback": { "passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "streamId": "f256e6ea9341d51eea64c9454659e576", "url": "rtmps://live.cloudflare.com:443/live/" }, "status": "connected", "uid": "66be4bf738797e01e1fca35a7bdecdcd", "webRTC": { "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/publish" }, "webRTCPlayback": { "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/play" } } } ``` ## Update a live input `stream.live_inputs.update(strlive_input_identifier, LiveInputUpdateParams**kwargs) -> LiveInput` **put** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}` Updates a specified live input. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. - `default_creator: Optional[str]` Sets the creator ID asssociated with this live input. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `recording: Optional[Recording]` Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied. - `allowed_origins: Optional[SequenceNotStr[str]]` Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin. - `hide_live_viewer_count: Optional[bool]` Disables reporting the number of live viewers when this property is set to `true`. - `mode: Optional[Literal["off", "automatic"]]` Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input. - `"off"` - `"automatic"` - `require_signed_urls: Optional[bool]` Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input. - `timeout_seconds: Optional[int]` Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used. ### Returns - `class LiveInput: …` Details about a live input. - `created: Optional[datetime]` The date and time the live input was created. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `modified: Optional[datetime]` The date and time the live input was last modified. - `recording: Optional[Recording]` Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied. - `allowed_origins: Optional[List[str]]` Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin. - `hide_live_viewer_count: Optional[bool]` Disables reporting the number of live viewers when this property is set to `true`. - `mode: Optional[Literal["off", "automatic"]]` Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input. - `"off"` - `"automatic"` - `require_signed_urls: Optional[bool]` Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input. - `timeout_seconds: Optional[int]` Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used. - `rtmps: Optional[Rtmps]` Details for streaming to an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use when streaming via RTMPS to a live input. - `url: Optional[str]` The RTMPS URL you provide to the broadcaster, which they stream live video to. - `rtmps_playback: Optional[RtmpsPlayback]` Details for playback from an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use for playback via RTMPS. - `url: Optional[str]` The URL used to play live video over RTMPS. - `srt: Optional[Srt]` Details for streaming to a live input using SRT. - `passphrase: Optional[str]` The secret key to use when streaming via SRT to a live input. - `stream_id: Optional[str]` The identifier of the live input to use when streaming via SRT. - `url: Optional[str]` The SRT URL you provide to the broadcaster, which they stream live video to. - `srt_playback: Optional[SrtPlayback]` Details for playback from an live input using SRT. - `passphrase: Optional[str]` The secret key to use for playback via SRT. - `stream_id: Optional[str]` The identifier of the live input to use for playback via SRT. - `url: Optional[str]` The URL used to play live video over SRT. - `status: Optional[Literal["connected", "reconnected", "reconnecting", 5 more]]` The connection status of a live input. - `"connected"` - `"reconnected"` - `"reconnecting"` - `"client_disconnect"` - `"ttl_exceeded"` - `"failed_to_connect"` - `"failed_to_reconnect"` - `"new_configuration_accepted"` - `uid: Optional[str]` A unique identifier for a live input. - `web_rtc: Optional[WebRtc]` Details for streaming to a live input using WebRTC. - `url: Optional[str]` The WebRTC URL you provide to the broadcaster, which they stream live video to. - `web_rtc_playback: Optional[WebRtcPlayback]` Details for playback from a live input using WebRTC. - `url: Optional[str]` The URL used to play live video over WebRTC. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) live_input = client.stream.live_inputs.update( live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(live_input.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "created": "2014-01-02T02:20:00Z", "deleteRecordingAfterDays": 45, "enabled": true, "meta": { "name": "test stream 1" }, "modified": "2014-01-02T02:20:00Z", "recording": { "allowedOrigins": [ "example.com" ], "hideLiveViewerCount": false, "mode": "off", "requireSignedURLs": false, "timeoutSeconds": 0 }, "rtmps": { "streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "url": "rtmps://live.cloudflare.com:443/live/" }, "rtmpsPlayback": { "streamKey": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "url": "rtmps://live.cloudflare.com:443/live/" }, "srt": { "passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "streamId": "f256e6ea9341d51eea64c9454659e576", "url": "srt://live.cloudflare.com:778" }, "srtPlayback": { "passphrase": "2fb3cb9f17e68a2568d6ebed8d5505eak3ceaf8c9b1f395e1b76b79332497cada", "streamId": "f256e6ea9341d51eea64c9454659e576", "url": "rtmps://live.cloudflare.com:443/live/" }, "status": "connected", "uid": "66be4bf738797e01e1fca35a7bdecdcd", "webRTC": { "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/publish" }, "webRTCPlayback": { "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/b236bde30eb07b9d01318940e5fc3edake34a3efb3896e18f2dc277ce6cc993ad/webRTC/play" } } } ``` ## Delete a live input `stream.live_inputs.delete(strlive_input_identifier, LiveInputDeleteParams**kwargs)` **delete** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}` Prevents a live input from being streamed to and makes the live input inaccessible to any future API calls. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.stream.live_inputs.delete( live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) ``` #### Response ```json {} ``` ## Domain Types ### Live Input - `class LiveInput: …` Details about a live input. - `created: Optional[datetime]` The date and time the live input was created. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `modified: Optional[datetime]` The date and time the live input was last modified. - `recording: Optional[Recording]` Records the input to a Cloudflare Stream video. Behavior depends on the mode. In most cases, the video will initially be viewable as a live video and transition to on-demand after a condition is satisfied. - `allowed_origins: Optional[List[str]]` Lists the origins allowed to display videos created with this input. Enter allowed origin domains in an array and use `*` for wildcard subdomains. An empty array allows videos to be viewed on any origin. - `hide_live_viewer_count: Optional[bool]` Disables reporting the number of live viewers when this property is set to `true`. - `mode: Optional[Literal["off", "automatic"]]` Specifies the recording behavior for the live input. Set this value to `off` to prevent a recording. Set the value to `automatic` to begin a recording and transition to on-demand after Stream Live stops receiving input. - `"off"` - `"automatic"` - `require_signed_urls: Optional[bool]` Indicates if a video using the live input has the `requireSignedURLs` property set. Also enforces access controls on any video recording of the livestream with the live input. - `timeout_seconds: Optional[int]` Determines the amount of time a live input configured in `automatic` mode should wait before a recording transitions from live to on-demand. `0` is recommended for most use cases and indicates the platform default should be used. - `rtmps: Optional[Rtmps]` Details for streaming to an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use when streaming via RTMPS to a live input. - `url: Optional[str]` The RTMPS URL you provide to the broadcaster, which they stream live video to. - `rtmps_playback: Optional[RtmpsPlayback]` Details for playback from an live input using RTMPS. - `stream_key: Optional[str]` The secret key to use for playback via RTMPS. - `url: Optional[str]` The URL used to play live video over RTMPS. - `srt: Optional[Srt]` Details for streaming to a live input using SRT. - `passphrase: Optional[str]` The secret key to use when streaming via SRT to a live input. - `stream_id: Optional[str]` The identifier of the live input to use when streaming via SRT. - `url: Optional[str]` The SRT URL you provide to the broadcaster, which they stream live video to. - `srt_playback: Optional[SrtPlayback]` Details for playback from an live input using SRT. - `passphrase: Optional[str]` The secret key to use for playback via SRT. - `stream_id: Optional[str]` The identifier of the live input to use for playback via SRT. - `url: Optional[str]` The URL used to play live video over SRT. - `status: Optional[Literal["connected", "reconnected", "reconnecting", 5 more]]` The connection status of a live input. - `"connected"` - `"reconnected"` - `"reconnecting"` - `"client_disconnect"` - `"ttl_exceeded"` - `"failed_to_connect"` - `"failed_to_reconnect"` - `"new_configuration_accepted"` - `uid: Optional[str]` A unique identifier for a live input. - `web_rtc: Optional[WebRtc]` Details for streaming to a live input using WebRTC. - `url: Optional[str]` The WebRTC URL you provide to the broadcaster, which they stream live video to. - `web_rtc_playback: Optional[WebRtcPlayback]` Details for playback from a live input using WebRTC. - `url: Optional[str]` The URL used to play live video over WebRTC. ### Live Input List Response - `class LiveInputListResponse: …` - `live_inputs: Optional[List[LiveInput]]` - `created: Optional[datetime]` The date and time the live input was created. - `delete_recording_after_days: Optional[float]` Indicates the number of days after which the live inputs recordings will be deleted. When a stream completes and the recording is ready, the value is used to calculate a scheduled deletion date for that recording. Omit the field to indicate no change, or include with a `null` value to remove an existing scheduled deletion. - `enabled: Optional[bool]` Indicates whether the live input is enabled and can accept streams. - `meta: Optional[object]` A user modifiable key-value store used to reference other systems of record for managing live inputs. - `modified: Optional[datetime]` The date and time the live input was last modified. - `uid: Optional[str]` A unique identifier for a live input. - `range: Optional[int]` The total number of remaining live inputs based on cursor position. - `total: Optional[int]` The total number of live inputs that match the provided filters. # Outputs ## List all outputs associated with a specified live input `stream.live_inputs.outputs.list(strlive_input_identifier, OutputListParams**kwargs) -> SyncSinglePage[Output]` **get** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs` Retrieves all outputs associated with a specified live input. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. ### Returns - `class Output: …` - `enabled: Optional[bool]` When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch. - `stream_key: Optional[str]` The streamKey used to authenticate against an output's target. - `uid: Optional[str]` A unique identifier for the output. - `url: Optional[str]` The URL an output uses to restream. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.live_inputs.outputs.list( live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "enabled": true, "streamKey": "uzya-f19y-g2g9-a2ee-51j2", "uid": "baea4d9c515887b80289d5c33cf01145", "url": "rtmp://a.rtmp.youtube.com/live2" } ] } ``` ## Create a new output, connected to a live input `stream.live_inputs.outputs.create(strlive_input_identifier, OutputCreateParams**kwargs) -> Output` **post** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs` Creates a new output that can be used to simulcast or restream live video to other RTMP or SRT destinations. Outputs are always linked to a specific live input — one live input can have many outputs. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. - `stream_key: str` The streamKey used to authenticate against an output's target. - `url: str` The URL an output uses to restream. - `enabled: Optional[bool]` When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch. ### Returns - `class Output: …` - `enabled: Optional[bool]` When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch. - `stream_key: Optional[str]` The streamKey used to authenticate against an output's target. - `uid: Optional[str]` A unique identifier for the output. - `url: Optional[str]` The URL an output uses to restream. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) output = client.stream.live_inputs.outputs.create( live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", account_id="023e105f4ecef8ad9ca31a8372d0c353", stream_key="uzya-f19y-g2g9-a2ee-51j2", url="rtmp://a.rtmp.youtube.com/live2", ) print(output.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "enabled": true, "streamKey": "uzya-f19y-g2g9-a2ee-51j2", "uid": "baea4d9c515887b80289d5c33cf01145", "url": "rtmp://a.rtmp.youtube.com/live2" } } ``` ## Update an output `stream.live_inputs.outputs.update(stroutput_identifier, OutputUpdateParams**kwargs) -> Output` **put** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}` Updates the state of an output. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. - `output_identifier: str` A unique identifier for the output. - `enabled: bool` When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch. ### Returns - `class Output: …` - `enabled: Optional[bool]` When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch. - `stream_key: Optional[str]` The streamKey used to authenticate against an output's target. - `uid: Optional[str]` A unique identifier for the output. - `url: Optional[str]` The URL an output uses to restream. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) output = client.stream.live_inputs.outputs.update( output_identifier="baea4d9c515887b80289d5c33cf01145", account_id="023e105f4ecef8ad9ca31a8372d0c353", live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", enabled=True, ) print(output.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "enabled": true, "streamKey": "uzya-f19y-g2g9-a2ee-51j2", "uid": "baea4d9c515887b80289d5c33cf01145", "url": "rtmp://a.rtmp.youtube.com/live2" } } ``` ## Delete an output `stream.live_inputs.outputs.delete(stroutput_identifier, OutputDeleteParams**kwargs)` **delete** `/accounts/{account_id}/stream/live_inputs/{live_input_identifier}/outputs/{output_identifier}` Deletes an output and removes it from the associated live input. ### Parameters - `account_id: str` Identifier. - `live_input_identifier: str` A unique identifier for a live input. - `output_identifier: str` A unique identifier for the output. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) client.stream.live_inputs.outputs.delete( output_identifier="baea4d9c515887b80289d5c33cf01145", account_id="023e105f4ecef8ad9ca31a8372d0c353", live_input_identifier="66be4bf738797e01e1fca35a7bdecdcd", ) ``` #### Response ```json {} ``` ## Domain Types ### Output - `class Output: …` - `enabled: Optional[bool]` When enabled, live video streamed to the associated live input will be sent to the output URL. When disabled, live video will not be sent to the output URL, even when streaming to the associated live input. Use this to control precisely when you start and stop simulcasting to specific destinations like YouTube and Twitch. - `stream_key: Optional[str]` The streamKey used to authenticate against an output's target. - `uid: Optional[str]` A unique identifier for the output. - `url: Optional[str]` The URL an output uses to restream. # Watermarks ## List watermark profiles `stream.watermarks.list(WatermarkListParams**kwargs) -> SyncSinglePage[Watermark]` **get** `/accounts/{account_id}/stream/watermarks` Lists all watermark profiles for an account. ### Parameters - `account_id: str` The account identifier tag. ### Returns - `class Watermark: …` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.watermarks.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } ] } ``` ## Watermark profile details `stream.watermarks.get(stridentifier, WatermarkGetParams**kwargs) -> Watermark` **get** `/accounts/{account_id}/stream/watermarks/{identifier}` Retrieves details for a single watermark profile. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` The unique identifier for a watermark profile. ### Returns - `class Watermark: …` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) watermark = client.stream.watermarks.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(watermark.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } ``` ## Create watermark profiles via basic upload `stream.watermarks.create(WatermarkCreateParams**kwargs) -> Watermark` **post** `/accounts/{account_id}/stream/watermarks` Creates watermark profiles using a single `HTTP POST multipart/form-data` request. ### Parameters - `account_id: str` The account identifier tag. - `file: str` The image file to upload. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. ### Returns - `class Watermark: …` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) watermark = client.stream.watermarks.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", file="@/Users/rchen/Downloads/watermark.png", ) print(watermark.uid) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "created": "2014-01-02T02:20:00Z", "downloadedFrom": "https://company.com/logo.png", "height": 0, "name": "Marketing Videos", "opacity": 0.75, "padding": 0.1, "position": "center", "scale": 0.1, "size": 29472, "uid": "ea95132c15732412d22c1476fa83f27a", "width": 0 } } ``` ## Delete watermark profiles `stream.watermarks.delete(stridentifier, WatermarkDeleteParams**kwargs) -> WatermarkDeleteResponse` **delete** `/accounts/{account_id}/stream/watermarks/{identifier}` Deletes a watermark profile. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` The unique identifier for a watermark profile. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) watermark = client.stream.watermarks.delete( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(watermark) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "" } ``` ## Domain Types ### Watermark - `class Watermark: …` - `created: Optional[datetime]` The date and a time a watermark profile was created. - `downloaded_from: Optional[str]` The source URL for a downloaded image. If the watermark profile was created via direct upload, this field is null. - `height: Optional[int]` The height of the image in pixels. - `name: Optional[str]` A short description of the watermark profile. - `opacity: Optional[float]` The translucency of the image. A value of `0.0` makes the image completely transparent, and `1.0` makes the image completely opaque. Note that if the image is already semi-transparent, setting this to `1.0` will not make the image completely opaque. - `padding: Optional[float]` The whitespace between the adjacent edges (determined by position) of the video and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded video width or length, as determined by the algorithm. - `position: Optional[str]` The location of the image. Valid positions are: `upperRight`, `upperLeft`, `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the `padding` parameter. - `scale: Optional[float]` The size of the image relative to the overall size of the video. This parameter will adapt to horizontal and vertical videos automatically. `0.0` indicates no scaling (use the size of the image as-is), and `1.0`fills the entire video. - `size: Optional[float]` The size of the image in bytes. - `uid: Optional[str]` The unique identifier for a watermark profile. - `width: Optional[int]` The width of the image in pixels. ### Watermark Delete Response - `str` # Webhooks ## View webhooks `stream.webhooks.get(WebhookGetParams**kwargs) -> object` **get** `/accounts/{account_id}/stream/webhook` Retrieves a list of webhooks. ### Parameters - `account_id: str` The account identifier tag. ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhook = client.stream.webhooks.get( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(webhook) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": {} } ``` ## Create webhooks `stream.webhooks.update(WebhookUpdateParams**kwargs) -> object` **put** `/accounts/{account_id}/stream/webhook` Creates a webhook notification. ### Parameters - `account_id: str` The account identifier tag. - `notification_url: str` The URL where webhooks will be sent. ### Returns - `object` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhook = client.stream.webhooks.update( account_id="023e105f4ecef8ad9ca31a8372d0c353", notification_url="https://example.com", ) print(webhook) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": {} } ``` ## Delete webhooks `stream.webhooks.delete(WebhookDeleteParams**kwargs) -> WebhookDeleteResponse` **delete** `/accounts/{account_id}/stream/webhook` Deletes a webhook. ### Parameters - `account_id: str` The account identifier tag. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) webhook = client.stream.webhooks.delete( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(webhook) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "ok" } ``` ## Domain Types ### Webhook Delete Response - `str` # Captions ## List captions or subtitles `stream.captions.get(stridentifier, CaptionGetParams**kwargs) -> SyncSinglePage[Caption]` **get** `/accounts/{account_id}/stream/{identifier}/captions` Lists the available captions or subtitles for a specific video. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.stream.captions.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } ] } ``` ## Domain Types ### Caption - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` # Language ## List captions or subtitles for a provided language `stream.captions.language.get(strlanguage, LanguageGetParams**kwargs) -> Caption` **get** `/accounts/{account_id}/stream/{identifier}/captions/{language}` Lists the captions or subtitles for provided language. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) caption = client.stream.captions.language.get( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(caption.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } } ``` ## Generate captions or subtitles for a provided language via AI `stream.captions.language.create(strlanguage, LanguageCreateParams**kwargs) -> Caption` **post** `/accounts/{account_id}/stream/{identifier}/captions/{language}/generate` Generate captions or subtitles for provided language via AI. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) caption = client.stream.captions.language.create( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(caption.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } } ``` ## Upload captions or subtitles `stream.captions.language.update(strlanguage, LanguageUpdateParams**kwargs) -> Caption` **put** `/accounts/{account_id}/stream/{identifier}/captions/{language}` Uploads the caption or subtitle file to the endpoint for a specific BCP47 language. One caption or subtitle file per language is allowed. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. - `file: str` The WebVTT file containing the caption or subtitle content. ### Returns - `class Caption: …` - `generated: Optional[bool]` Whether the caption was generated via AI. - `label: Optional[str]` The language label displayed in the native language to users. - `language: Optional[str]` The language tag in BCP 47 format. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated caption. - `"ready"` - `"inprogress"` - `"error"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) caption = client.stream.captions.language.update( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", file="@/Users/kyle/Desktop/tr.vtt", ) print(caption.generated) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "generated": true, "label": "Türkçe", "language": "tr", "status": "ready" } } ``` ## Delete captions or subtitles `stream.captions.language.delete(strlanguage, LanguageDeleteParams**kwargs) -> LanguageDeleteResponse` **delete** `/accounts/{account_id}/stream/{identifier}/captions/{language}` Removes the captions or subtitles from a video. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) language = client.stream.captions.language.delete( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(language) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "" } ``` ## Domain Types ### Language Delete Response - `str` # Vtt ## Return WebVTT captions for a provided language `stream.captions.language.vtt.get(strlanguage, VttGetParams**kwargs) -> VttGetResponse` **get** `/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt` Return WebVTT captions for a provided language. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `language: str` The language tag in BCP 47 format. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) vtt = client.stream.captions.language.vtt.get( language="tr", account_id="023e105f4ecef8ad9ca31a8372d0c353", identifier="ea95132c15732412d22c1476fa83f27a", ) print(vtt) ``` ## Domain Types ### Vtt Get Response - `str` # Downloads ## List downloads `stream.downloads.get(stridentifier, DownloadGetParams**kwargs) -> DownloadGetResponse` **get** `/accounts/{account_id}/stream/{identifier}/downloads` Lists the downloads created for a video. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `class DownloadGetResponse: …` An object with download type keys. Each key is optional and only present if that download type has been created. - `audio: Optional[Audio]` The audio-only download. Only present if this download type has been created. - `percent_complete: Optional[float]` Indicates the progress as a percentage between 0 and 100. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated download. - `"ready"` - `"inprogress"` - `"error"` - `url: Optional[str]` The URL to access the generated download. - `default: Optional[Default]` The default video download. Only present if this download type has been created. - `percent_complete: Optional[float]` Indicates the progress as a percentage between 0 and 100. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated download. - `"ready"` - `"inprogress"` - `"error"` - `url: Optional[str]` The URL to access the generated download. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) download = client.stream.downloads.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(download.audio) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "audio": { "percentComplete": 0, "status": "ready", "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/downloads/default.mp4" }, "default": { "percentComplete": 0, "status": "ready", "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/downloads/default.mp4" } } } ``` ## Create downloads `stream.downloads.create(stridentifier, DownloadCreateParams**kwargs) -> DownloadCreateResponse` **post** `/accounts/{account_id}/stream/{identifier}/downloads` Creates a download for a video when a video is ready to view. Use `/downloads/{download_type}` instead for type-specific downloads. Available types are `default` and `audio`. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `body: object` ### Returns - `class DownloadCreateResponse: …` - `percent_complete: Optional[float]` Indicates the progress as a percentage between 0 and 100. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated download. - `"ready"` - `"inprogress"` - `"error"` - `url: Optional[str]` The URL to access the generated download. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) download = client.stream.downloads.create( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", body={}, ) print(download.percent_complete) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "percentComplete": 0, "status": "ready", "url": "https://customer-m033z5x00ks6nunl.cloudflarestream.com/ea95132c15732412d22c1476fa83f27a/downloads/default.mp4" } } ``` ## Delete downloads `stream.downloads.delete(stridentifier, DownloadDeleteParams**kwargs) -> DownloadDeleteResponse` **delete** `/accounts/{account_id}/stream/{identifier}/downloads` Delete the downloads for a video. Use `/downloads/{download_type}` instead for type-specific downloads. Available types are `default` and `audio`. ### Parameters - `account_id: str` Identifier. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) download = client.stream.downloads.delete( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(download) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": "ok" } ``` ## Domain Types ### Download Get Response - `class DownloadGetResponse: …` An object with download type keys. Each key is optional and only present if that download type has been created. - `audio: Optional[Audio]` The audio-only download. Only present if this download type has been created. - `percent_complete: Optional[float]` Indicates the progress as a percentage between 0 and 100. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated download. - `"ready"` - `"inprogress"` - `"error"` - `url: Optional[str]` The URL to access the generated download. - `default: Optional[Default]` The default video download. Only present if this download type has been created. - `percent_complete: Optional[float]` Indicates the progress as a percentage between 0 and 100. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated download. - `"ready"` - `"inprogress"` - `"error"` - `url: Optional[str]` The URL to access the generated download. ### Download Create Response - `class DownloadCreateResponse: …` - `percent_complete: Optional[float]` Indicates the progress as a percentage between 0 and 100. - `status: Optional[Literal["ready", "inprogress", "error"]]` The status of a generated download. - `"ready"` - `"inprogress"` - `"error"` - `url: Optional[str]` The URL to access the generated download. ### Download Delete Response - `str` # Embed ## Retrieve embed Code HTML `stream.embed.get(stridentifier, EmbedGetParams**kwargs) -> EmbedGetResponse` **get** `/accounts/{account_id}/stream/{identifier}/embed` Fetches an HTML code snippet to embed a video in a web page delivered through Cloudflare. On success, returns an HTML fragment for use on web pages to display a video. On failure, returns a JSON response body. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. ### Returns - `str` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) embed = client.stream.embed.get( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(embed) ``` #### Response ```json "" ``` ## Domain Types ### Embed Get Response - `str` # Token ## Create signed URL tokens for videos `stream.token.create(stridentifier, TokenCreateParams**kwargs) -> TokenCreateResponse` **post** `/accounts/{account_id}/stream/{identifier}/token` Creates a signed URL token for a video. If a body is not provided in the request, a token is created with default values. ### Parameters - `account_id: str` The account identifier tag. - `identifier: str` A Cloudflare-generated unique identifier for a media item. - `id: Optional[str]` The optional ID of a Stream signing key. If present, the `pem` field is also required. - `access_rules: Optional[Iterable[AccessRule]]` The optional list of access rule constraints on the token. Access can be blocked or allowed based on an IP, IP range, or by country. Access rules are evaluated from first to last. If a rule matches, the associated action is applied and no further rules are evaluated. - `action: Optional[Literal["allow", "block"]]` The action to take when a request matches a rule. If the action is `block`, the signed token blocks views for viewers matching the rule. - `"allow"` - `"block"` - `country: Optional[SequenceNotStr[str]]` An array of 2-letter country codes in ISO 3166-1 Alpha-2 format used to match requests. - `ip: Optional[SequenceNotStr[str]]` An array of IPv4 or IPV6 addresses or CIDRs used to match requests. - `type: Optional[Literal["any", "ip.src", "ip.geoip.country"]]` Lists available rule types to match for requests. An `any` type matches all requests and can be used as a wildcard to apply default actions after other rules. - `"any"` - `"ip.src"` - `"ip.geoip.country"` - `downloadable: Optional[bool]` The optional boolean value that enables using signed tokens to access MP4 download links for a video. - `exp: Optional[int]` The optional unix epoch timestamp that specficies the time after a token is not accepted. The maximum time specification is 24 hours from issuing time. If this field is not set, the default is one hour after issuing. - `nbf: Optional[int]` The optional unix epoch timestamp that specifies the time before a the token is not accepted. If this field is not set, the default is one hour before issuing. - `pem: Optional[str]` The optional base64 encoded private key in PEM format associated with a Stream signing key. If present, the `id` field is also required. ### Returns - `class TokenCreateResponse: …` - `token: Optional[str]` The signed token used with the signed URLs feature. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) token = client.stream.token.create( identifier="ea95132c15732412d22c1476fa83f27a", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(token.token) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImU5ZGI5OTBhODI2NjZkZDU3MWM3N2Y5NDRhNWM1YzhkIn0.eyJzdWIiOiJlYTk1MTMyYzE1NzMyNDEyZDIyYzE0NzZmYTgzZjI3YSIsImtpZCI6ImU5ZGI5OTBhODI2NjZkZDU3MWM3N2Y5NDRhNWM1YzhkIiwiZXhwIjoiMTUzNzQ2MDM2NSIsIm5iZiI6IjE1Mzc0NTMxNjUifQ.OZhqOARADn1iubK6GKcn25hN3nU-hCFF5q9w2C4yup0C4diG7aMIowiRpP-eDod8dbAJubsiFuTKrqPcmyCKWYsiv0TQueukqbQlF7HCO1TV-oF6El5-7ldJ46eD-ZQ0XgcIYEKrQOYFF8iDQbqPm3REWd6BnjKZdeVrLzuRaiSnZ9qqFpGu5dfxIY9-nZKDubJHqCr3Imtb211VIG_b9MdtO92JjvkDS-rxT_pkEfTZSafl1OU-98A7KBGtPSJHz2dHORIrUiTA6on4eIXTj9aFhGiir4rSn-rn0OjPRTtJMWIDMoQyE_fwrSYzB7MPuzL2t82BWaEbHZTfixBm5A" } } ``` ## Domain Types ### Token Create Response - `class TokenCreateResponse: …` - `token: Optional[str]` The signed token used with the signed URLs feature.