Yattee v2 rewrite

This commit is contained in:
Arkadiusz Fal
2026-02-08 18:31:16 +01:00
parent 20d0cfc0c7
commit 05f921d605
1043 changed files with 163875 additions and 68430 deletions

View File

@@ -0,0 +1,38 @@
//
// PeerTubeDirectoryAPI.swift
// Yattee
//
// API client for the PeerTube public instance directory.
//
import Foundation
/// API client for fetching PeerTube instances from the public directory.
actor PeerTubeDirectoryAPI {
private let httpClient: HTTPClient
private let baseURL = URL(string: "https://instances.joinpeertube.org")!
init(httpClient: HTTPClient) {
self.httpClient = httpClient
}
/// Fetches instances from the public directory.
/// - Parameters:
/// - start: The offset for pagination (default: 0).
/// - count: The number of instances to fetch (default: 50).
/// - Returns: A response containing the total count and array of instances.
/// - Note: The API does not support server-side filtering by language/country.
/// Filtering should be done client-side after fetching all instances.
func fetchInstances(
start: Int = 0,
count: Int = 50
) async throws -> PeerTubeDirectoryResponse {
let query: [String: String] = [
"start": String(start),
"count": String(count)
]
let endpoint = GenericEndpoint.get("/api/v1/instances", query: query)
return try await httpClient.fetch(endpoint, baseURL: baseURL)
}
}