curl -X GET "https://api.tktchurch.com/v1/livestreams/123e4567-e89b-12d3-a456-426614174000"
const getLivestream = async (id) => {
const response = await fetch(
`https://api.tktchurch.com/v1/livestreams/${id}`
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to get livestream');
}
return response.json();
};
// Usage
try {
const livestream = await getLivestream('123e4567-e89b-12d3-a456-426614174000');
console.log('Livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
struct Livestream: Codable {
let id: UUID
let title: String
let description: String
let youtubeUrl: String?
let customStreamUrl: String?
let status: String
let scheduledStartTime: Date?
let actualStartTime: Date?
let endTime: Date?
let tags: [String]
let thumbnailUrl: String?
let thumbnail: ThumbnailInfo?
let createdByUserId: UUID
let updatedByUserId: UUID
let createdAt: Date?
let updatedAt: Date?
struct ThumbnailInfo: Codable {
let id: UUID?
let url: String
let provider: String
let key: String
}
}
func getLivestream(id: UUID) async throws -> Livestream {
let url = URL(string: "https://api.tktchurch.com/v1/livestreams/\(id)")!
let (data, response) = try await URLSession.shared.data(from: url)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode == 404 {
throw URLError(.resourceNotFound)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(Livestream.self, from: data)
}
// Usage
do {
let livestream = try await getLivestream(
id: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("Livestream:", livestream)
} catch {
print("Error:", error)
}
data class Livestream(
val id: UUID,
val title: String,
val description: String,
val youtubeUrl: String?,
val customStreamUrl: String?,
val status: String,
val scheduledStartTime: String?,
val actualStartTime: String?,
val endTime: String?,
val tags: List<String>,
val thumbnailUrl: String?,
val thumbnail: ThumbnailInfo?,
val createdByUserId: UUID,
val updatedByUserId: UUID,
val createdAt: String?,
val updatedAt: String?
) {
data class ThumbnailInfo(
val id: UUID?,
val url: String,
val provider: String,
val key: String
)
}
suspend fun getLivestream(id: UUID): Livestream {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/livestreams/$id")
.get()
.build()
return withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw when (response.code) {
404 -> NoSuchElementException("Livestream not found")
else -> IOException("Unexpected response ${response.code}")
}
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<Livestream>(body)
}
}
}
// Usage
try {
val livestream = getLivestream(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"))
println("Livestream: $livestream")
} catch (e: Exception) {
println("Error: ${e.message}")
}
interface Thumbnail {
id?: string;
url: string;
provider: 's3' | 'local';
key: string;
}
interface Livestream {
id: string;
title: string;
description: string;
youtubeUrl?: string;
customStreamUrl?: string;
status: 'scheduled' | 'live' | 'ended' | 'cancelled';
scheduledStartTime?: string;
actualStartTime?: string;
endTime?: string;
tags: string[];
thumbnailUrl?: string;
thumbnail?: Thumbnail;
createdByUserId: string;
updatedByUserId: string;
createdAt?: string;
updatedAt?: string;
}
const getLivestream = async (id: string): Promise<Livestream> => {
try {
const response = await axios.get<Livestream>(
`https://api.tktchurch.com/v1/livestreams/${id}`
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error('Livestream not found');
}
throw new Error(error.response?.data?.reason || 'Failed to get livestream');
}
throw error;
}
};
// Usage
try {
const livestream = await getLivestream('123e4567-e89b-12d3-a456-426614174000');
console.log('Livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"customStreamUrl": null,
"status": "live",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"actualStartTime": "2024-01-21T10:02:00Z",
"endTime": null,
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"thumbnail": {
"id": "123e4567-e89b-12d3-a456-426614174001",
"url": "https://storage.example.com/thumbnails/abc123.jpg",
"provider": "s3",
"key": "thumbnails/abc123.jpg"
},
"createdByUserId": "123e4567-e89b-12d3-a456-426614174002",
"updatedByUserId": "123e4567-e89b-12d3-a456-426614174002",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-21T10:02:00Z"
}
{
"error": {
"status": 404,
"reason": "Livestream not found"
}
}
Livestreams
Get Livestream
Get details of a specific livestream
GET
/
livestreams
/
{id}
curl -X GET "https://api.tktchurch.com/v1/livestreams/123e4567-e89b-12d3-a456-426614174000"
const getLivestream = async (id) => {
const response = await fetch(
`https://api.tktchurch.com/v1/livestreams/${id}`
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to get livestream');
}
return response.json();
};
// Usage
try {
const livestream = await getLivestream('123e4567-e89b-12d3-a456-426614174000');
console.log('Livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
struct Livestream: Codable {
let id: UUID
let title: String
let description: String
let youtubeUrl: String?
let customStreamUrl: String?
let status: String
let scheduledStartTime: Date?
let actualStartTime: Date?
let endTime: Date?
let tags: [String]
let thumbnailUrl: String?
let thumbnail: ThumbnailInfo?
let createdByUserId: UUID
let updatedByUserId: UUID
let createdAt: Date?
let updatedAt: Date?
struct ThumbnailInfo: Codable {
let id: UUID?
let url: String
let provider: String
let key: String
}
}
func getLivestream(id: UUID) async throws -> Livestream {
let url = URL(string: "https://api.tktchurch.com/v1/livestreams/\(id)")!
let (data, response) = try await URLSession.shared.data(from: url)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode == 404 {
throw URLError(.resourceNotFound)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(Livestream.self, from: data)
}
// Usage
do {
let livestream = try await getLivestream(
id: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("Livestream:", livestream)
} catch {
print("Error:", error)
}
data class Livestream(
val id: UUID,
val title: String,
val description: String,
val youtubeUrl: String?,
val customStreamUrl: String?,
val status: String,
val scheduledStartTime: String?,
val actualStartTime: String?,
val endTime: String?,
val tags: List<String>,
val thumbnailUrl: String?,
val thumbnail: ThumbnailInfo?,
val createdByUserId: UUID,
val updatedByUserId: UUID,
val createdAt: String?,
val updatedAt: String?
) {
data class ThumbnailInfo(
val id: UUID?,
val url: String,
val provider: String,
val key: String
)
}
suspend fun getLivestream(id: UUID): Livestream {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/livestreams/$id")
.get()
.build()
return withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw when (response.code) {
404 -> NoSuchElementException("Livestream not found")
else -> IOException("Unexpected response ${response.code}")
}
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<Livestream>(body)
}
}
}
// Usage
try {
val livestream = getLivestream(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"))
println("Livestream: $livestream")
} catch (e: Exception) {
println("Error: ${e.message}")
}
interface Thumbnail {
id?: string;
url: string;
provider: 's3' | 'local';
key: string;
}
interface Livestream {
id: string;
title: string;
description: string;
youtubeUrl?: string;
customStreamUrl?: string;
status: 'scheduled' | 'live' | 'ended' | 'cancelled';
scheduledStartTime?: string;
actualStartTime?: string;
endTime?: string;
tags: string[];
thumbnailUrl?: string;
thumbnail?: Thumbnail;
createdByUserId: string;
updatedByUserId: string;
createdAt?: string;
updatedAt?: string;
}
const getLivestream = async (id: string): Promise<Livestream> => {
try {
const response = await axios.get<Livestream>(
`https://api.tktchurch.com/v1/livestreams/${id}`
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error('Livestream not found');
}
throw new Error(error.response?.data?.reason || 'Failed to get livestream');
}
throw error;
}
};
// Usage
try {
const livestream = await getLivestream('123e4567-e89b-12d3-a456-426614174000');
console.log('Livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"customStreamUrl": null,
"status": "live",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"actualStartTime": "2024-01-21T10:02:00Z",
"endTime": null,
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"thumbnail": {
"id": "123e4567-e89b-12d3-a456-426614174001",
"url": "https://storage.example.com/thumbnails/abc123.jpg",
"provider": "s3",
"key": "thumbnails/abc123.jpg"
},
"createdByUserId": "123e4567-e89b-12d3-a456-426614174002",
"updatedByUserId": "123e4567-e89b-12d3-a456-426614174002",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-21T10:02:00Z"
}
{
"error": {
"status": 404,
"reason": "Livestream not found"
}
}
Path Parameters
string
required
The UUID of the livestream to retrieve
Response
string
Livestream’s unique identifier (UUID)
string
Title of the livestream
string
Description of the livestream
string
YouTube URL for the livestream
string
Custom streaming URL
string
Current status of the livestream. One of:
scheduled: Upcoming livestreamlive: Currently streamingended: Completed livestreamcancelled: Cancelled livestream
string
Scheduled start time in ISO 8601 format
string
Actual start time in ISO 8601 format
string
End time in ISO 8601 format
array
Array of tags associated with the livestream
string
URL of the livestream thumbnail
object
string
UUID of the user who created the livestream
string
UUID of the user who last updated the livestream
string
Creation timestamp in ISO 8601 format
string
Last update timestamp in ISO 8601 format
Error Responses
object
Common error cases:
- 404 Not Found: Livestream not found
curl -X GET "https://api.tktchurch.com/v1/livestreams/123e4567-e89b-12d3-a456-426614174000"
const getLivestream = async (id) => {
const response = await fetch(
`https://api.tktchurch.com/v1/livestreams/${id}`
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.reason || 'Failed to get livestream');
}
return response.json();
};
// Usage
try {
const livestream = await getLivestream('123e4567-e89b-12d3-a456-426614174000');
console.log('Livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
struct Livestream: Codable {
let id: UUID
let title: String
let description: String
let youtubeUrl: String?
let customStreamUrl: String?
let status: String
let scheduledStartTime: Date?
let actualStartTime: Date?
let endTime: Date?
let tags: [String]
let thumbnailUrl: String?
let thumbnail: ThumbnailInfo?
let createdByUserId: UUID
let updatedByUserId: UUID
let createdAt: Date?
let updatedAt: Date?
struct ThumbnailInfo: Codable {
let id: UUID?
let url: String
let provider: String
let key: String
}
}
func getLivestream(id: UUID) async throws -> Livestream {
let url = URL(string: "https://api.tktchurch.com/v1/livestreams/\(id)")!
let (data, response) = try await URLSession.shared.data(from: url)
guard let httpResponse = response as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
if httpResponse.statusCode == 404 {
throw URLError(.resourceNotFound)
}
if httpResponse.statusCode != 200 {
throw URLError(.badServerResponse)
}
return try JSONDecoder().decode(Livestream.self, from: data)
}
// Usage
do {
let livestream = try await getLivestream(
id: UUID(uuidString: "123e4567-e89b-12d3-a456-426614174000")!
)
print("Livestream:", livestream)
} catch {
print("Error:", error)
}
data class Livestream(
val id: UUID,
val title: String,
val description: String,
val youtubeUrl: String?,
val customStreamUrl: String?,
val status: String,
val scheduledStartTime: String?,
val actualStartTime: String?,
val endTime: String?,
val tags: List<String>,
val thumbnailUrl: String?,
val thumbnail: ThumbnailInfo?,
val createdByUserId: UUID,
val updatedByUserId: UUID,
val createdAt: String?,
val updatedAt: String?
) {
data class ThumbnailInfo(
val id: UUID?,
val url: String,
val provider: String,
val key: String
)
}
suspend fun getLivestream(id: UUID): Livestream {
val request = Request.Builder()
.url("https://api.tktchurch.com/v1/livestreams/$id")
.get()
.build()
return withContext(Dispatchers.IO) {
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
throw when (response.code) {
404 -> NoSuchElementException("Livestream not found")
else -> IOException("Unexpected response ${response.code}")
}
}
val body = response.body?.string() ?: throw IOException("Empty response")
Json.decodeFromString<Livestream>(body)
}
}
}
// Usage
try {
val livestream = getLivestream(UUID.fromString("123e4567-e89b-12d3-a456-426614174000"))
println("Livestream: $livestream")
} catch (e: Exception) {
println("Error: ${e.message}")
}
interface Thumbnail {
id?: string;
url: string;
provider: 's3' | 'local';
key: string;
}
interface Livestream {
id: string;
title: string;
description: string;
youtubeUrl?: string;
customStreamUrl?: string;
status: 'scheduled' | 'live' | 'ended' | 'cancelled';
scheduledStartTime?: string;
actualStartTime?: string;
endTime?: string;
tags: string[];
thumbnailUrl?: string;
thumbnail?: Thumbnail;
createdByUserId: string;
updatedByUserId: string;
createdAt?: string;
updatedAt?: string;
}
const getLivestream = async (id: string): Promise<Livestream> => {
try {
const response = await axios.get<Livestream>(
`https://api.tktchurch.com/v1/livestreams/${id}`
);
return response.data;
} catch (error) {
if (axios.isAxiosError(error)) {
if (error.response?.status === 404) {
throw new Error('Livestream not found');
}
throw new Error(error.response?.data?.reason || 'Failed to get livestream');
}
throw error;
}
};
// Usage
try {
const livestream = await getLivestream('123e4567-e89b-12d3-a456-426614174000');
console.log('Livestream:', livestream);
} catch (error) {
console.error('Error:', error.message);
}
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Sunday Service",
"description": "Join us for our weekly Sunday service",
"youtubeUrl": "https://youtube.com/watch?v=abc123",
"customStreamUrl": null,
"status": "live",
"scheduledStartTime": "2024-01-21T10:00:00Z",
"actualStartTime": "2024-01-21T10:02:00Z",
"endTime": null,
"tags": ["sunday-service", "worship"],
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"thumbnail": {
"id": "123e4567-e89b-12d3-a456-426614174001",
"url": "https://storage.example.com/thumbnails/abc123.jpg",
"provider": "s3",
"key": "thumbnails/abc123.jpg"
},
"createdByUserId": "123e4567-e89b-12d3-a456-426614174002",
"updatedByUserId": "123e4567-e89b-12d3-a456-426614174002",
"createdAt": "2024-01-20T15:00:00Z",
"updatedAt": "2024-01-21T10:02:00Z"
}
{
"error": {
"status": 404,
"reason": "Livestream not found"
}
}
