Skip to content

AIOZNetwork/w3stream-go-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

W3Stream Go client

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.

Project description

W3Stream's Go client streamlines the coding process. Chunking files is handled for you, as is pagination and refreshing your tokens.

Getting started

Installation

go get github.com/AIOZNetwork/w3stream-go-client

Code sample

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!")
}

Documentation

API endpoints

All urls are relative to https://api.w3stream.xyz/api

Api key

Retrieve an instance of the ApiKey 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
Endpoints
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

Live stream

Retrieve an instance of the Live stream 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()
liveStreamApi := client.LiveStream
Endpoints
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

Players

Retrieve an instance of the players 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()
playersApi := client.Players
Endpoints
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

Playlist

Retrieve an instance of the playlist 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()
playlistApi := client.Playlist
Endpoints
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

Video

Retrieve an instance of the video 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()
videoApi := client.Video
Endpoints
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

Video chapter

Retrieve an instance of the video chapter 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()
videoChapterApi := client.VideoChapter
Endpoints
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

Watermark

Retrieve an instance of the watermark 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()
watermarkApi := client.Watermark
Endpoints
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

Webhook

Retrieve an instance of the webhook 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()
webhookApi := client.Webhook
Endpoints
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

Models

Have 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!