### GET /videos/{videoGuid} Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Retrieve metadata for a specific video by its unique identifier. ```APIDOC ## GET /videos/{videoGuid} ### Description Retrieve metadata for a specific video by its unique identifier. Returns complete video information including title, status, encoding progress, and playback URLs. ### Method GET ### Endpoint /videos/{videoGuid} ### Parameters #### Path Parameters - **videoGuid** (string) - Required - The unique identifier of the video. ### Response #### Success Response (200) - **videoLibraryId** (integer) - The ID of the video library. - **guid** (string) - The unique video identifier. - **title** (string) - The title of the video. - **status** (integer) - The current processing status. - **length** (integer) - Duration in seconds. #### Response Example { "videoLibraryId": 12345, "guid": "abc123-video-guid", "title": "My Video", "status": 4, "length": 120 } ``` -------------------------------- ### Get Video Metadata (PHP) Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Retrieves metadata for a specific video using its unique GUID. The function returns detailed video information, including title, status, encoding progress, and playback URLs. It handles potential errors like invalid API keys or not finding the video. ```php getVideo("abc123-video-guid"); // Access video properties echo "Title: " . $video['title'] . "\n"; echo "Status: " . $video['status'] . "\n"; echo "Duration: " . $video['length'] . " seconds\n"; echo "Views: " . $video['views'] . "\n"; // Expected response structure: // [ // 'videoLibraryId' => 12345, // 'guid' => 'abc123-video-guid', // 'title' => 'My Video', // 'status' => 4, // 'length' => 120, // 'views' => 1500, // 'isPublic' => true, // 'thumbnailFileName' => 'thumbnail.jpg' // ] } catch (Exception $e) { echo "Error: " . $e->getMessage(); // Handles 401 (invalid API key) and 404 (video not found) } ``` -------------------------------- ### Upload Video with Video ID Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Uploads a local video file to a previously created video object. Requires a valid video GUID obtained from the createVideo method. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $videoObject = $bstream->createVideo("My Upload"); $videoId = $videoObject['guid']; $result = $bstream->uploadVideoWithVideoId($videoId, "/path/to/video.mp4"); echo "Upload successful for video: " . $videoId . "\n"; } catch (Exception $e) { echo "Upload error: " . $e->getMessage(); } ``` -------------------------------- ### GET /videos Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Retrieve a paginated list of videos from your Stream library with optional filtering. ```APIDOC ## GET /videos ### Description Retrieve a paginated list of videos from your Stream library with optional filtering by search term or collection. ### Method GET ### Endpoint /videos ### Parameters #### Query Parameters - **page** (integer) - Optional - Page number for pagination. - **itemsPerPage** (integer) - Optional - Number of items per page. - **orderBy** (string) - Optional - Sort field (date, title). - **search** (string) - Optional - Search term. - **collectionId** (string) - Optional - Filter by collection ID. ### Response #### Success Response (200) - **totalItems** (integer) - Total number of videos. - **items** (array) - List of video objects. #### Response Example { "totalItems": 150, "currentPage": 1, "items": [ {"guid": "...", "title": "...", "status": 4} ] } ``` -------------------------------- ### GET /video/{videoId} Source: https://github.com/bunnyway/bunnystream-api-php/blob/main/README.md Retrieve metadata for a specific video using its unique identifier. ```APIDOC ## GET /video/{videoId} ### Description Retrieves a JSON object containing the metadata for a specific video. ### Method GET ### Endpoint /video/{videoId} ### Parameters #### Path Parameters - **videoId** (string) - Required - The unique identifier of the video. ### Response #### Success Response (200) - **video** (object) - The video metadata object. #### Response Example { "video": { "guid": "example-id", "title": "My Video", "status": 3 } } ``` -------------------------------- ### Update Video Metadata Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Updates an existing video's title and its collection assignment using the video GUID. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $result = $bstream->updateVideo("video-guid-123", "Updated Video Title", "new-collection-guid"); echo "Video updated successfully\n"; } catch (Exception $e) { echo "Update failed: " . $e->getMessage(); } ``` -------------------------------- ### Delete Video Captions using PHP Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Removes an existing caption track from a video by specifying the target video GUID and the language code. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $result = $bstream->deleteVideoCaptions("video-guid-123", "en"); $result = $bstream->deleteVideoCaptions("video-guid-123", "es"); echo "Captions deleted successfully\n"; } catch (Exception $e) { echo "Failed to delete captions: " . $e->getMessage(); } ``` -------------------------------- ### POST /video Source: https://github.com/bunnyway/bunnystream-api-php/blob/main/README.md Create a new video object in the library. ```APIDOC ## POST /video ### Description Creates a new video object. This must be performed before uploading video content. ### Method POST ### Endpoint /video ### Parameters #### Request Body - **title** (string) - Required - The title of the video. - **collectionId** (string) - Optional - The ID of the collection to associate with the video. ### Response #### Success Response (200) - **id** (string) - The ID of the newly created video object. #### Response Example { "id": "new-video-id" } ``` -------------------------------- ### Initialize BunnyStream Client Source: https://github.com/bunnyway/bunnystream-api-php/blob/main/README.md Instantiate the BunnyCDNStream class using your library ID and API key. This object is required for all subsequent API interactions. ```php $bstream = new BunnyCDNStream("YOUR_VIDEO_LIBRARY_ID", "YOUR_STREAM_ZONE_API_KEY"); ``` -------------------------------- ### Fetch Video from External Source Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Imports a video into the library from an external URL. Supports optional headers for authentication. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $videoObject = $bstream->createVideo("Imported Video"); $videoId = $videoObject['guid']; $result = $bstream->fetchVideo($videoId, "https://example.com/videos/source-video.mp4"); $result = $bstream->fetchVideo($videoId, "https://private-server.com/protected/video.mp4", ["Authorization" => "Bearer your-access-token", "X-Custom-Header" => "custom-value"]); echo "Video fetch initiated for: " . $videoId . "\n"; } catch (Exception $e) { echo "Fetch failed: " . $e->getMessage(); } ``` -------------------------------- ### Handle API Errors in PHP Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Demonstrates how to use try-catch blocks to handle specific API exceptions, such as authentication failures, missing resources, or network issues. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $video = $bstream->getVideo("some-video-id"); } catch (Exception $e) { $message = $e->getMessage(); if (strpos($message, "Unauthorized") !== false) { echo "Authentication failed. Please check your API key.\n"; } elseif (strpos($message, "Not found") !== false) { echo "The requested video does not exist.\n"; } elseif (strpos($message, "cURL exception") !== false) { echo "Network error occurred. Please try again.\n"; } else { echo "An error occurred: " . $message . "\n"; } } ``` -------------------------------- ### POST /videos Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Create a new video object in your Stream library. ```APIDOC ## POST /videos ### Description Create a new video object in your Stream library. This must be done before uploading video content. ### Method POST ### Endpoint /videos ### Parameters #### Request Body - **title** (string) - Required - The title of the video. - **collectionId** (string) - Optional - The collection ID to associate the video with. ### Response #### Success Response (200) - **guid** (string) - The unique identifier of the created video. - **title** (string) - The title of the video. #### Response Example { "videoLibraryId": 12345, "guid": "new-video-guid", "title": "My New Video" } ``` -------------------------------- ### Manage Video Captions and Thumbnails Source: https://github.com/bunnyway/bunnystream-api-php/blob/main/README.md Utility methods to set video thumbnails and manage VRT caption files for specific videos. ```php $bstream->setVideoThumbnail("videoId", "https://image.url/thumb.jpg"); $bstream->addVideoCaptions("videoId", "en", "/path/to/file.vrt", "English"); $bstream->deleteVideoCaptions("videoId", "en"); ``` -------------------------------- ### Initialize BunnyCDN Stream Client (PHP) Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Initializes the BunnyCDN Stream client using your library ID and API key for authentication. This client object is then used for all subsequent API calls. ```php getVideo("videoId"); $list = $bstream->listVideos(1, 10); $bstream->updateVideo("videoId", "New Title", "collectionId"); $bstream->createVideo("Title"); $bstream->deleteVideo("videoId"); ``` -------------------------------- ### Error Handling Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Demonstrates how to implement robust error handling using try-catch blocks to manage various API exceptions. ```APIDOC ## Error Handling ### Description All methods throw exceptions with descriptive messages for different HTTP status codes. Implement try-catch blocks to handle API errors gracefully. ### Method N/A (Applies to all API calls) ### Endpoint N/A ### Parameters N/A ### Request Example ```php getVideo("some-video-id"); } catch (Exception $e) { $message = $e->getMessage(); if (strpos($message, "Unauthorized") !== false) { // 401 - Invalid API key echo "Authentication failed. Please check your API key.\n"; } elseif (strpos($message, "Not found") !== false) { // 404 - Video or library not found echo "The requested video does not exist.\n"; } elseif (strpos($message, "cURL exception") !== false) { // Network or connection error echo "Network error occurred. Please try again.\n"; } else { // Unknown error echo "An error occurred: " . $message . "\n"; } } ?> ``` ### Response #### Success Response (200) (Varies depending on the method called) #### Response Example (Varies depending on the method called) ### Error Codes - **401 Unauthorized**: Invalid API key or insufficient permissions. - **404 Not Found**: The requested resource (e.g., video, library) does not exist. - **cURL Exception**: Network or connection-related errors during the API request. ``` -------------------------------- ### Upload Video (Combined) Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt A convenience method that creates a video object and uploads the file in a single operation. Supports optional collection assignment. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $result = $bstream->uploadVideo("Product Demo", "/var/www/uploads/demo.mp4"); $result = $bstream->uploadVideo("Training Video", "/var/www/uploads/training.mp4", "training-collection-guid"); echo "Video uploaded and processing\n"; } catch (Exception $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Add Video Captions using PHP Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Adds subtitle or caption tracks to a video using a WebVTT file. It supports adding multiple language tracks and optional labels for user display. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $result = $bstream->addVideoCaptions( "video-guid-123", "en", "/path/to/captions-english.vrt", "English" ); $result = $bstream->addVideoCaptions( "video-guid-123", "es", "/path/to/captions-spanish.vrt", "Spanish" ); $result = $bstream->addVideoCaptions( "video-guid-123", "fr", "/path/to/captions-french.vrt" ); echo "Captions added successfully\n"; } catch (Exception $e) { echo "Failed to add captions: " . $e->getMessage(); } ``` -------------------------------- ### Create Video Object (PHP) Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Creates a new video object within your Stream library. This is a prerequisite step before uploading the actual video content. You can optionally associate the video with a specific collection. ```php createVideo("My New Video"); // Create a video in a specific collection $video = $bstream->createVideo("Tutorial Video", "collection-guid-123"); echo "Created video with GUID: " . $video['guid'] . "\n"; // Use this GUID to upload the actual video file // Expected response: // [ // 'videoLibraryId' => 12345, // 'guid' => 'new-video-guid', // 'title' => 'My New Video', // 'collectionId' => 'collection-guid-123' // ] } catch (Exception $e) { echo "Error creating video: " . $e->getMessage(); } ``` -------------------------------- ### Upload and Fetch Video Content Source: https://github.com/bunnyway/bunnystream-api-php/blob/main/README.md Methods to upload local video files or fetch videos from external sources. Requires a valid video object ID. ```php $bstream->uploadVideoWithVideoId("videoId", "/path/to/video.mp4"); $bstream->uploadVideo("Title", "/path/to/video.mp4"); $bstream->fetchVideo("videoId", "https://source.url/video.mp4"); ``` -------------------------------- ### List Videos (PHP) Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Retrieves a paginated list of videos from your Stream library. Supports basic listing, paginated results with custom parameters (page, items per page, sort order, search term, collection ID), and searching within videos. ```php listVideos(); // Paginated listing with custom parameters $videos = $bstream->listVideos( 2, // page number 25, // videos per page "date", // sort by: date, title null, // search term (optional) null // collection ID (optional) ); // Search for specific videos $searchResults = $bstream->listVideos(1, 10, "date", "tutorial"); // List videos in a specific collection $collectionVideos = $bstream->listVideos(1, 10, "date", null, "collection-guid"); foreach ($videos['items'] as $video) { echo $video['guid'] . ": " . $video['title'] . "\n"; } // Expected response structure: // [ // 'totalItems' => 150, // 'currentPage' => 1, // 'itemsPerPage' => 10, // 'items' => [ // ['guid' => '...', 'title' => '...', 'status' => 4], // ... // ] // ] } catch (Exception $e) { echo "Error: " . $e->getMessage(); } ``` -------------------------------- ### Set Video Thumbnail Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Assigns a custom thumbnail to a video by providing a public image URL. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $result = $bstream->setVideoThumbnail("video-guid-123", "https://example.com/images/custom-thumbnail.jpg"); echo "Thumbnail updated successfully\n"; } catch (Exception $e) { echo "Failed to set thumbnail: " . $e->getMessage(); } ``` -------------------------------- ### Add Video Captions Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt This endpoint allows you to add subtitle or caption tracks to a video using a VRT (WebVTT) file. You can add multiple caption tracks in different languages to the same video. ```APIDOC ## Add Video Captions ### Description Add subtitle/caption tracks to a video from a VRT (WebVTT) file. Multiple language tracks can be added to the same video. ### Method POST ### Endpoint `/videos/{videoGuid}/captions` (Assumed endpoint based on function name and parameters) ### Parameters #### Path Parameters - **videoGuid** (string) - Required - The unique identifier of the video. #### Query Parameters None #### Request Body - **language** (string) - Required - The 2-letter language code for the caption track (e.g., 'en', 'es'). - **captionFile** (file) - Required - The VRT (WebVTT) file containing the captions. - **label** (string) - Optional - A user-friendly label for the caption track (e.g., 'English', 'Spanish'). ### Request Example ```php addVideoCaptions( "video-guid-123", "en", // 2-letter language code "/path/to/captions-english.vrt", // path to VRT file "English" // label shown to users ); // Add Spanish captions $result = $bstream->addVideoCaptions( "video-guid-123", "es", "/path/to/captions-spanish.vrt", "Spanish" ); // Add captions without label (not recommended) $result = $bstream->addVideoCaptions( "video-guid-123", "fr", "/path/to/captions-french.vrt" ); echo "Captions added successfully\n"; } catch (Exception $e) { echo "Failed to add captions: " . $e->getMessage(); } ?> ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the captions were added successfully. - **message** (string) - A confirmation message. #### Response Example ```json { "success": true, "message": "Captions added successfully for video video-guid-123" } ``` ``` -------------------------------- ### DELETE /video/{videoId} Source: https://github.com/bunnyway/bunnystream-api-php/blob/main/README.md Permanently delete a video from the library. ```APIDOC ## DELETE /video/{videoId} ### Description Permanently deletes a video object and all associated files. ### Method DELETE ### Endpoint /video/{videoId} ### Parameters #### Path Parameters - **videoId** (string) - Required - The unique identifier of the video to delete. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the deletion was successful. ``` -------------------------------- ### Delete Video Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt Permanently removes a video from the Stream library. This operation is irreversible. ```php $bstream = new BunnyCDNStream("your-library-id", "your-stream-api-key"); try { $result = $bstream->deleteVideo("video-guid-to-delete"); echo "Video deleted successfully\n"; } catch (Exception $e) { echo "Delete failed: " . $e->getMessage(); } ``` -------------------------------- ### Delete Video Captions Source: https://context7.com/bunnyway/bunnystream-api-php/llms.txt This endpoint allows you to remove a specific caption track from a video by providing its language code. ```APIDOC ## Delete Video Captions ### Description Remove a caption track from a video by specifying the language code. ### Method DELETE ### Endpoint `/videos/{videoGuid}/captions/{languageCode}` (Assumed endpoint based on function name and parameters) ### Parameters #### Path Parameters - **videoGuid** (string) - Required - The unique identifier of the video. - **languageCode** (string) - Required - The 2-letter language code of the caption track to delete (e.g., 'en', 'es'). #### Query Parameters None #### Request Body None ### Request Example ```php deleteVideoCaptions("video-guid-123", "en"); // Delete Spanish captions $result = $bstream->deleteVideoCaptions("video-guid-123", "es"); echo "Captions deleted successfully\n"; } catch (Exception $e) { echo "Failed to delete captions: " . $e->getMessage(); } ?> ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the captions were deleted successfully. - **message** (string) - A confirmation message. #### Response Example ```json { "success": true, "message": "Captions for language 'en' deleted successfully for video video-guid-123" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.