### Manual Installation Example Source: https://github.com/muxinc/mux-php/blob/master/README.md This example shows how to manually include the Mux PHP autoloader if not using Composer. Manual installation is not recommended. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\RealTimeApi( // If you want use custom http client, pass your client which implements `GuzzleHttp ClientInterface`. // This is optional, `GuzzleHttp Client` will be used as default. new GuzzleHttp Client(), $config ); $realtime_metric_id = current-concurrent-viewers; // string | ID of the Realtime Metric $dimension = 'dimension_example'; // string | Dimension the specified value belongs to $timestamp = 56; // int | Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. $filters = array('filters_example'); // string[] | Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` $order_by = 'order_by_example'; // string | Value to order the results by $order_direction = 'order_direction_example'; // string | Sort order. try { $result = $apiInstance->getRealtimeBreakdown($realtime_metric_id, $dimension, $timestamp, $filters, $order_by, $order_direction); print_r($result); } catch (Exception $e) { echo 'Exception when calling RealTimeApi->getRealtimeBreakdown: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Monitoring Breakdown Example Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/MonitoringApi.md Retrieves breakdown information for a specific dimension and metric, including concurrent viewers and negative impact score. Requires configuration of authentication credentials. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\MonitoringApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $monitoring_metric_id = current-concurrent-viewers; // string | ID of the Monitoring Metric $dimension = 'dimension_example'; // string | Dimension the specified value belongs to $timestamp = 56; // int | Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. $filters = array('filters_example'); // string[] | Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` $order_by = 'order_by_example'; // string | Value to order the results by $order_direction = 'order_direction_example'; // string | Sort order. try { $result = $apiInstance->getMonitoringBreakdown($monitoring_metric_id, $dimension, $timestamp, $filters, $order_by, $order_direction); print_r($result); } catch (Exception $e) { echo 'Exception when calling MonitoringApi->getMonitoringBreakdown: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### launchWebInput Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/WebInputsApi.md Launches the browsers instance, loads the URL specified, and then starts streaming to the specified Live Stream. ```APIDOC ## `launchWebInput()` ### Description Launches the browsers instance, loads the URL specified, and then starts streaming to the specified Live Stream. ### Method POST ### Endpoint /video/v1/web-inputs/{web_input_id}/launch ### Parameters #### Path Parameters - **web_input_id** (string) - Required - The Web Input ID ### Response #### Success Response (200) - **` MuxPhp\Models\LaunchWebInputResponse`** - The response object indicating the launch status. ### Request Example ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\WebInputsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $web_input_id = abcd1234; // string | The Web Input ID try { $result = $apiInstance->launchWebInput($web_input_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling WebInputsApi->launchWebInput: ', $e->getMessage(), PHP_EOL; } ``` ``` -------------------------------- ### Get Overall Metric Values in PHP Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/MetricsApi.md This snippet shows how to configure the Mux PHP SDK and call the `getOverallValues` function to retrieve metric data. Ensure you have the SDK installed and configured with your credentials. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\MetricsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $metric_id = video_startup_time; // string | ID of the Metric $timeframe = array('timeframe_example'); // string[] | Timeframe window to limit results by. Must be provided as an array query string parameter (e.g. timeframe[]=). Accepted formats are... * array of epoch timestamps e.g. `timeframe[]=1498867200&timeframe[]=1498953600` * duration string e.g. `timeframe[]=24:hours or timeframe[]=7:days` $filters = array('filters_example'); // string[] | Filter results using key:value pairs. Must be provided as an array query string parameter. **Basic filtering:** * `filters[]=dimension:value` - Include rows where dimension equals value * `filters[]=!dimension:value` - Exclude rows where dimension equals value **For trace dimensions (like video_cdn_trace):** * `filters[]=+dimension:value` - Include rows where trace contains value * `filters[]=-dimension:value` - Exclude rows where trace contains value * `filters[]=dimension:[value1,value2]` - Exact trace match **Examples:** * `filters[]=country:US` - US views only * `filters[]=+video_cdn_trace:fastly` - Views using Fastly CDN $metric_filters = array('metric_filters_example'); // string[] | Limit the results to rows that match inequality conditions from provided metric comparison clauses. Must be provided as an array query string parameter. Possible filterable metrics are the same as the set of metric ids, with the exceptions of `exits_before_video_start`, `unique_viewers`, `video_startup_failure_percentage`, `view_dropped_percentage`, and `views`. Example: * `metric_filters[]=aggregate_startup_time>=1000` $measurement = 'measurement_example'; // string | Measurement for the provided metric. If omitted, the default for the metric will be used. The default measurement for each metric is: "sum" : `ad_attempt_count`, `ad_break_count`, `ad_break_error_count`, `ad_error_count`, `ad_impression_count`, `playing_time` "median" : `ad_preroll_startup_time`, `aggregate_startup_time`, `content_startup_time`, `max_downscale_percentage`, `max_upscale_percentage`, `page_load_time`, `player_average_live_latency`, `player_startup_time`, `rebuffer_count`, `rebuffer_duration`, `requests_for_first_preroll`, `video_startup_preroll_load_time`, `video_startup_preroll_request_time`, `video_startup_time`, `view_average_request_latency`, `view_average_request_throughput`, `view_max_request_latency`, `weighted_average_bitrate` "avg" : `ad_break_error_percentage`, `ad_error_percentage`, `ad_exit_before_start_count`, `ad_exit_before_start_percentage`, `ad_playback_failure_percentage`, `ad_startup_error_count`, `ad_startup_error_percentage`, `content_playback_failure_percentage`, `downscale_percentage`, `exits_before_video_start`, `playback_business_exception_percentage`, `playback_failure_percentage`, `playback_success_score`, `rebuffer_frequency`, `rebuffer_percentage`, `seek_latency`, `smoothness_score`, `startup_time_score`, `upscale_percentage`, `video_quality_score`, `video_startup_business_exception_percentage`, `video_startup_failure_percentage`, `view_dropped_percentage`, `viewer_experience_score` "count" : `started_views`, `unique_viewers` try { $result = $apiInstance->getOverallValues($metric_id, $timeframe, $filters, $metric_filters, $measurement); print_r($result); } catch (Exception $e) { echo 'Exception when calling MetricsApi->getOverallValues: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### List Filters Example Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/FiltersApi.md Lists all available filters, categorized into basic and advanced. This API is being replaced by the list-dimensions API call. ```php listFilters(): \MuxPhp\Models\ListFiltersResponse ``` -------------------------------- ### Launch Web Input Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/WebInputsApi.md Launch a Web Input to start its browser instance, load a URL, and begin streaming to a Live Stream. Authentication is required. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\WebInputsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp ClientInterface`. // This is optional, `GuzzleHttp Client` will be used as default. new GuzzleHttp Client(), $config ); $web_input_id = abcd1234; // string | The Web Input ID try { $result = $apiInstance->launchWebInput($web_input_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling WebInputsApi->launchWebInput: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### List DRM Configurations Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/DRMConfigurationsApi.md This example demonstrates how to retrieve a list of all DRM configurations. You can control the number of results per page using the `limit` parameter and paginate through results using the `page` parameter. Authentication is required. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\DRMConfigurationsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp ClientInterface`. // This is optional, `GuzzleHttp Client` will be used as default. new GuzzleHttp Client(), $config ); $page = 1; // int | Offset by this many pages, of the size of `limit` $limit = 25; // int | Number of items to include in the response try { $result = $apiInstance->listDrmConfigurations($page, $limit); print_r($result); } catch (Exception $e) { echo 'Exception when calling DRMConfigurationsApi->listDrmConfigurations: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Monitoring Timeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/MonitoringApi.md Fetches time series data for a specific monitoring metric, including concurrent viewer counts. An optional timestamp can be provided to set the start of the timeseries. Filters are available to refine the data. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\MonitoringApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $monitoring_metric_id = current-concurrent-viewers; // string | ID of the Monitoring Metric $filters = array('filters_example'); // string[] | Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` $timestamp = 56; // int | Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. try { $result = $apiInstance->getMonitoringTimeseries($monitoring_metric_id, $filters, $timestamp); print_r($result); } catch (Exception $e) { echo 'Exception when calling MonitoringApi->getMonitoringTimeseries: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### launchWebInput Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/WebInputsApi.md Launches a Web Input, making it active and ready to stream content. ```APIDOC ## PUT /video/v1/web-inputs/{WEB_INPUT_ID}/launch ### Description Launch a Web Input ### Method PUT ### Endpoint /video/v1/web-inputs/{WEB_INPUT_ID}/launch ### Parameters #### Path Parameters - **WEB_INPUT_ID** (string) - Required - The unique identifier of the Web Input to launch. ### Response #### Success Response (200) - **data** (object) - Contains the updated details of the Web Input after launching. - **id** (string) - Unique identifier for the Web Input. - **status** (string) - The updated status of the Web Input (should be 'active'). ### Response Example ```json { "data": { "id": "abcd1234efgh5678ij", "status": "active" } } ``` ``` -------------------------------- ### Create Live Stream with Mux PHP Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/LiveStreamsApi.md Demonstrates how to create a new live stream using the Mux PHP SDK. It shows the necessary configuration and how to pass the request body, which can be decoded from JSON. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\LiveStreamsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); // This API method wants a \MuxPhp\Models\CreateLiveStreamRequest // as the second parameter. That being said, these API docs are // auto-generated from our OpenAPI specification, which // gives us the example parameter as a JSON string. In this example, // we'll use json_decode() to turn it into an associative array, which // is compatible with the model. // // In your own code you should use an associative array, or // use a "new \MuxPhp\Models\CreateLiveStreamRequest" directly. $create_live_stream_request = json_decode('{"playback_policies":["public"],"new_asset_settings":{"playback_policies":["public"]}}',true); // \MuxPhp\Models\CreateLiveStreamRequest try { $result = $apiInstance->createLiveStream($create_live_stream_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling LiveStreamsApi->createLiveStream: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### getRealtimeHistogramTimeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/RealTimeApi.md Gets histogram timeseries information for a specific metric. This API is now deprecated, please use the `Get Monitoring Histogram Timeseries` API. ```APIDOC ## `getRealtimeHistogramTimeseries()` ### Description Gets histogram timeseries information for a specific metric. This API is now deprecated, please use the `Get Monitoring Histogram Timeseries` API. ### Method GET ### Endpoint /api/v1/realtime/histogram-timeseries/{realtime_histogram_metric_id} ### Parameters #### Path Parameters - **realtime_histogram_metric_id** (string) - Required - ID of the Realtime Histogram Metric #### Query Parameters - **filters** (string[]) - Optional - Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: `filters[]=operating_system:windows&filters[]=!country:US` ### Response #### Success Response (200) - **data** (object) - Histogram timeseries data. #### Response Example ```json { "data": { "status": "success", "request_id": "some_request_id", "data": [ { "timestamp": 1678886400, "value": 100 } ] } } ``` ### Authorization - accessToken ``` -------------------------------- ### List Filters Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/FiltersApi.md Demonstrates how to instantiate the FiltersApi and call the listFilters method to retrieve a list of filters. Ensure you have configured your API credentials before execution. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\FiltersApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\\\ClientInterface`. // This is optional, `GuzzleHttp\\Client` will be used as default. new GuzzleHttp\\Client(), $config ); try { $result = $apiInstance->listFilters(); print_r($result); } catch (Exception $e) { echo 'Exception when calling FiltersApi->listFilters: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Live Stream Playback ID Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/LiveStreamsApi.md Fetches information about a live stream's playback ID. This is used to get the URL through which viewers can watch the stream. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\LiveStreamsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp ClientInterface`. // This is optional, `GuzzleHttp Client` will be used as default. new GuzzleHttp Client(), $config ); $live_stream_id = 'live_stream_id_example'; // string | The live stream ID $playback_id = 'playback_id_example'; // string | The live stream's playback ID. try { $result = $apiInstance->getLiveStreamPlaybackId($live_stream_id, $playback_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling LiveStreamsApi->getLiveStreamPlaybackId: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### List Video Views with Filters Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/VideoViewsApi.md Demonstrates how to list video views using the Mux PHP SDK, including various filtering and pagination options. Ensure you have configured the API with your credentials. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\VideoViewsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp ClientInterface`. // This is optional, `GuzzleHttp Client` will be used as default. new GuzzleHttp\Client(), $config ); $limit = 25; // int | Number of items to include in the response $page = 1; // int | Offset by this many pages, of the size of `limit` $viewer_id = 'viewer_id_example'; // string | Viewer ID to filter results by. This value may be provided by the integration, or may be created by Mux. $error_id = 56; // int | Filter video views by the provided error ID (as returned in the error_type_id field in the list video views endpoint). If you provide any as the error ID, this will filter the results to those with any error. $order_direction = 'order_direction_example'; // string | Sort order. $filters = array('filters_example'); // string[] | Filter results using key:value pairs. Must be provided as an array query string parameter. **Basic filtering:** * `filters[]=dimension:value` - Include rows where dimension equals value * `filters[]=!dimension:value` - Exclude rows where dimension equals value **For trace dimensions (like video_cdn_trace):** * `filters[]=+dimension:value` - Include rows where trace contains value * `filters[]=-dimension:value` - Exclude rows where trace contains value * `filters[]=dimension:[value1,value2]` - Exact trace match **Examples:** * `filters[]=country:US` - US views only * `filters[]=+video_cdn_trace:fastly` - Views using Fastly CDN $metric_filters = array('metric_filters_example'); // string[] | Limit the results to rows that match inequality conditions from provided metric comparison clauses. Must be provided as an array query string parameter. Possible filterable metrics are the same as the set of metric ids, with the exceptions of `exits_before_video_start`, `unique_viewers`, `video_startup_failure_percentage`, `view_dropped_percentage`, and `views`. Example: * `metric_filters[]=aggregate_startup_time>=1000` $timeframe = array('timeframe_example'); // string[] | Timeframe window to limit results by. Must be provided as an array query string parameter (e.g. timeframe[]=). Accepted formats are... * array of epoch timestamps e.g. `timeframe[]=1498867200&timeframe[]=1498953600` * duration string e.g. `timeframe[]=24:hours or timeframe[]=7:days` try { $result = $apiInstance->listVideoViews($limit, $page, $viewer_id, $error_id, $order_direction, $filters, $metric_filters, $timeframe); print_r($result); } catch (Exception $e) { echo 'Exception when calling VideoViewsApi->listVideoViews: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### getRealtimeTimeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/RealTimeApi.md Gets Time series information for a specific metric along with the number of concurrent viewers. This API is now deprecated, please use the `Get Monitoring Timeseries` API. ```APIDOC ## `getRealtimeTimeseries()` ### Description Gets Time series information for a specific metric along with the number of concurrent viewers. This API is now deprecated, please use the `Get Monitoring Timeseries` API. ### Method GET ### Endpoint /api/v1/realtime/timeseries/{realtime_metric_id} ### Parameters #### Path Parameters - **realtime_metric_id** (string) - Required - ID of the Realtime Metric #### Query Parameters - **filters** (string[]) - Optional - Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: `filters[]=operating_system:windows&filters[]=!country:US` - **timestamp** (integer) - Optional - Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. ### Response #### Success Response (200) - **data** (object) - Timeseries data including concurrent viewers. #### Response Example ```json { "data": { "status": "success", "request_id": "some_request_id", "data": [ { "timestamp": 1678886400, "current_viewers": 1000 } ] } } ``` ### Authorization - accessToken ``` -------------------------------- ### List All Metric Values with PHP Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/MetricsApi.md This snippet shows how to initialize the Mux PHP Metrics API client and call the `listAllMetricValues` method. It demonstrates setting up authentication, defining timeframes, filters, and dimensions for the API request. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\MetricsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $timeframe = array('timeframe_example'); // string[] | Timeframe window to limit results by. Must be provided as an array query string parameter (e.g. timeframe[]=). Accepted formats are... * array of epoch timestamps e.g. `timeframe[]=1498867200&timeframe[]=1498953600` * duration string e.g. `timeframe[]=24:hours or timeframe[]=7:days` $filters = array('filters_example'); // string[] | Filter results using key:value pairs. Must be provided as an array query string parameter. **Basic filtering:** * `filters[]=dimension:value` - Include rows where dimension equals value * `filters[]=!dimension:value` - Exclude rows where dimension equals value **For trace dimensions (like video_cdn_trace):** * `filters[]=+dimension:value` - Include rows where trace contains value * `filters[]=-dimension:value` - Exclude rows where trace contains value * `filters[]=dimension:[value1,value2]` - Exact trace match **Examples:** * `filters[]=country:US` - US views only * `filters[]=+video_cdn_trace:fastly` - Views using Fastly CDN $metric_filters = array('metric_filters_example'); // string[] | Limit the results to rows that match inequality conditions from provided metric comparison clauses. Must be provided as an array query string parameter. Possible filterable metrics are the same as the set of metric ids, with the exceptions of `exits_before_video_start`, `unique_viewers`, `video_startup_failure_percentage`, `view_dropped_percentage`, and `views`. Example: * `metric_filters[]=aggregate_startup_time>=1000` $dimension = 'dimension_example'; // string | Dimension the specified value belongs to $value = 'value_example'; // string | Value to show all available metrics for try { $result = $apiInstance->listAllMetricValues($timeframe, $filters, $metric_filters, $dimension, $value); print_r($result); } catch (Exception $e) { echo 'Exception when calling MetricsApi->listAllMetricValues: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### Get Real-Time Histogram Timeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/RealTimeApi.md Retrieves histogram timeseries information for a specific metric. This method is deprecated; use the Get Monitoring Histogram Timeseries API instead. Requires authentication configuration. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp Api RealTimeApi( // If you want use custom http client, pass your client which implements `GuzzleHttp // ClientInterface`. // This is optional, `GuzzleHttp // Client` will be used as default. new GuzzleHttp Client(), $config ); $realtime_histogram_metric_id = video-startup-time; // string | ID of the Realtime Histogram Metric $filters = array('filters_example'); // string[] | Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` try { $result = $apiInstance->getRealtimeHistogramTimeseries($realtime_histogram_metric_id, $filters); print_r($result); } catch (Exception $e) { echo 'Exception when calling RealTimeApi->getRealtimeHistogramTimeseries: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### getRealtimeBreakdown Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/RealTimeApi.md Gets breakdown information for a specific dimension and metric along with the number of concurrent viewers and negative impact score. This API is now deprecated, please use the `Get Monitoring Breakdown` API. ```APIDOC ## GET /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/breakdown ### Description Gets breakdown information for a specific dimension and metric along with the number of concurrent viewers and negative impact score. This API is now deprecated, please use the `Get Monitoring Breakdown` API. ### Method GET ### Endpoint /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/breakdown ### Parameters #### Path Parameters - **realtime_metric_id** (string) - Required - ID of the Realtime Metric #### Query Parameters - **dimension** (string) - Optional - Dimension the specified value belongs to - **timestamp** (int) - Optional - Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. - **filters** (string[]) - Optional - Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: `filters[]=operating_system:windows&filters[]=!country:US` - **order_by** (string) - Optional - Value to order the results by - **order_direction** (string) - Optional - Sort order. ### Response #### Success Response (200) - **response** (object) - Description of the response object ### Response Example { "example": "response body" } ### Authorization accessToken ``` -------------------------------- ### getVideoView Source: https://github.com/muxinc/mux-php/blob/master/README.md Get a Video View. ```APIDOC ## GET /data/v1/video-views/{VIDEO_VIEW_ID} ### Description Get a Video View. ### Method GET ### Endpoint /data/v1/video-views/{VIDEO_VIEW_ID} ### Parameters #### Path Parameters - **VIDEO_VIEW_ID** (string) - Required - The ID of the video view to retrieve. ``` -------------------------------- ### getRealtimeBreakdown Source: https://github.com/muxinc/mux-php/blob/master/README.md Get Real-Time Breakdown. ```APIDOC ## GET /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/breakdown ### Description Get Real-Time Breakdown. ### Method GET ### Endpoint /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/breakdown ### Parameters #### Path Parameters - **REALTIME_METRIC_ID** (string) - Required - The ID of the real-time metric. ``` -------------------------------- ### Create Video Asset and Get Playback URL Source: https://github.com/muxinc/mux-php/blob/master/README.md This snippet demonstrates how to authenticate, create a new video asset from a URL, and retrieve its public playback URL. Ensure MUX_TOKEN_ID and MUX_TOKEN_SECRET environment variables are set for authentication. ```php // Authentication Setup $config = MuxPhp\Configuration::getDefaultConfiguration() ->setUsername(getenv('MUX_TOKEN_ID')) ->setPassword(getenv('MUX_TOKEN_SECRET')); // API Client Initialization $assetsApi = new MuxPhp\Api\AssetsApi( new GuzzleHttp\Client(), $config ); // Create Asset Request $input = new MuxPhp\Models\InputSettings(["url" => "https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4"]); $createAssetRequest = new MuxPhp\Models\CreateAssetRequest(["input" => $input, "playback_policy" => [MuxPhp\Models\PlaybackPolicy::_PUBLIC] ]); // Ingest $result = $assetsApi->createAsset($createAssetRequest); // Print URL print "Playback URL: https://stream.mux.com/" . $result->getData()->getPlaybackIds()[0]->getId() . ".m3u8\n"; ``` -------------------------------- ### Create Live Stream Simulcast Target (PHP) Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/LiveStreamsApi.md Creates a simulcast target for a live stream. The live stream must be in an idle state, and only one simulcast target can be created at a time. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp Api LiveStreamsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp // ClientInterface`. // This is optional, `GuzzleHttp // Client` will be used as default. new GuzzleHttp Client(), $config ); $live_stream_id = 'live_stream_id_example'; // string | The live stream ID // This API method wants a \MuxPhp\Models\CreateSimulcastTargetRequest // as the second parameter. That being said, these API docs are // auto-generated from our OpenAPI specification, which // gives us the example parameter as a JSON string. In this example, // we'll use json_decode() to turn it into an associative array, which // is compatible with the model. // // In your own code you should use an associative array, or // use a "new \MuxPhp\Models\CreateSimulcastTargetRequest" directly. $create_simulcast_target_request = json_decode('{"url":"rtmp:\/\/live.example.com\/app","stream_key":"abcdefgh","passthrough":"Example"}',true); // \MuxPhp\Models\CreateSimulcastTargetRequest try { $result = $apiInstance->createLiveStreamSimulcastTarget($live_stream_id, $create_simulcast_target_request); print_r($result); } catch (Exception $e) { echo 'Exception when calling LiveStreamsApi->createLiveStreamSimulcastTarget: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### getMonitoringBreakdown Source: https://github.com/muxinc/mux-php/blob/master/README.md Get Monitoring Breakdown. ```APIDOC ## GET /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/breakdown ### Description Get Monitoring Breakdown. ### Method GET ### Endpoint /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/breakdown ### Parameters #### Path Parameters - **MONITORING_METRIC_ID** (string) - Required - The ID of the monitoring metric. ``` -------------------------------- ### getRealtimeTimeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/RealTimeApi.md Get Real-Time Timeseries ```APIDOC ## GET /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/timeseries ### Description Get Real-Time Timeseries ### Method GET ### Endpoint /data/v1/realtime/metrics/{REALTIME_METRIC_ID}/timeseries ### Parameters #### Path Parameters - **realtime_metric_id** (string) - Required - ID of the Realtime Metric ### Response #### Success Response (200) - **response** (object) - Description of the response object ### Response Example { "example": "response body" } ### Authorization accessToken ``` -------------------------------- ### List Insights for a Metric Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/MetricsApi.md Demonstrates how to configure the Mux PHP client and call the `listInsights` function to retrieve performance insights for a specific metric. Includes setup for authentication and optional parameters for filtering and ordering. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp\Api\MetricsApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $metric_id = video_startup_time; // string | ID of the Metric $measurement = 'measurement_example'; // string | Measurement for the provided metric. If omitted, the default for the metric will be used. The default measurement for each metric is: "sum" : `ad_attempt_count`, `ad_break_count`, `ad_break_error_count`, `ad_error_count`, `ad_impression_count`, `playing_time` "median" : `ad_preroll_startup_time`, `aggregate_startup_time`, `content_startup_time`, `max_downscale_percentage`, `max_upscale_percentage`, `page_load_time`, `player_average_live_latency`, `player_startup_time`, `rebuffer_count`, `rebuffer_duration`, `requests_for_first_preroll`, `video_startup_preroll_load_time`, `video_startup_preroll_request_time`, `video_startup_time`, `view_average_request_latency`, `view_average_request_throughput`, `view_max_request_latency`, `weighted_average_bitrate` "avg" : `ad_break_error_percentage`, `ad_error_percentage`, `ad_exit_before_start_count`, `ad_exit_before_start_percentage`, `ad_playback_failure_percentage`, `ad_startup_error_count`, `ad_startup_error_percentage`, `content_playback_failure_percentage`, `downscale_percentage`, `exits_before_video_start`, `playback_business_exception_percentage`, `playback_failure_percentage`, `playback_success_score`, `rebuffer_frequency`, `rebuffer_percentage`, `seek_latency`, `smoothness_score`, `startup_time_score`, `upscale_percentage`, `video_quality_score`, `video_startup_business_exception_percentage`, `video_startup_failure_percentage`, `view_dropped_percentage`, `viewer_experience_score` "count" : `started_views`, `unique_viewers` $order_direction = 'order_direction_example'; // string | Sort order. $timeframe = array('timeframe_example'); // string[] | Timeframe window to limit results by. Must be provided as an array query string parameter (e.g. timeframe[]=). Accepted formats are... * array of epoch timestamps e.g. `timeframe[]=1498867200&timeframe[]=1498953600` * duration string e.g. `timeframe[]=24:hours or timeframe[]=7:days` $filters = array('filters_example'); // string[] | Filter results using key:value pairs. Must be provided as an array query string parameter. **Basic filtering:** * `filters[]=dimension:value` - Include rows where dimension equals value * `filters[]=!dimension:value` - Exclude rows where dimension equals value **For trace dimensions (like video_cdn_trace):** * `filters[]=+dimension:value` - Include rows where trace contains value * `filters[]=-dimension:value` - Exclude rows where trace contains value * `filters[]=dimension:[value1,value2]` - Exact trace match **Examples:** * `filters[]=country:US` - US views only * `filters[]=+video_cdn_trace:fastly` - Views using Fastly CDN $metric_filters = array('metric_filters_example'); // string[] | Limit the results to rows that match inequality conditions from provided metric comparison clauses. Must be provided as an array query string parameter. Possible filterable metrics are the same as the set of metric ids, with the exceptions of `exits_before_video_start`, `unique_viewers`, `video_startup_failure_percentage`, `view_dropped_percentage`, and `views`. Example: * `metric_filters[]=aggregate_startup_time>=1000` try { $result = $apiInstance->listInsights($metric_id, $measurement, $order_direction, $timeframe, $filters, $metric_filters); print_r($result); } catch (Exception $e) { echo 'Exception when calling MetricsApi->listInsights: ', $e->getMessage(), PHP_EOL; } ``` -------------------------------- ### getMonitoringTimeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/MonitoringApi.md Get Monitoring Timeseries ```APIDOC ## GET /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/timeseries ### Description Get Monitoring Timeseries ### Method GET ### Endpoint /data/v1/monitoring/metrics/{MONITORING_METRIC_ID}/timeseries ### Parameters #### Path Parameters - **MONITORING_METRIC_ID** (string) - Required - The ID of the Monitoring Metric. #### Query Parameters - **dimension** (string) - Optional - Dimension the specified value belongs to. - **timestamp** (integer) - Optional - Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. - **filters** (string[]) - Optional - Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: `filters[]=operating_system:windows&filters[]=!country:US` - **order_by** (string) - Optional - Value to order the results by. - **order_direction** (string) - Optional - Sort order. ### Response #### Success Response (200) - **data** (object) - Description of the response data. #### Response Example { "example": "{\"data\": {}}" } ``` -------------------------------- ### Create Live Stream Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/LiveStreamsApi.md Use this method to create a new live stream. After creation, an encoder can connect using the provided stream key to begin streaming. ```php createLiveStream($create_live_stream_request): \MuxPhp\Models\LiveStreamResponse ``` -------------------------------- ### Get Real-Time Timeseries Source: https://github.com/muxinc/mux-php/blob/master/docs/Api/RealTimeApi.md Retrieves timeseries information for a specific metric, including concurrent viewers. This method is deprecated; use the Get Monitoring Timeseries API instead. Requires authentication configuration and optionally accepts a timestamp. ```php setUsername('YOUR_USERNAME') ->setPassword('YOUR_PASSWORD'); $apiInstance = new MuxPhp Api RealTimeApi( // If you want use custom http client, pass your client which implements `GuzzleHttp // ClientInterface`. // This is optional, `GuzzleHttp // Client` will be used as default. new GuzzleHttp Client(), $config ); $realtime_metric_id = current-concurrent-viewers; // string | ID of the Realtime Metric $filters = array('filters_example'); // string[] | Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` $timestamp = 56; // int | Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. try { $result = $apiInstance->getRealtimeTimeseries($realtime_metric_id, $filters, $timestamp); print_r($result); } catch (Exception $e) { echo 'Exception when calling RealTimeApi->getRealtimeTimeseries: ', $e->getMessage(), PHP_EOL; } ```