W3Stream 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.
W3Stream's Go client streamlines the coding process. Chunking files is handled for you, as is pagination and refreshing your tokens.
go get github.com/AIOZNetwork/w3stream-go-client
For a more advanced usage you can checkout the rest of the documentation in the docs directory
import (
"context"
"fmt"
"os"
w3streamsdk "github.com/AIOZNetwork/w3stream-go-client"
)
func main() {
// Connect to production environment
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
secretKey := "YOUR_SECRET_KEY" // Replace with your actual API secret key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
// Create a video object
title := "Sample Video Title"
videoData := w3streamsdk.CreateVideoRequest{
Title: &title,
}
createResult, err := client.Video.Create(videoData)
if err != nil {
fmt.Fprintf(os.Stderr, "Error creating video: %v\n", err)
return
}
videoId := createResult.Data.Id // Get the video ID from the response
// Open the video file
videoFile, err := os.Open("./path/to/video.mp4")
if err != nil {
fmt.Println("Error opening video file:", err)
return
}
defer videoFile.Close() // Close the file after use
fileInfo, err := videoFile.Stat()
if err != nil {
fmt.Fprintf(os.Stderr, "Error getting file info: %v\n", err)
return
}
fileSize := fileInfo.Size()
fileName := fileInfo.Name()
// Option 1: Use client upload with videoId
err = client.UploadVideo(context.Background(), *videoId, fileName, videoFile, fileSize)
if err != nil {
fmt.Fprintf(os.Stderr, "Error uploading video with client: %v\n", err)
return
}
// Option 2: Upload parts yourself
// This example is commented out as you already used option 1
//_, err = client.Video.UploadPart(*videoId, nil, nil, "./path/to/video.mp4", videoFile, fileInfo.Size())
//if err != nil {
// fmt.Fprintf(os.Stderr, "Error uploading video part: %v\n", err)
// return
//}
//
//success, err := client.Video.UploadVideoComplete(*videoId)
//if err != nil {
// fmt.Fprintf(os.Stderr, "Error completing video upload: %v\n", err)
// return
//}
//
//jsonString, err := json.MarshalIndent(success, "", " ")
//if err != nil {
// fmt.Fprintf(os.Stderr, "Error marshalling response: %v\n", err)
// return
//}
//fmt.Println(string(jsonString))
fmt.Println("Video uploaded successfully!")
}
All urls are relative to https://api.w3stream.xyz/api
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
apiKeyApi := client.ApiKey
Method | HTTP request | Description |
---|---|---|
Create | Post /api_keys |
Create API key |
Update | Patch /api_keys/{id} |
Rename api key |
Delete | Delete /api_keys/{id} |
Delete API key |
List | Get /api_keys |
Get list API keys |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
liveStreamApi := client.LiveStream
Method | HTTP request | Description |
---|---|---|
CreateLiveStreamKey | Post /live_streams |
Create live stream key |
CreateStreaming | Post /live_streams/{id}/streamings |
Create a new live stream video |
DeleteLiveStreamKey | Delete /live_streams/{id} |
Delete live stream key |
DeleteLiveStreamVideo | Delete /live_streams/{id}/videos |
Delete live stream video |
GetLiveStreamKey | Get /live_streams/{id} |
Get live stream key |
GetLiveStreamKeys | Get /live_streams |
Get live stream key list |
GetLiveStreamPlayerInfo | Get /live_streams/player/{id}/videos |
Get live stream video public |
GetLiveStreamVideo | Get /live_streams/{id}/videos |
Get live stream video |
GetLiveStreamVideos | Post /live_streams/{id}/videos |
Get live stream videos |
GetStreaming | Get /live_streams/{id}/streamings/{stream_id} |
Get live stream video streaming |
GetStreamings | Get /live_streams/{id}/streamings |
Get live stream video streamings |
UpdateLiveStreamKey | Put /live_streams/{id} |
Update live stream key |
UpdateLiveStreamVideo | Put /live_streams/{id}/streamings |
Update live stream video |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
playersApi := client.Players
Method | HTTP request | Description |
---|---|---|
Create | Post /players |
Create a player theme |
Get | Get /players/{id} |
Get a player theme by ID |
Update | Patch /players/{id} |
Update a player theme by ID |
Delete | Delete /players/{id} |
Delete a player theme by ID |
List | Get /players |
List all player themes |
UploadLogo | Post /players/{id}/logo |
Upload a logo for a player theme by ID |
DeleteLogo | Delete /players/{id}/logo |
Delete a logo for a player theme by ID |
AddPlayer | Post /players/add-player |
Add a player theme to a video |
RemovePlayer | Post /players/remove-player |
Remove a player theme from a video |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
playlistApi := client.Playlist
Method | HTTP request | Description |
---|---|---|
DeleteThumbnail | Delete /playlists/{id}/thumbnail |
Delete a playlist thumbnail |
AddItem | Post /playlists/{id}/items |
Add a video to a playlist |
CreatePlaylist | Post /playlists/create |
Create a new playlist |
DeleteItem | Delete /playlists/{id}/items/{item_id} |
Remove a video from a playlist |
DeletePlaylist | Delete /playlists/{id} |
Delete a playlist by ID |
GetPlaylistById | Get /playlists/{id} |
Get playlist by ID |
GetPlaylistInfo | Get /playlists/{id}/player.json |
Get a playlist public |
GetPlaylists | Post /playlists |
Get user's playlists |
MoveItems | Put /playlists/{id}/items |
Move a video within a playlist |
UpdatePlaylist | Patch /playlists/{id} |
Update a playlist |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
videoApi := client.Video
Method | HTTP request | Description |
---|---|---|
Create | Post /videos/create |
Create video object |
Update | Patch /videos/{id} |
update video info |
Delete | Delete /videos/{id} |
Delete video |
UploadThumbnail | Post /videos/{id}/thumbnail |
Upload video thumbnail |
CreateCaption | Post /videos/{id}/captions/{lan} |
Create a new video caption |
DeleteCaption | Delete /videos/{id}/captions/{lan} |
Delete a video caption |
GetCaptions | Get /videos/{id}/captions |
Get video captions |
GetCost | Get /videos/cost |
get video transcoding cost |
GetDetail | Get /videos/{id} |
get video detail |
GetVideoList | Post /videos |
Get user videos list |
GetVideoPlayerInfo | Get /videos/{id}/player.json |
Get video player info |
SetCaption | Patch /videos/{id}/captions/{lan} |
Set default video caption |
UploadPart | Post /videos/{id}/part |
Upload part of video |
UploadVideoComplete | Get /videos/{id}/complete |
Get upload video when complete |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
videoChapterApi := client.VideoChapter
Method | HTTP request | Description |
---|---|---|
Create | Post /videos/{id}/chapters/{lan} |
Create a video chapter |
Get | Get /videos/{id}/chapters |
Get video chapters |
Delete | Delete /videos/{id}/chapters/{lan} |
Delete a video chapter |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
watermarkApi := client.Watermark
Method | HTTP request | Description |
---|---|---|
Upload | Post /watermarks |
Create a new watermark |
Delete | Delete /watermarks/{id} |
Delete a watermark by ID |
List | Get /watermarks |
List all watermarks |
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := w3streamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client := w3streamsdk.ClientBuilder(apiCreds).Build()
webhookApi := client.Webhook
Method | HTTP request | Description |
---|---|---|
Create | Post /webhooks |
Create webhook |
Get | Get /webhooks/{id} |
Get user's webhook by id |
Update | Patch /webhooks/{id} |
Update event webhook |
Delete | Delete /webhooks/{id} |
Delete webhook |
List | Get /webhooks |
Get list webhooks |
Check | Post /webhooks/check/{id} |
Check webhook by id |
- AddPlayerThemesToVideoRequest
- AddVideoToPlaylistRequest
- ApiKey
- Asset
- Controls
- CreateApiKeyData
- CreateApiKeyRequest
- CreateApiKeyResponse
- CreateLiveStreamKeyRequest
- CreateLiveStreamKeyResponse
- CreatePlayerThemeRequest
- CreatePlayerThemesData
- CreatePlayerThemesResponse
- CreatePlaylistData
- CreatePlaylistRequest
- CreatePlaylistResponse
- CreateStreamingRequest
- CreateStreamingResponse
- CreateVideoCaptionData
- CreateVideoCaptionResponse
- CreateVideoChapterData
- CreateVideoChapterResponse
- CreateVideoRequest
- CreateVideoResponse
- CreateWatermarkData
- CreateWatermarkResponse
- CreateWebhookData
- CreateWebhookRequest
- CreateWebhookResponse
- GetAllWatermarkData
- GetAllWatermarkResponse
- GetApiKeysData
- GetApiKeysResponse
- GetLiveStreamKeyData
- GetLiveStreamKeyResponse
- GetLiveStreamKeysListData
- GetLiveStreamKeysListResponse
- GetLiveStreamVideoPublicResponse
- GetLiveStreamVideoResponse
- GetLiveStreamVideosRequest
- GetLiveStreamVideosResponse
- GetPlayerThemeByIdData
- GetPlayerThemeByIdResponse
- GetPlayerThemeData
- GetPlayerThemeResponse
- GetPlaylistByIdData
- GetPlaylistByIdResponse
- GetPlaylistListData
- GetPlaylistListRequest
- GetPlaylistListResponse
- GetStreamingResponse
- GetStreamingsResponse
- GetTranscodeCostData
- GetTranscodeCostResponse
- GetUserWebhookData
- GetUserWebhookResponse
- GetVideoCaptionsData
- GetVideoCaptionsResponse
- GetVideoChaptersData
- GetVideoChaptersResponse
- GetVideoDetailResponse
- GetVideoListData
- GetVideoListRequest
- GetVideoListResponse
- GetVideoPlayerInfoResponse
- GetWebhooksListData
- GetWebhooksListResponse
- LiveStreamAssets
- LiveStreamKeyData
- LiveStreamVideoData
- LiveStreamVideoResponse
- LiveStreamVideosResponse
- Metadata
- MoveVideoInPlaylistRequest
- PlayerTheme
- Playlist
- PlaylistItem
- PlaylistItemVideo
- PublicPlaylistObject
- QualityObject
- RemovePlayerThemesFromVideoRequest
- RenameAPIKeyRequest
- ResponseError
- ResponseSuccess
- SetDefaultCaptionRequest
- Theme
- UpdateLiveStreamKeyData
- UpdateLiveStreamKeyRequest
- UpdateLiveStreamKeyResponse
- UpdateLiveStreamVideoRequest
- UpdatePlayerThemeRequest
- UpdatePlayerThemeResponse
- UpdateVideoInfoRequest
- UpdateWebhookRequest
- UploadLogoByIdResponse
- Video
- VideoAssets
- VideoCaption
- VideoChapter
- VideoWatermark
- Watermark
- Webhook
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!