A .NET library to access the livecoding.tv API
Supported platform :
- .NET Framework 4.5
- Windows 8, Windows 8.1
- Windows Phone 8.1
- Windows 10 (UWP)
- Xamarin.iOS
- Xamarin.Android (not available - 1 issue to fix)
Take a look at the livecoding API documentation here : https://www.livecoding.tv/developer/documentation/#!/api
Initialize an instance of LivecodingApiService
and you are ready to use the livecoding API.
First, retrieve token through Authentication/Login process and then call API endpoints with methods available in the API service.
To retrieve a token and access API endpoints, you have to provide the client id, client secret of your application (OAuth credentials).
And you have to provide the scopes
list, a list of granted access your application requires.
var apiService = new LivecodingApiService();
var scopes = new string[] { AuthenticationScope.Read };
bool? isAuthenticated = await apiService.LoginAsync("<your-client-id>", "<your-client-secret>", scopes);
If isAuthenticated == true
, it means you have been successfully authenticated and the token provided allows you to make API calls.
In other case, something went wrong during the authentication process.
The API endpoints for with pagination is written with some Hypermedia controls
.
The pagination also contains properties to enable search, ordering, filtering.
Here is a short description of pagination :
Page
- from 1 to TotalPagesCount
- number of results present in the pageItemsPerPage
- maximum number of results per pageSearch
- text search on itemsOrdering
- order items based on a field, max 1 ordering field per requestDescendingOrdering
- if true, ordering field is in DESC mode instead of ASC modeFilters
- list of filters to dive into items results
// Assuming you have been succesfully authenticated
var apiService = new LivecodingApiService();
var paginationRequest = new PaginationRequest
{
Search = "uwp",
ItemsPerPage = 20,
Page = 2
};
var paginationVideos = await apiService.GetVideosAsync(paginationRequest);
Now, you can use paginationVideos.Results
which is a list of videos based on your search request.
You can order your results by some field (example: creation date, slug, ..). Here is an example to get the latest created videos about "UWP".
// Assuming you have been succesfully authenticated
var apiService = new LivecodingApiService();
var paginationRequest = new PaginationRequest
{
Search = "uwp",
ItemsPerPage = 20,
Ordering = VideoOrderingField.CreationDate,
DescendingOrdering = true
};
var paginationVideos = await apiService.GetVideosAsync(paginationRequest);
You can filter your results by some field (example: coding category, difficulty, ..). Here is an example to get videos about ruby programming.
// Assuming you have been succesfully authenticated
var apiService = new LivecodingApiService();
var paginationRequest = new PaginationRequest
{
ItemsPerPage = 20
};
paginationRequest.Filters.Add(VideoFilteringField.CodingCategory, "ruby");
var paginationVideos = await apiService.GetVideosAsync(paginationRequest);
Do not forget that your API can be break. So, here is a way to handle exceptions using the normal implementation.
var apiService = new LivecodingApiService();
try
{
bool? isAuthenticated = await apiService.LoginAsync("<your-client-id>", "<your-client-secret>", scopes);
}
catch (Exception ex)
{
// TODO
}
Initialize an instance of ReactiveLivecodingApiService
and you are ready to use the livecoding API using the Reactive Extensions paradigm.
First, retrieve token through Authentication/Login process and then call API endpoints with methods available in the API service.
To retrieve a token and access API endpoints, you have to provide the client id, client secret of your application (OAuth credentials).
And you have to provide the scopes
list, a list of granted access your application requires.
var reactiveApiService = new ReactiveLivecodingApiService();
var scopes = new string[] { AuthenticationScope.Read };
reactiveApiService.Login("<your-client-id>", "<your-client-secret>", scopes)
.Subscribe((isAuthenticated) =>
{
// TODO
},
(error) =>
{
// TODO
});
If isAuthenticated == true
, it means you have been successfully authenticated and the token provided allows you to make API calls.
In other case, something went wrong during the authentication process.
The API endpoints for with pagination is written with some Hypermedia controls
.
The pagination also contains properties to enable search, ordering, filtering.
Here is a short description of pagination :
Page
- from 1 to TotalPagesCount
- number of results present in the pageItemsPerPage
- maximum number of results per pageSearch
- text search on itemsOrdering
- order items based on a field, max 1 ordering field per requestDescendingOrdering
- if true, ordering field is in DESC mode instead of ASC modeFilters
- list of filters to dive into items results
// Assuming you have been succesfully authenticated
var reactiveApiService = new ReactiveLivecodingApiService();
var paginationRequest = new PaginationRequest
{
Search = "uwp",
ItemsPerPage = 20,
Page = 2
};
reactiveApiService.GetVideos(paginationRequest)
.Subscribe((paginationVideos) =>
{
// TODO
},
(error) =>
{
// TODO
});
Now, you can use paginationVideos.Results
which is a list of videos based on your search request.
You can order your results by some field (example: creation date, slug, ..). Here is an example to get the latest created videos about "UWP".
// Assuming you have been succesfully authenticated
var reactiveApiService = new ReactiveLivecodingApiService();
var paginationRequest = new PaginationRequest
{
Search = "uwp",
ItemsPerPage = 20,
Ordering = VideoOrderingField.CreationDate,
DescendingOrdering = true
};
reactiveApiService.GetVideos(paginationRequest)
.Subscribe((paginationVideos) =>
{
// TODO
},
(error) =>
{
// TODO
});
You can filter your results by some field (example: coding category, difficulty, ..). Here is an example to get videos about ruby programming.
// Assuming you have been succesfully authenticated
var reactiveApiService = new ReactiveLivecodingApiService();
var paginationRequest = new PaginationRequest
{
ItemsPerPage = 20
};
paginationRequest.Filters.Add(VideoFilteringField.CodingCategory, "ruby");
reactiveApiService.GetVideos(paginationRequest)
.Subscribe((paginationVideos) =>
{
// TODO
},
(error) =>
{
// TODO
});
Do not forget that your API can be break. So, here is a way to handle exceptions using the reactive implementation.
Using Reactive Extensions, you can retrieve exceptions thrown in the OnError
handler.
So, error
variable is the Exception that has been thrown inside the service.
var reactiveApiService = new ReactiveLivecodingApiService();
reactiveApiService.Login("<your-client-id>", "<your-client-secret>", scopes)
.Subscribe((isAuthenticated) =>
{
// TODO
},
(error) =>
{
// TODO : `error` is the Exception that has been thrown
});