api.video PHP client
api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
Table of contents
- Project description
- Getting started
- Documentation
- Have you gotten use from this API client?
- Contribution
Project description
api.video's PHP API client streamlines the coding process. Chunking files is handled for you, as is pagination and refreshing your tokens.
Getting started
Installation
composer require api-video/php-api-clientInitialization
Due to PHP PSR support, you must initialize the client with 3 to 5 arguments:
- Base URI, which can be either
https://sandbox.api.videoorhttps://ws.api.video - Your API key, available on your account
- HTTP client
- (Request factory)
- (Stream factory)
Note : If the HTTP client also implements RequestFactoryInterface and StreamFactoryInterface, then it is not necessary to pass this object in 4th and 5th argument.
Symfony HTTP client example
The Symfony HTTP client has the triple advantage of playing the role of HTTP client, but also of request factory and stream factory. It is therefore sufficient to pass it as an argument 3 times.
If the HTTP client isn't yet in your project, you can add it with:
composer require symfony/http-client composer require nyholm/psr7Code sample
Client initialization
<?php require __DIR__ . '/vendor/autoload.php'; $httpClient = new \Symfony\Component\HttpClient\Psr18Client(); $client = new \ApiVideo\Client\Client( 'https://sandbox.api.video', 'YOUR_API_KEY', $httpClient ); ?>Create a video
$payload = (new VideoCreationPayload()) ->setTitle('Test video creation'); // the `$client` must already be initialized. $video = $client->videos()->create($payload);Upload a video
$payload = (new VideoCreationPayload()) ->setTitle('Test video creation'); $video = $client->videos()->create($payload); // the `$client` must already be initialized. $client->videos()->upload( $video->getVideoId(), new SplFileObject(__DIR__.'/../earth.mp4') );Documentation
API Endpoints
AnalyticsApi
Method Description HTTP request getAggregatedMetrics() Retrieve aggregated metrics GET /data/metrics/{metric}/{aggregation}getMetricsBreakdown() Retrieve metrics in a breakdown of dimensions GET /data/buckets/{metric}/{breakdown}getMetricsOverTime() Retrieve metrics over time GET /data/timeseries/{metric}CaptionsApi
Method Description HTTP request upload() Upload a caption POST /videos/{videoId}/captions/{language}get() Retrieve a caption GET /videos/{videoId}/captions/{language}update() Update a caption PATCH /videos/{videoId}/captions/{language}delete() Delete a caption DELETE /videos/{videoId}/captions/{language}list() List video captions GET /videos/{videoId}/captionsChaptersApi
Method Description HTTP request upload() Upload a chapter POST /videos/{videoId}/chapters/{language}get() Retrieve a chapter GET /videos/{videoId}/chapters/{language}delete() Delete a chapter DELETE /videos/{videoId}/chapters/{language}list() List video chapters GET /videos/{videoId}/chaptersLiveStreamsApi
Method Description HTTP request create() Create live stream POST /live-streamsget() Retrieve live stream GET /live-streams/{liveStreamId}update() Update a live stream PATCH /live-streams/{liveStreamId}delete() Delete a live stream DELETE /live-streams/{liveStreamId}list() List all live streams GET /live-streamsuploadThumbnail() Upload a thumbnail POST /live-streams/{liveStreamId}/thumbnaildeleteThumbnail() Delete a thumbnail DELETE /live-streams/{liveStreamId}/thumbnailcomplete() Complete a live stream PUT /live-streams/{liveStreamId}/completePlayerThemesApi
Method Description HTTP request create() Create a player POST /playersget() Retrieve a player GET /players/{playerId}update() Update a player PATCH /players/{playerId}delete() Delete a player DELETE /players/{playerId}list() List all player themes GET /playersuploadLogo() Upload a logo POST /players/{playerId}/logodeleteLogo() Delete logo DELETE /players/{playerId}/logoSummariesApi
Method Description HTTP request create() Generate video summary POST /summariesupdate() Update summary details PATCH /summaries/{summaryId}/sourcedelete() Delete video summary DELETE /summaries/{summaryId}list() List summaries GET /summariesgetSummarySource() Get summary details GET /summaries/{summaryId}/sourceTagsApi
Method Description HTTP request list() List all video tags GET /tagsUploadTokensApi
Method Description HTTP request createToken() Generate an upload token POST /upload-tokensgetToken() Retrieve upload token GET /upload-tokens/{uploadToken}deleteToken() Delete an upload token DELETE /upload-tokens/{uploadToken}list() List all active upload tokens GET /upload-tokensVideosApi
Method Description HTTP request create() Create a video object POST /videosupload() Upload a video POST /videos/{videoId}/sourceuploadWithUploadToken() Upload with an delegated upload token POST /uploadget() Retrieve a video object GET /videos/{videoId}update() Update a video object PATCH /videos/{videoId}delete() Delete a video object DELETE /videos/{videoId}list() List all video objects GET /videosuploadThumbnail() Upload a thumbnail POST /videos/{videoId}/thumbnailpickThumbnail() Set a thumbnail PATCH /videos/{videoId}/thumbnailgetDiscarded() Retrieve a discarded video object GET /discarded/videos/{videoId}getStatus() Retrieve video status and details GET /videos/{videoId}/statuslistDiscarded() List all discarded video objects GET /discarded/videosupdateDiscarded() Update a discarded video object PATCH /discarded/videos/{videoId}WatermarksApi
Method Description HTTP request upload() Upload a watermark POST /watermarksdelete() Delete a watermark DELETE /watermarks/{watermarkId}list() List all watermarks GET /watermarksWebhooksApi
Method Description HTTP request create() Create Webhook POST /webhooksget() Retrieve Webhook details GET /webhooks/{webhookId}delete() Delete a Webhook DELETE /webhooks/{webhookId}list() List all webhooks GET /webhooksModels
- AccessToken
- AdditionalBadRequestErrors
- AnalyticsAggregatedMetricsResponse
- AnalyticsAggregatedMetricsResponseContext
- AnalyticsAggregatedMetricsResponseContextTimeframe
- AnalyticsData
- AnalyticsMetricsBreakdownResponse
- AnalyticsMetricsBreakdownResponseContext
- AnalyticsMetricsBreakdownResponseData
- AnalyticsMetricsOverTimeResponse
- AnalyticsMetricsOverTimeResponseContext
- AnalyticsMetricsOverTimeResponseData
- AnalyticsPlays400Error
- AnalyticsPlaysResponse
- AuthenticatePayload
- BadRequest
- BytesRange
- Caption
- CaptionsListResponse
- CaptionsUpdatePayload
- Chapter
- ChaptersListResponse
- ConflictError
- DiscardedVideoUpdatePayload
- FilterBy
- FilterBy1
- FilterBy2
- Link
- ListTagsResponse
- ListTagsResponseData
- LiveStream
- LiveStreamAssets
- LiveStreamCreationPayload
- LiveStreamListResponse
- LiveStreamUpdatePayload
- Metadata
- Model403ErrorSchema
- NotFound
- Pagination
- PaginationLink
- PlayerSessionEvent
- PlayerTheme
- PlayerThemeAssets
- PlayerThemeCreationPayload
- PlayerThemeUpdatePayload
- PlayerThemesListResponse
- Quality
- RefreshTokenPayload
- RestreamsRequestObject
- RestreamsResponseObject
- SummariesListResponse
- Summary
- SummaryCreationPayload
- SummarySource
- SummaryUpdatePayload
- TokenCreationPayload
- TokenListResponse
- TooManyRequests
- UnrecognizedRequestUrl
- UploadToken
- Video
- VideoAssets
- VideoClip
- VideoCreationPayload
- VideoSource
- VideoSourceLiveStream
- VideoSourceLiveStreamLink
- VideoStatus
- VideoStatusEncoding
- VideoStatusEncodingMetadata
- VideoStatusIngest
- VideoStatusIngestReceivedParts
- VideoThumbnailPickPayload
- VideoUpdatePayload
- VideoWatermark
- VideosListResponse
- Watermark
- WatermarksListResponse
- Webhook
- WebhooksCreationPayload
- WebhooksListResponse
Authentication
Some endpoints don't require authentication. These one can be called with a Client instantiated with a
nullAPI key:<?php require __DIR__ . '/vendor/autoload.php'; $httpClient = new \Symfony\Component\HttpClient\Psr18Client(); $client = new \ApiVideo\Client\Client( 'https://sandbox.api.video', null, $httpClient ); ?>Chunks
The video is automatically split into 50 Mb chunks.
To modify the size of the chunks, fill in the last argument
$contentRangeas follows:bytes 0-{size}/0where{size}is the size of the chunk.
For example :
bytes 0-500000/0for 500 Kb chunks.The chunks size value must be between 5 Mb and 128mb.
Tests
In order to run the PhpUnit tests, it is necessary to enter two variables in the command line:
BASE_URI(for example :https://sandbox.api.video)API_KEY
These identifiers must belong to a real api.video account.
$ BASE_URI="" API_KEY="..." vendor/bin/phpunitHave you gotten use from this API client?
Please take a moment to leave a star on the client ⭐
This helps other users to find the clients and also helps us understand which clients are most popular. Thank you!
Contribution
Since this API client is generated from an OpenAPI description, we cannot accept pull requests made directly to the repository. If you want to contribute, you can open a pull request on the repository of our client generator. Otherwise, you can also simply open an issue detailing your need on this repository.
- Base URI, which can be either
