Skip to content

AIOZNetwork/aioz-stream-go-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AIOZ Stream Go client

AIOZ Stream 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

AIOZ Stream'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/aioz-stream-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"
 
	aiozstreamsdk "github.com/AIOZNetwork/aioz-stream-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 := aiozstreamsdk.AuthCredentials{
		PublicKey: publicKey,
		SecretKey: secretKey,
	}
    client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
 
    // Create a video object
	title := "Sample Video Title"
	videoData := aiozstreamsdk.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.aiozstream.network/api

Analytics

Retrieve an instance of the Analytics API:
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
analyticsApi := client.Analytics
Endpoints
Method HTTP request Description
GetAggregatedMetrics Post /analytics/metrics/data/{metric}/{aggregation} Get aggregated metrics
GetBreakdownMetrics Post /analytics/metrics/bucket/{metric}/{breakdown} Get breakdown metrics
GetDataUsage Get /analytics/data Get data usage
GetOvertimeMetrics Post /analytics/metrics/timeseries/{metric}/{interval} Get overtime metrics
GetStatisticMedias Get /analytics/media Get statistic media

ApiKey

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 := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.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

LiveStream

Retrieve an instance of the LiveStream API:
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
liveStreamApi := client.LiveStream
Endpoints
Method HTTP request Description
UploadThumbnail Post /live_streams/{id}/thumbnail Upload live stream media thumbnail
DeleteThumbnail Delete /live_streams/{id}/thumbnail Delete live stream media thumbnail
AddMulticast Post /live_streams/multicast/{stream_key} Add live stream multicast
CreateLiveStreamKey Post /live_streams Create live stream key
CreateStreaming Post /live_streams/{id}/streamings Create a new live stream media
DeleteLiveStreamKey Delete /live_streams/{id} Delete live stream key
DeleteLiveStreamMulticast Delete /live_streams/multicast/{stream_key} Delete live stream multicast
DeleteStreaming Delete /live_streams/{id}/streamings/{stream_id} Delete live stream video
GetLiveStreamKey Get /live_streams/{id} Get live stream key
GetLiveStreamKeys Get /live_streams Get live stream key list
GetLiveStreamMulticastByStreamKey Get /live_streams/multicast/{stream_key} Get live stream multicast by stream key
GetLiveStreamPlayerInfo Get /live_streams/player/{id}/media Get live stream video public
GetLiveStreamStatisticByStreamMediaId Get /live_streams/statistic/{stream_media_id} Get live stream statistic by stream media id
GetLiveStreamVideo Get /live_streams/{id}/video Get live stream video
GetMedias Post /live_streams/{id}/media Get live stream media
GetStreaming Get /live_streams/{id}/streamings/{stream_id} Get live stream media streaming
GetStreamings Get /live_streams/{id}/streamings Get live stream media streamings
UpdateLiveStreamKey Put /live_streams/{id} Update live stream key
UpdateMedia Put /live_streams/{id}/streamings Update live stream media

Media

Retrieve an instance of the Media API:
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
mediaApi := client.Media
Endpoints
Method HTTP request Description
Create Post /media/create Create media object
Update Patch /media/{id} update media info
Delete Delete /media/{id} Delete media
UploadThumbnail Post /media/{id}/thumbnail Upload media thumbnail
DeleteThumbnail Delete /media/{id}/thumbnail Delete media thumbnail
CreateCaption Post /media/{id}/captions/{lan} Create a new media caption
DeleteCaption Delete /media/{id}/captions/{lan} Delete a media caption
GetCaptions Get /media/{id}/captions Get media captions
GetCost Get /media/cost get media transcoding cost
GetDetail Get /media/{id} get media detail
GetMediaList Post /media Get user videos list
GetMediaPlayerInfo Get /media/{id}/player.json Get media object
SetDefaultCaption Patch /media/{id}/captions/{lan} Set default caption
UploadMediaComplete Get /media/{id}/complete Get upload media when complete
UploadPart Post /media/{id}/part Upload part of media

MediaChapter

Retrieve an instance of the MediaChapter API:
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
mediaChapterApi := client.MediaChapter
Endpoints
Method HTTP request Description
Create Post /media/{id}/chapters/{lan} Create a media chapter
Get Get /media/{id}/chapters Get media chapters
Delete Delete /media/{id}/chapters/{lan} Delete a video chapter

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 := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.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 := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
playlistApi := client.Playlist
Endpoints
Method HTTP request Description
AddVideoToPlaylist Post /playlists/{id}/items Add a video to a playlist
CreatePlaylist Post /playlists/create Create a playlist
DeletePlaylistById Delete /playlists/{id} Delete a playlist by ID
DeletePlaylistThumbnail Delete /playlists/{id}/thumbnail Delete a playlist thumbnail
GetPlaylistById Get /playlists/{id} Get playlist by ID
GetPlaylistPublicInfo Get /playlists/{id}/player.json Get a playlist public
GetPlaylists Post /playlists Get user's playlists
MoveVideoInPlaylist Put /playlists/{id}/items Move a video in a playlist
RemoveMediaFromPlaylist Delete /playlists/{id}/items/{item_id} Remove a media from a playlist
UpdatePlaylist Patch /playlists/{id} Update a playlist

User

Retrieve an instance of the User API:
secretKey := "YOUR_SECRET_KEY" // Replace with your actual secret key
publicKey := "YOUR_PUBLIC_KEY" // Replace with your public key
apiCreds := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.ClientBuilder(apiCreds).Build()
userApi := client.User
Endpoints
Method HTTP request Description
GetMe Get /user/me Get me

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 := aiozstreamsdk.AuthCredentials{
	PublicKey: publicKey,
	SecretKey: secretKey,
}
client := aiozstreamsdk.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!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors