Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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/v3

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/v3"
)
 
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} Aggregate one metric
GetBreakdownMetrics Post /analytics/metrics/bucket/{metric}/{breakdown} Bucket one metric by dimension
GetDataUsage Get /analytics/data Delivery volume over time
GetOvertimeMetrics Post /analytics/metrics/timeseries/{metric}/{interval} Bucket one metric by time

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 an API key
Delete Delete /api_keys/{id} Delete an API key
List Get /api_keys 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
AddLiveStreamMulticasts 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
GetLiveStreamKey Get /live_streams/{id} Get live stream key
GetLiveStreamKeys Get /live_streams Get live stream key list
GetLiveStreamMedia Get /live_streams/{id}/media Get live stream media
GetLiveStreamMedias Post /live_streams/{id}/media Get live stream media
GetLiveStreamMulticastByStreamKey Get /live_streams/multicast/{stream_key} Get live stream multicast by stream key
GetLiveStreamPlayerInfo Get /live_streams/player/{id}/media Get live stream media public
GetLiveStreamStatisticByStreamMediaId Get /live_streams/statistic/{stream_media_id} Get live stream statistic by stream media id
GetLiveStreamUsage Get /live_streams/usage/{stream_id} Get usage details for a specific live stream
GetStreaming Get /live_streams/{id}/streamings/{stream_id} Get live stream media streaming
GetStreamings Get /live_streams/{id}/streamings Get live stream media streamings
GetUserStreamsUsageDetail Get /live_streams/usage/streams Get paginated list of streams with usage details for current user
UpdateLiveStreamKey Put /live_streams/{id} Update live stream key
UpdateLiveStreamMedia 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 media list
GetMediaPlayerInfo Get /media/{id}/player.json Get media player info
SetDefaultCaption Patch /media/{id}/captions/{lan} Set the 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 media 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
Update Patch /players/{id} Update a player theme
Delete Delete /players/{id} Delete a player theme
List Get /players List player themes
UploadLogo Post /players/{id}/logo Upload a player theme logo
DeleteLogo Delete /players/{id}/logo Delete a player theme logo
Attach Post /players/add-player Add a player theme to a media
Detach Post /players/remove-player Remove a player theme from a media

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
Create Post /playlists/create Create a playlist
Get Get /playlists/{id} Get a playlist
Update Patch /playlists/{id} Update a playlist
Delete Delete /playlists/{id} Delete a playlist
List Post /playlists List playlists
DeleteThumbnail Delete /playlists/{id}/thumbnail Delete a playlist thumbnail
AddMedia Post /playlists/{id}/items Add media to playlists
GetPublic Get /playlists/{id}/player.json Get a playlist for the player
MoveItem Put /playlists/{id}/items Reorder a playlist
RemoveMedia Delete /playlists/{id}/items/{item_id} Remove an item from playlists

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 the current account

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 a webhook
Get Get /webhooks/{id} Get a webhook
Update Patch /webhooks/{id} Update a webhook
Delete Delete /webhooks/{id} Delete a webhook
List Get /webhooks List webhooks
Check Post /webhooks/check/{id} Send a test event

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

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages