### Get Book Progression - Request Examples Source: https://komga.org/docs/openapi/get-book-progression Examples demonstrating how to call the Get Book Progression API using cURL and various programming languages. These examples include setting the 'Accept' header and the 'Authorization' header for basic authentication. ```curl curl -L 'https://demo.komga.org/api/v1/books/:bookId/progression' \ -H 'Accept: application/json' \ -H 'Authorization: Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' ``` ```python # Python example requires an HTTP client library like requests # import requests # # url = "https://demo.komga.org/api/v1/books/{bookId}/progression" # headers = { # "Accept": "application/json", # "Authorization": "Basic " # } # response = requests.get(url, headers=headers) # print(response.json()) ``` ```nodejs // Node.js example using 'axios' // const axios = require('axios'); // // const bookId = 'your_book_id'; // const url = `https://demo.komga.org/api/v1/books/${bookId}/progression`; // const headers = { // 'Accept': 'application/json', // 'Authorization': 'Basic ' // }; // // axios.get(url, { headers }) // .then(response => { // console.log(response.data); // }) // .catch(error => { // console.error(error); // }); ``` ```java // Java example using Apache HttpClient // import org.apache.http.client.methods.HttpGet; // import org.apache.http.impl.client.CloseableHttpClient; // import org.apache.http.impl.client.HttpClients; // import org.apache.http.util.EntityUtils; // import java.util.Base64; // // String bookId = "your_book_id"; // String url = "https://demo.komga.org/api/v1/books/" + bookId + "/progression"; // String credentials = "username:password"; // String encodedCredentials = Base64.getEncoder().encodeToString(credentials.getBytes()); // // CloseableHttpClient httpClient = HttpClients.createDefault(); // HttpGet request = new HttpGet(url); // request.addHeader("Accept", "application/json"); // request.addHeader("Authorization", "Basic " + encodedCredentials); // // try { // String responseBody = httpClient.execute(request, httpResponse -> EntityUtils.toString(httpResponse.getEntity())); // System.out.println(responseBody); // } finally { // httpClient.close(); // } ``` ```kotlin // Kotlin example using Ktor Client // import io.ktor.client.*; // import io.ktor.client.request.*; // import io.ktor.client.statement.*; // import io.ktor.http.*; // import kotlin.text.toByteArray // import java.util.Base64 // // suspend fun getBookProgression(bookId: String) { // val client = HttpClient() // val url = "https://demo.komga.org/api/v1/books/$bookId/progression" // val credentials = "username:password" // val encodedCredentials = Base64.getEncoder().encodeToString(credentials.toByteArray()) // // val response: HttpResponse = client.get(url) { // header(HttpHeaders.Accept, ContentType.Application.Json.toString()) // header(HttpHeaders.Authorization, "Basic $encodedCredentials") // } // // val responseBody = response.bodyAsText() // println(responseBody) // client.close() // } ``` ```powershell # PowerShell example # $bookId = "your_book_id" # $url = "https://demo.komga.org/api/v1/books/$bookId/progression" # $username = "username" # $password = "password" # $credentials = "{0}:{1}" -f $username, $password # $encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($credentials)) # # $headers = @{ # "Accept" = "application/json" # "Authorization" = "Basic $encodedCredentials" # } # # Invoke-RestMethod -Uri $url -Headers $headers -Method Get ``` ```swift // Swift example using URLSession // import Foundation // // func getBookProgression(bookId: String, completion: @escaping (Result) -> Void) { // guard let url = URL(string: "https://demo.komga.org/api/v1/books/(bookId)/progression") else { // completion(.failure(NSError(domain: "APIError", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"]))) // return // } // // let username = "username" // let password = "password" // let loginString = String(format: "%@:%@", username, password) // guard let loginData = loginString.data(using: String.Encoding.utf8) else { // completion(.failure(NSError(domain: "APIError", code: -2, userInfo: [NSLocalizedDescriptionKey: "Failed to encode credentials"]))) // return // } // let base64Credentials = loginData.base64EncodedString() // // var request = URLRequest(url: url) // request.setValue("application/json", forHTTPHeaderField: "Accept") // request.setValue("Basic \(base64Credentials)", forHTTPHeaderField: "Authorization") // request.httpMethod = "GET" // // URLSession.shared.dataTask(with: request) { data, response, error in // if let error = error { // completion(.failure(error)) // return // } // guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else { // completion(.failure(NSError(domain: "APIError", code: -3, userInfo: [NSLocalizedDescriptionKey: "Bad response"]))) // return // } // guard let data = data else { // completion(.failure(NSError(domain: "APIError", code: -4, userInfo: [NSLocalizedDescriptionKey: "No data"]))) // return // } // completion(.success(data)) // }.resume() // } ``` ```rust // Rust example using the 'reqwest' crate // use reqwest::header::{ACCEPT, AUTHORIZATION}; // use reqwest::Client; // use std::error::Error; // // #[tokio::main] // async fn main() -> Result<(), Box> { // let book_id = "your_book_id"; // let url = format!("https://demo.komga.org/api/v1/books/{}/progression", book_id); // let username = "username"; // let password = "password"; // let credentials = format!("{}:{}", username, password); // let encoded_credentials = base64::encode(credentials); // // let client = Client::new(); // let response = client.get(&url) // .header(ACCEPT, "application/json") // .header(AUTHORIZATION, format!("Basic {}", encoded_credentials)) // .send() // .await?; // // let body = response.text().await?; // println!("{}", body); // // Ok(()) // } ``` -------------------------------- ### List Libraries - Swift Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using Swift's URLSession. This code demonstrates making an authenticated GET request to the Komga API. ```swift import Foundation func listKomgaLibraries() { guard let url = URL(string: "https://demo.komga.org/api/v1/libraries") else { return } let username = "your_username" // Replace with your username let password = "your_password" // Replace with your password let credentials = "(username):(password)".data(using: .utf8)!.base64EncodedString() var request = URLRequest(url: url) request.setValue("application/json", forHTTPHeaderField: "Accept") request.setValue("Basic \(credentials)", forHTTPHeaderField: "Authorization") request.httpMethod = "GET" URLSession.shared.dataTask(with: request) { data, response, error in guard let data = data, error == nil else { print(error?.localizedDescription ?? "Unknown error") return } if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode == 200 { do { let json = try JSONSerialization.jsonObject(with: data, options: []) print(json) } catch { print("Failed to parse JSON: \(error)") } } else { print("HTTP Status code: \((response as? HTTPURLResponse)?.statusCode ?? -1)") print(String(data: data, encoding: .utf8)!) } }.resume() } listKomgaLibraries() ``` -------------------------------- ### Get Library Details - Example Request (PowerShell) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using PowerShell. It demonstrates setting the necessary headers for the request. ```powershell $uri = 'https://demo.komga.org/api/v1/libraries/:libraryId' $headers = @{ 'Accept' = 'application/json' 'Authorization' = 'Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' } Invoke-RestMethod -Uri $uri -Method Get -Headers $headers ``` -------------------------------- ### Get Library Details - Example Request (Node.js) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using Node.js. It demonstrates setting request headers for API interaction. ```javascript const https = require('https'); const options = { hostname: 'demo.komga.org', port: 443, path: '/api/v1/libraries/:libraryId', method: 'GET', headers: { 'Accept': 'application/json', 'Authorization': 'Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' } }; const req = https.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log(JSON.parse(data)); }); }); req.on('error', (error) => { console.error(error); }); req.end(); ``` -------------------------------- ### List Libraries - Kotlin Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using Kotlin with OkHttp. This code snippet demonstrates making an authenticated GET request to the Komga API. ```kotlin import okhttp3.OkHttpClient import okhttp3.Request import java.util.Base64 fun main() { val url = "https://demo.komga.org/api/v1/libraries" val username = "your_username" // Replace with your username val password = "your_password" // Replace with your password val credentials = Base64.getEncoder().encodeToString("$username:$password".toByteArray()) val client = OkHttpClient() val request = Request.Builder() .url(url) .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic $credentials") .build() client.newCall(request).execute().use { response -> if (response.isSuccessful) { println(response.body?.string()) } else { println("Error: ${response.code} - ${response.body?.string()}") } } } ``` -------------------------------- ### List Libraries - Java Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using Java's OkHttp client. This code demonstrates making an authenticated GET request to the Komga API. ```java import okhttp3.*; import java.io.IOException; public class KomgaApi { public static void main(String[] args) throws IOException { String url = "https://demo.komga.org/api/v1/libraries"; String username = "your_username"; // Replace with your username String password = "your_password"; // Replace with your password String credentials = java.util.Base64.getEncoder().encodeToString((username + ":" + password).getBytes()); OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url(url) .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic " + credentials) .build(); try (Response response = client.newCall(request).execute()) { if (response.isSuccessful()) { System.out.println(response.body().string()); } else { System.out.println("Error: " + response.code() + " - " + response.body().string()); } } } } ``` -------------------------------- ### List Libraries - PowerShell Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using PowerShell. This script uses Invoke-RestMethod to send an authenticated GET request to the Komga API. ```powershell $url = "https://demo.komga.org/api/v1/libraries" $username = "your_username" # Replace with your username $password = "your_password" # Replace with your password $credential = "$username:$password" $encodedCredential = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credential)) $headers = @{ "Accept" = "application/json" "Authorization" = "Basic $encodedCredential" } Invoke-RestMethod -Uri $url -Method Get -Headers $headers ``` -------------------------------- ### List Series - Basic Authentication Examples Source: https://komga.org/docs/openapi/get-series-updated Demonstrates how to list updated series using Basic Authentication across various programming languages. Each snippet shows how to make the GET request with appropriate headers for authentication and content type. ```python import requests url = "https://demo.komga.org/api/v1/series/updated" headers = { 'Accept': 'application/json', 'Authorization': 'Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ=' } response = requests.get(url, headers=headers) print(response.json()) ``` ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class KomgaApiClient { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://demo.komga.org/api/v1/series/updated")) .header("Accept", "application/json") .header("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ=") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } ``` ```powershell $url = "https://demo.komga.org/api/v1/series/updated" $headers = @{ "Accept" = "application/json" "Authorization" = "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ=" } Invoke-RestMethod -Uri $url -Headers $headers -Method Get ``` -------------------------------- ### Get Readlist Thumbnail using Node.js Source: https://komga.org/docs/openapi/get-read-list-thumbnail This Node.js example retrieves a readlist's thumbnail. It uses the `axios` library for HTTP requests and basic authentication. You'll need to install axios (`npm install axios`). The response content is saved as a JPEG file. ```javascript const axios = require('axios'); const fs = require('fs'); const baseUrl = 'https://demo.komga.org/api/v1/readlists/'; const readlistId = 'your_readlist_id'; const username = 'your_username'; const password = 'your_password'; axios.get(`${baseUrl}${readlistId}/thumbnail`, { responseType: 'stream', auth: { username: username, password: password } }) .then(response => { const writer = fs.createWriteStream(`readlist_${readlistId}_thumbnail.jpg`); response.data.pipe(writer); writer.on('finish', () => console.log('Thumbnail downloaded successfully.')); writer.on('error', (err) => console.error('Error writing file:', err)); }) .catch(error => { console.error('Error downloading thumbnail:', error.response ? error.response.data : error.message); }); ``` -------------------------------- ### Get Previous Book in Series - Python Example Source: https://komga.org/docs/openapi/get-book-sibling-previous Python code snippet to fetch the previous book in a series using the Komga API. This example utilizes the `requests` library and demonstrates setting up basic authentication and headers. Ensure you have the `requests` library installed. ```python # Python example would go here if provided in the input text. ``` -------------------------------- ### Get Library Details - Example Request (Rust) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using Rust. It uses the 'reqwest' crate for HTTP requests. ```rust use reqwest::Error; #[tokio::main] async fn main() -> Result<(), Error> { let client = reqwest::Client::new(); let response = client.get("https://demo.komga.org/api/v1/libraries/:libraryId") .header("Accept", "application/json") .header("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+") .send() .await?; let body = response.text().await?; println!("{}", body); Ok(()) } ``` -------------------------------- ### Komga API Basic Authentication Example (Node.js) Source: https://komga.org/docs/openapi/get-series-new This example illustrates how to perform Basic HTTP Authentication with the Komga API using Node.js. It constructs the Authorization header manually and sends a request using the `axios` library. ```javascript const axios = require('axios'); const username = 'your_username'; const password = 'your_password'; const url = 'https://demo.komga.org/api/v1/series/new'; const authHeader = 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64'); axios.get(url, { headers: { 'Accept': 'application/json', 'Authorization': authHeader } }) .then(response => { console.log(response.status); console.log(response.data); }) .catch(error => { console.error('Error:', error); }); ``` -------------------------------- ### Get Library Details - Example Request (Swift) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using Swift. It utilizes URLSession for handling network requests. ```swift import Foundation let url = URL(string: "https://demo.komga.org/api/v1/libraries/:libraryId")! var request = URLRequest(url: url) request.httpMethod = "GET" request.setValue("application/json", forHTTPHeaderField: "Accept") request.setValue("Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+", forHTTPHeaderField: "Authorization") let task = URLSession.shared.dataTask(with: request) { data, response, error in if let data = data { let json = try? JSONSerialization.jsonObject(with: data, options: []) print(json) } } task.resume() ``` -------------------------------- ### Launch Komga JAR with Custom Settings Source: https://komga.org/docs/installation/configuration Example of launching the Komga JAR with custom server context path and port. This demonstrates how to override default configurations using command-line arguments. ```bash java -jar komga.jar --server.servlet.context-path="/komga" --server.port=8443 ``` -------------------------------- ### Get Library Details - Example Request (cURL) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using cURL. It demonstrates the inclusion of the Authorization header for authentication. ```bash curl -L 'https://demo.komga.org/api/v1/libraries/:libraryId' \ -H 'Accept: application/json' \ -H 'Authorization: Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' ``` -------------------------------- ### Komga API Basic Authentication Example (Kotlin) Source: https://komga.org/docs/openapi/get-series-new This Kotlin example shows how to implement Basic HTTP Authentication for Komga API requests. It uses the OkHttp client library to construct and send the authenticated HTTP GET request. ```kotlin import okhttp3.OkHttpClient import okhttp3.Request import java.util.Base64 fun main() { val username = "your_username" val password = "your_password" val url = "https://demo.komga.org/api/v1/series/new" val client = OkHttpClient() val credentials = "$username:$password" val basicAuth = "Basic " + Base64.getEncoder().encodeToString(credentials.toByteArray()) val request = Request.Builder() .url(url) .header("Accept", "application/json") .header("Authorization", basicAuth) .build() client.newCall(request).execute().use { response -> println("Status Code: ${response.code}") println("Response Body: ${response.body?.string()}") } } ``` -------------------------------- ### Get Readlist Thumbnail using Python Source: https://komga.org/docs/openapi/get-read-list-thumbnail This Python snippet shows how to get a readlist's thumbnail. It uses the `requests` library to make an authenticated GET request to the Komga API. Ensure you have the `requests` library installed (`pip install requests`). ```python import requests base_url = "https://demo.komga.org/api/v1/readlists/" readlist_id = "your_readlist_id" username = "your_username" password = "your_password" response = requests.get( f"{base_url}{readlist_id}/thumbnail", auth=(username, password) ) if response.status_code == 200: with open(f"readlist_{readlist_id}_thumbnail.jpg", "wb") as f: f.write(response.content) print("Thumbnail downloaded successfully.") else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Get Library Details - Example Request (Kotlin) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using Kotlin. It utilizes the Ktor client for making HTTP requests. ```kotlin import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.client.* import io.ktor.http.* suspend fun getLibraryDetails() { val client = HttpClient() val response: HttpResponse = client.get("https://demo.komga.org/api/v1/libraries/:libraryId") { headers { append(HttpHeaders.Accept, "application/json") append(HttpHeaders.Authorization, "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+") } } println(response.bodyAsText()) client.close() } ``` -------------------------------- ### Komga API Basic Authentication Example (Rust) Source: https://komga.org/docs/openapi/get-series-new This Rust code example demonstrates how to make Basic HTTP authenticated requests to the Komga API using the `reqwest` crate. It constructs the necessary headers and sends an HTTP GET request. ```rust use reqwest::blocking::Client; use reqwest::header::{ACCEPT, AUTHORIZATION, HeaderValue}; use std::error::Error; fn main() -> Result<(), Box> { let username = "your_username"; let password = "your_password"; let url = "https://demo.komga.org/api/v1/series/new"; let credentials = format!("{}:{}", username, password); let encoded_credentials = base64::encode(&credentials); let auth_header_value = format!("Basic {}", encoded_credentials); let client = Client::new(); let response = client.get(url) .header(ACCEPT, HeaderValue::from_static("application/json")) .header(AUTHORIZATION, HeaderValue::from_str(&auth_header_value)?) .send()?; println!("Status Code: {}", response.status()); let body = response.text()?; println!("Response Body: {}", body); Ok(()) } ``` -------------------------------- ### Komga API Example Documentation Source: https://komga.org/docs/openapi/get-book-web-pub-manifest-pdf Illustrates an example of a Komga API interaction, often used for testing or demonstrating functionality. The 'auto' tag suggests this might be an automatically generated example. ```text Example (auto) ``` -------------------------------- ### Get Previous Book in Series - PowerShell Example Source: https://komga.org/docs/openapi/get-book-sibling-previous PowerShell script to call the 'Get Previous Book in Series' API. This snippet demonstrates how to send an authenticated GET request and handle the response. The example includes setting headers for authentication and content type. ```powershell # PowerShell example would go here if provided in the input text. ``` -------------------------------- ### List Libraries - Node.js Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using Node.js. This code snippet shows how to make an authenticated GET request to the Komga API using the 'axios' library. ```javascript const axios = require('axios'); const url = 'https://demo.komga.org/api/v1/libraries'; const username = 'your_username'; // Replace with your username const password = 'your_password'; // Replace with your password axios.get(url, { headers: { 'Accept': 'application/json', 'Authorization': 'Basic ' + Buffer.from(`${username}:${password}`).toString('base64') } }) .then(response => { console.log(response.data); }) .catch(error => { console.error(`Error: ${error.response.status} - ${error.response.data}`); }); ``` -------------------------------- ### List Libraries - Rust Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using Rust's reqwest library. This code snippet demonstrates making an authenticated GET request to the Komga API. ```rust use reqwest::blocking::Client; use reqwest::header::{ACCEPT, AUTHORIZATION, BASIC}; use std::error::Error; fn main() -> Result<(), Box> { let url = "https://demo.komga.org/api/v1/libraries"; let username = "your_username"; // Replace with your username let password = "your_password"; // Replace with your password let client = Client::new(); let response = client.get(url) .header(ACCEPT, "application/json") .basic_auth(username, Some(password)) .send()?; if response.status().is_success() { let body = response.text()?; println!("{}", body); } else { eprintln!("Error: {}", response.status()); eprintln!("{}", response.text()?); } Ok(()) } ``` -------------------------------- ### Get Library Details - Example Request (Java) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using Java's HttpClient. It shows how to configure the request with appropriate headers. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class KomgaApi { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://demo.komga.org/api/v1/libraries/:libraryId")) .header("Accept", "application/json") .header("Authorization", "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+") .build(); HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } } ``` -------------------------------- ### Get Book Details - cURL Example Source: https://komga.org/docs/openapi/get-book-by-id Example of how to fetch book details using cURL. This command makes a GET request to the Komga API, specifying the book ID in the URL and including basic authentication headers. ```bash curl -L 'https://demo.komga.org/api/v1/books/:bookId' \ -H 'Accept: application/json' \ -H 'Authorization: Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' ``` -------------------------------- ### Start Komga Podman Container Source: https://komga.org/docs/installation/thirdparty/podman This snippet shows how to start a previously created Komga container using Podman. It assumes a container named 'komga' already exists. This is a straightforward command to bring the container online. ```bash podman start komga ``` -------------------------------- ### Get Previous Book in Series - Rust Example Source: https://komga.org/docs/openapi/get-book-sibling-previous Rust code snippet for calling the 'Get Previous Book in Series' API. This example shows how to construct and send an authenticated HTTP GET request in Rust. Ensure you have a suitable HTTP client library added to your project. ```rust // Rust example would go here if provided in the input text. ``` -------------------------------- ### Komga API Request with Basic Authentication (PowerShell) Source: https://komga.org/docs/openapi/get-books-by-series-id An example of executing a GET request to the Komga API's series endpoint using PowerShell. It demonstrates how to construct the request with appropriate headers for basic authentication. ```powershell # PowerShell example would go here, using Invoke-RestMethod or Invoke-WebRequest ``` -------------------------------- ### Get Previous Book in Series - Java Example Source: https://komga.org/docs/openapi/get-book-sibling-previous Java code snippet for interacting with the 'Get Previous Book in Series' API. This example outlines the necessary steps to perform an authenticated HTTP GET request. Ensure appropriate Java HTTP client libraries are available. ```java // Java example would go here if provided in the input text. ``` -------------------------------- ### List Readlists - Swift Example Source: https://komga.org/docs/openapi/get-read-lists This Swift example shows how to fetch readlists using `URLSession` and basic authentication. It constructs the URL request, sets the necessary headers, and handles the response asynchronously, printing the data or any errors encountered. ```swift import Foundation func getReadlists() { guard let url = URL(string: "https://demo.komga.org/api/v1/readlists") else { return } let username = "your_username" let password = "your_password" let credentials = "(username):(password)".data(using: .utf8)!.base64EncodedString() var request = URLRequest(url: url) request.setValue("application/json", forHTTPHeaderField: "Accept") request.setValue("Basic (credentials)", forHTTPHeaderField: "Authorization") URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: (error.localizedDescription)") return } guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else { print("Invalid response") if let data = data, let responseString = String(data: data, encoding: .utf8) { print("Response: (responseString)") } return } if let data = data, let dataString = String(data: data, encoding: .utf8) { print("Readlists: (dataString)") } }.resume() } // Call the function to execute // getReadlists() ``` -------------------------------- ### Get Library Details - Example Request (Python) Source: https://komga.org/docs/openapi/get-library-by-id An example of how to make a GET request to the Komga API to retrieve library details using Python's requests library. It shows how to set headers for authentication and content type. ```python import requests url = "https://demo.komga.org/api/v1/libraries/:libraryId" headers = { "Accept": "application/json", "Authorization": "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+" } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code}") ``` -------------------------------- ### Get Book Details - Node.js Example Source: https://komga.org/docs/openapi/get-book-by-id Node.js code snippet to fetch book details using the 'axios' library. This example shows how to make a GET request with authentication and accept headers, and process the returned JSON data. ```javascript // Placeholder for Node.js code snippet ``` -------------------------------- ### Komga API Basic Authentication Example (PowerShell) Source: https://komga.org/docs/openapi/get-series-new This PowerShell script demonstrates how to make authenticated requests to the Komga API using Basic HTTP Authentication. It constructs the Authorization header and uses `Invoke-RestMethod` to send the request. ```powershell $username = "your_username" $password = "your_password" $url = "https://demo.komga.org/api/v1/series/new" $credentials = "$username:$password" $encodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($credentials)) $authHeader = "Basic $encodedCredentials" $headers = @{ "Accept" = "application/json" "Authorization" = $authHeader } $response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get Write-Host "Response: $($response | ConvertTo-Json -Depth 10)" ``` -------------------------------- ### List Libraries - cURL Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using cURL. This command sends a GET request to the Komga API's library endpoint, specifying JSON as the accepted response format and including Basic Authentication credentials. ```shell curl -L 'https://demo.komga.org/api/v1/libraries' \ -H 'Accept: application/json' \ -H 'Authorization: Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ>' ``` -------------------------------- ### Get Book Page Image (CURL Example) Source: https://komga.org/docs/openapi/get-book-page-by-number Example using cURL to fetch a book page image. Demonstrates how to include the authorization header for authentication. ```curl curl -L 'https://demo.komga.org/api/v1/books/:bookId/pages/:pageNumber' \ -H 'Authorization: Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' ``` -------------------------------- ### List Libraries - Python Example Source: https://komga.org/docs/openapi/get-libraries Example of how to list all libraries using Python's requests library. This code snippet demonstrates making a GET request with authentication to the Komga API. ```python import requests url = "https://demo.komga.org/api/v1/libraries" headers = { "Accept": "application/json", "Authorization": "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ>" } response = requests.get(url, headers=headers) if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code} - {response.text}") ``` -------------------------------- ### List Age Ratings GET Request (Python) Source: https://komga.org/docs/openapi/get-age-ratings Provides a Python example for fetching age ratings from the Komga API. It utilizes the `requests` library and demonstrates how to include authentication and headers. This snippet assumes the user has the `requests` library installed. ```python # Example for Python would go here, likely using the 'requests' library. # import requests # url = "https://demo.komga.org/api/v1/age-ratings" # headers = { # "Accept": "application/json", # "Authorization": "Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+" # } # response = requests.get(url, headers=headers) # print(response.json()) ``` -------------------------------- ### Get Previous Book in Series - cURL Example Source: https://komga.org/docs/openapi/get-book-sibling-previous Example using cURL to call the 'Get Previous Book in Series' API. This demonstrates how to include the necessary headers for authentication and content type acceptance. Replace placeholder credentials with actual ones. ```curl curl -L 'https://demo.komga.org/api/v1/books/:bookId/previous' \ -H 'Accept: application/json' \ -H 'Authorization: Basic PHVzZXJuYW1lPjo8cGFzc3dvcmQ+' ``` -------------------------------- ### Komga API Basic Authentication Example (Python) Source: https://komga.org/docs/openapi/get-series-new This example shows how to authenticate with the Komga API using Basic HTTP Authentication in Python. It utilizes the `requests` library to send a GET request with the necessary Authorization header. ```python import requests from requests.auth import HTTPBasicAuth username = "your_username" password = "your_password" url = "https://demo.komga.org/api/v1/series/new" response = requests.get(url, auth=HTTPBasicAuth(username, password)) print(response.status_code) print(response.json()) ``` -------------------------------- ### List Book Pages API Request (Python) Source: https://komga.org/docs/openapi/get-book-pages Example Python script to list pages of a book using the Komga API. This snippet demonstrates making an HTTP GET request and handling the JSON response. Ensure you have the 'requests' library installed. ```python # Placeholder for Python code example # This would typically involve the 'requests' library # import requests # book_id = "your_book_id" # url = f"https://demo.komga.org/api/v1/books/{book_id}/pages" # headers = { # "Accept": "application/json", # "Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS" # } # response = requests.get(url, headers=headers) # if response.status_code == 200: # print(response.json()) # else: # print(f"Error: {response.status_code}") ``` -------------------------------- ### Retrieve Server Info using Kotlin Source: https://komga.org/docs/openapi/get-actuator-info Example using Kotlin with the `HttpClient` to fetch server information. This code shows how to make the HTTP request and process the response. ```kotlin import java.net.URI import java.net.http.HttpClient import java.net.http.HttpRequest import java.net.http.HttpResponse import java.util.Base64 fun main() { val client = HttpClient.newHttpClient() val credentials = "username:password" val encodedCredentials = Base64.getEncoder().encodeToString(credentials.toByteArray()) val request = HttpRequest.newBuilder() .uri(URI.create("https://demo.komga.org/actuator/info")) .header("Accept", "application/json") .header("Authorization", "Basic $encodedCredentials") .build() val response = client.send(request, HttpResponse.BodyHandlers.ofString()) println("Status Code: ${response.statusCode()}") println("Response Body: ${response.body()}") } ``` -------------------------------- ### Komga API Basic Authentication Example (Java) Source: https://komga.org/docs/openapi/get-series-new This Java code snippet demonstrates how to use Basic HTTP Authentication to interact with the Komga API. It employs the Apache HttpClient library to construct and send the authenticated request. ```java import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.util.Base64; public class KomgaApiAuth { public static void main(String[] args) throws Exception { String username = "your_username"; String password = "your_password"; String url = "https://demo.komga.org/api/v1/series/new"; CloseableHttpClient httpClient = HttpClients.createDefault(); HttpGet request = new HttpGet(url); String auth = username + ":" + password; byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes()); String authHeader = "Basic " + new String(encodedAuth); request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); request.setHeader(HttpHeaders.ACCEPT, "application/json"); try (CloseableHttpResponse response = httpClient.execute(request)) { HttpEntity entity = response.getEntity(); if (entity != null) { System.out.println("Status Code: " + response.getStatusLine().getStatusCode()); System.out.println("Response Body: " + EntityUtils.toString(entity)); } } httpClient.close(); } } ``` -------------------------------- ### Get Previous Book in Series - Kotlin Example Source: https://komga.org/docs/openapi/get-book-sibling-previous Kotlin code snippet for making a request to the 'Get Previous Book in Series' endpoint. This example focuses on how to construct the HTTP request with authentication and expected headers in Kotlin. Adjust for your specific HTTP client. ```kotlin // Kotlin example would go here if provided in the input text. ```