SDKs overview
Software Development Kits (SDKs) and libraries for Czech Television facilitate programmatic interaction with its digital content and services. These tools are designed to streamline the development process for integrating live broadcasts, on-demand video archives, program guides, and user-specific features into third-party applications. Official SDKs offer direct interfaces to Czech Television's core APIs, providing structured methods for common tasks such as content discovery, playback control, and metadata retrieval. Community-contributed libraries often extend this functionality, adapting it to specific frameworks or development paradigms, or offering utilities for niche use cases.
The core of these SDKs and libraries typically interacts with a RESTful API, adhering to common web standards for data exchange. This approach ensures interoperability across various programming environments and allows developers to leverage existing knowledge of HTTP and JSON. Authentication mechanisms vary depending on the specific API endpoint being accessed, ranging from simple API keys for public content access to OAuth 2.0 for user-specific features requiring authentication and authorization. Developers are advised to consult the official Czech Television API documentation for detailed information on authentication flows and endpoint specifications.
Official SDKs by language
Czech Television provides official SDKs to support developers in integrating its services across various programming environments. These SDKs are maintained by Czech Television and are designed to offer stable and supported interfaces to the underlying APIs. Each SDK is tailored to the conventions and best practices of its respective programming language, aiming to reduce the complexity of direct API calls and data parsing. The following table provides an overview of the officially supported SDKs, including their primary language, package name, typical installation command, and maturity level.
| Language | Package Name | Install Command | Maturity |
|---|---|---|---|
| JavaScript (Node.js/Browser) | @ceskatelevize/ct-sdk-js |
npm install @ceskatelevize/ct-sdk-js |
Stable |
| Python | ceskatelevize-ct-sdk-py |
pip install ceskatelevize-ct-sdk-py |
Stable |
| PHP | ceskatelevize/ct-sdk-php |
composer require ceskatelevize/ct-sdk-php |
Stable |
| Ruby | ceskatelevize-ct-sdk-ruby |
gem install ceskatelevize-ct-sdk-ruby |
Beta |
The JavaScript SDK is compatible with both Node.js environments for server-side applications and modern web browsers for client-side integrations. The Python SDK is commonly used in data processing, backend services, and scripting. The PHP SDK is designed for web applications built on the PHP platform, while the Ruby SDK is in beta and continues to receive updates based on developer feedback and ongoing feature development. For specific versioning information and release notes, developers should refer to the respective package repositories or the official Czech Television developer portal.
Installation
Installing Czech Television SDKs typically follows the standard package management practices for each programming language. The process involves using a command-line interface (CLI) tool to fetch and install the specified package from its respective repository. Prior to installation, developers should ensure they have the necessary language runtime and package manager installed and configured on their development machine. For instance, Node.js projects require npm or yarn, Python projects use pip, PHP projects utilize Composer, and Ruby projects rely on Bundler or gem.
JavaScript SDK Installation
For JavaScript projects using Node.js or a modern front-end build system, install the SDK via npm:
npm install @ceskatelevize/ct-sdk-js
Or using yarn:
yarn add @ceskatelevize/ct-sdk-js
After installation, the SDK can be imported into your JavaScript files using ES modules or CommonJS syntax.
Python SDK Installation
Python developers can install the SDK using pip, the standard package installer for Python:
pip install ceskatelevize-ct-sdk-py
It is recommended to use a virtual environment to manage dependencies for Python projects to avoid conflicts. More information on Python package management is available in the Microsoft Python documentation on managing packages with pip.
PHP SDK Installation
For PHP applications, the SDK is installed via Composer, the dependency manager for PHP:
composer require ceskatelevize/ct-sdk-php
Ensure that Composer is installed and accessible in your project directory. The SDK will be loaded automatically if your project includes Composer's autoloader.
Ruby SDK Installation
Ruby developers can install the SDK using RubyGems:
gem install ceskatelevize-ct-sdk-ruby
Alternatively, if using Bundler for dependency management, add the gem to your Gemfile:
# Gemfile
gem 'ceskatelevize-ct-sdk-ruby'
Then run bundle install to install the dependency.
Quickstart example
This quickstart example demonstrates how to use the JavaScript SDK to retrieve a list of available live streams from Czech Television. The example assumes the SDK has been installed and an API key is available for authentication. Replace YOUR_API_KEY with your actual API key obtained from the Czech Television developer portal. For security, API keys should typically be stored as environment variables or handled through secure configuration management rather than hardcoded directly in application source code, as detailed in Google's API key best practices.
JavaScript Quickstart
This example fetches and logs the titles of current live broadcasts.
import { CtSdk } from '@ceskatelevize/ct-sdk-js';
const apiKey = 'YOUR_API_KEY'; // Replace with your actual API key
const ct = new CtSdk({ apiKey });
async function getLiveStreams() {
try {
const response = await ct.live.getStreams();
console.log('Live Streams:', response.data);
if (response.data && response.data.length > 0) {
console.log('Available Live Stream Titles:');
response.data.forEach(stream => {
console.log(`- ${stream.title} (ID: ${stream.id})`);
});
} else {
console.log('No live streams currently available.');
}
} catch (error) {
console.error('Error fetching live streams:', error.message);
// Log detailed error response if available
if (error.response && error.response.data) {
console.error('API Error Details:', error.response.data);
}
}
}
getLiveStreams();
This script initializes the CtSdk with an API key and then calls the getStreams() method from the live service. It logs the raw response data and then iterates through the available streams to print their titles and IDs. Error handling is included to catch potential issues during the API call, such as network errors or invalid API keys. Developers can adapt this pattern to access other services and endpoints provided by the SDK, such as on-demand content search or program guide information.
Community libraries
Beyond the official SDKs, the Czech Television developer community has contributed several libraries and tools that extend functionality or offer alternative interfaces. These community-driven projects can provide specialized features, support for less common programming languages or frameworks, or simplified wrappers for specific API tasks. While not officially supported by Czech Television, these libraries often reflect innovative approaches and can be valuable resources for developers with particular needs.
Examples of community contributions include:
ct-python-scraper(Python): A library focused on parsing specific content structures not directly exposed by the official API, useful for data analysis or archiving projects.react-ct-player(JavaScript/React): A React component that simplifies embedding Czech Television video players into React applications, handling player initialization and event listeners.ct-go-client(Go): An unofficial client library for the Go programming language, providing idiomatic Go bindings for interacting with the Czech Television API. This is often preferred by Go developers for integration into Go-based microservices or CLI tools.ct-swift-kit(Swift): A community-maintained library for iOS and macOS developers, offering Swifty interfaces to access Czech Television content for native Apple platform applications.
Developers considering community libraries should evaluate their active maintenance, documentation quality, and compatibility with the latest Czech Television API versions. It is advisable to review the source code and community support channels (e.g., GitHub repositories, forums) before integrating them into production environments. Links to prominent community projects are often shared on the Czech Television developer forum or repositories like GitHub, which hosts a wide array of open-source projects.
When using community libraries, it is important to understand that their stability and feature set may not be guaranteed to the same extent as official SDKs. Updates to the underlying Czech Television API might require updates to community libraries, which could lead to temporary incompatibilities if not actively maintained. However, for rapid prototyping, specific platform integrations, or niche use cases, these community efforts can significantly accelerate development.