The Uiza API is organized around RESTful standard. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. JSON is returned by all API responses, including errors, although our API libraries convert responses to appropriate language-specific objects.
The library building project provides convenient access to the Uiza API, supporting .NET Standard 1.6+, .NET Core 2.0+, and .NET Framework 4.5.2+
See the .NET API docs.
From the command line:
nuget install Uiza
From Package Manager:
PM> Install-Package Uiza
From within Visual Studio:
- Open the Solution Explorer.
- Right-click on a project within your solution.
- Click on Manage NuGet Packages...
- Click on the Browse tab and search for "Uiza".
- Click on the Uiza package, select the appropriate version in the right-tab and click Install.
You can configure the Uiza package to use your secret API key by the way:
In your application initialization, set your API key (only once once during startup):
UizaConfiguration.SetupUiza(new UizaConfigOptions
{
ApiKey = "Your api key here",
AppId = "Your AppId"
});
You can obtain your secret API key from the API Settings in the Dashboard.
- Make sure to review open issues and pull requests before opening a new issue.
- Feel free to leave a comment or reaction on any existing issues.
TheUizaData
class inheritance from UizaResponse.
/// <summary>
///
/// </summary>
public class UizaData : UizaResponse
{
/// <summary>
///
/// </summary>
[JsonProperty("data")]
public dynamic Data { get; set; }
}
Using QueryJsonDynamic
to Parse API Response
see the Create Entity API
and Example
var service = new EntityService();
var result = service.Create(...);
Console.WriteLine(string.Format("Create New Entity Id = {0} Success", result.Data.id));
TheUizaException
Object is an attribute inheritance from Exception
/// <summary>
///
/// </summary>
public class UizaException : Exception
{
/// <summary>
/// constain errors with Uiza.Net Format
/// </summary>
public UizaExceptionResponse UizaInnerException { get; set; }
/// <summary>
///
/// </summary>
public UizaException()
{
}
/// <summary>
///
/// </summary>
/// <param name="message"></param>
public UizaException(string message)
: base(message)
{
}
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="ex"></param>
public UizaException(string message, Exception ex)
: base(message, ex)
{
}
/// <summary>
/// Constructor Exception from API Response
/// </summary>
/// <param name="error"></param>
public UizaException(UizaExceptionResponse error)
: base(error.Message)
{
this.UizaInnerException = error;
}
/// <summary>
/// Constructor Exception with custom Error
/// </summary>
/// <param name="message"></param>
/// <param name="error"></param>
public UizaException(string message, UizaExceptionResponse error)
: base(message)
{
this.UizaInnerException = error;
}
}
using try catch to handle Error
try
{
////
}
catch (UizaException ex)
{
var result = ex.UizaInnerException.Error;
}
UizaExceptionResponse
TheUizaExceptionResponse
public class UizaExceptionResponse
{
/// <summary>
///
/// </summary>
[JsonProperty("code")]
public int Code { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("retryable")]
public bool RetryAble { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("message")]
public string Message { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("data")]
public dynamic Data { get; set; }
/// <summary>
///
/// </summary>
public ErrorData Error
{
get
{
return Errors.FirstOrDefault() ?? new ErrorData();
}
}
/// <summary>
///
/// </summary>
public List<ErrorData> Errors
{
get
{
if (Data is JArray)
return JsonConvert.DeserializeObject<List<ErrorData>>(JsonConvert.SerializeObject(Data));
if (Data is string)
return new List<ErrorData>() {
new ErrorData()
{
Message = Message,
Type = Type
}
};
if (Data is JObject)
return new List<ErrorData>() {
JsonConvert.DeserializeObject<ErrorData>(JsonConvert.SerializeObject(Data))
};
return new List<ErrorData>() {
JsonConvert.DeserializeObject<ErrorData>(JsonConvert.SerializeObject(Data))
};
}
}
/// <summary>
///
/// </summary>
public string DescriptionLink { get; set; }
}
/// <summary>
///
/// </summary>
public class ErrorData
{
/// <summary>
///
/// </summary>
[JsonProperty("message")]
public string Message { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("type")]
public string Type { get; set; }
/// <summary>
///
/// </summary>
[JsonProperty("field")]
public string Field { get; set; }
}
Uiza use Xunit to Unitest and OpenCover to test Code Coverage See details here.
try
{
var service = new EntityService();
var result = service.Create(...);
Console.WriteLine(string.Format("Create New Entity Id = {0} Success", result.Data.id));
Console.ReadLine();
}
catch (UizaException ex)
{
var result = ex.UizaInnerException.Error;
Console.WriteLine(ex.Message);
Console.ReadLine();
}
These below APIs used to take action with your media files (we called Entity). Entity API. See details here.
var result = UizaServices.Entity.Create(new CreateEntityParameter()
{
Name = "Sample Video",
InputType = EntityInputTypes.S3Uiza,
URL = ""
});
Console.WriteLine(string.Format("Create New Entity Id = {0} Success", result.Data.id));
Category has been splits into 3 types: folder
, playlist
and tag
. These will make the management of category more easier. Category API.
See details here.
var createResult = UizaServices.Category.Create(new CreateCategoryParameter()
{
Name = string.Format("Category name {0}", Guid.NewGuid().ToString()),
Type = CategoryTypes.Folder
});
Console.WriteLine(string.Format("Create New Category Id = {0} Success", createResult.Data.id));
You can add your storage (FTP
, AWS S3
) with UIZA.
After synced, you can select your content easier from your storage to Store API.
See details here.
var result = UizaServices.Storage.Add(new AddStorageParameter()
{
Name = "FTP Uiza",
Host = "ftp-example.uiza.io",
Description = "FTP of Uiza, use for transcode",
StorageType = StorageInputTypes.Ftp,
UserName = "uiza",
Password = "=59x@LPsd+w7qW",
Port = 21
});
Console.WriteLine(string.Format("Add New Storage Id = {0} Success", result.Data.id));
These APIs used to create and manage live streaming event.
- When a Live is not start : it's named as
Event
. - When have an
Event
, you can start it : it's named asFeed
.
using Uiza.Net.Services;
UizaConfiguration.SetupUiza(new UizaConfigOptions
{
ApiKey = "your-ApiKey",
ApiBase = "your-workspace-api-domain.uiza.co"
});
var result = UizaServices.Storage.Add(new AddStorageParameter()
{
Name = "FTP Uiza",
Host = "ftp-example.uiza.io",
Description = "FTP of Uiza, use for transcode",
StorageType = StorageInputTypes.Ftp,
UserName = "uiza",
Password = "=59x@LPsd+w7qW",
Port = 21
});
Console.WriteLine(string.Format("Create Live Streaming Success New Id = {0}", result.Data.id));
See details here.
Callback used to retrieve an information for Uiza to your server, so you can have a trigger notice about an entity is upload completed and .
using Uiza.Net.Services;
UizaConfiguration.SetupUiza(new UizaConfigOptions
{
ApiKey = "your-ApiKey",
ApiBase = "your-workspace-api-domain.uiza.co"
});
var createResult = UizaServices.Callback.Create(new CreateCallbackParameter()
{
Url = "https://callback-url.uiza.co",
Method = CallbackMethodTypes.Post,
});
Console.WriteLine(string.Format("Create New Callback Id = {0} Success", createResult.Data.id));
See details here.
We welcome contributions from anyone interested in Uiza or Uiza.net development. If you'd like to submit a pull request, it's best to start with an issue to describe what you'd like to build.