AdventoAPI.CPB 1.0.5

dotnet add package AdventoAPI.CPB --version 1.0.5
                    
NuGet\Install-Package AdventoAPI.CPB -Version 1.0.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AdventoAPI.CPB" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AdventoAPI.CPB" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="AdventoAPI.CPB" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AdventoAPI.CPB --version 1.0.5
                    
#r "nuget: AdventoAPI.CPB, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AdventoAPI.CPB@1.0.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AdventoAPI.CPB&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=AdventoAPI.CPB&version=1.0.5
                    
Install as a Cake Tool

AdventoAPI.CPB

A .NET 10 library for fetching and parsing Bible lessons and devotionals from the CPB (Centro de Pesquisa Bíblica) website.

Overview

AdventoAPI.CPB provides a simple and efficient way to retrieve:

  • Adult Bible Lessons (LicaoAdulto) - Quarterly lesson materials with daily content, audio, and supplementary materials
  • Devotionals (DevocionalBase) - Daily devotional content for different audiences:
    • DevocionalDiario - Daily devotionals
    • DevocionalJovem - Youth devotionals
    • DevocionalMulher - Women's devotionals

The library handles HTML parsing, data extraction, and provides async-friendly APIs with built-in throttling support.

Features

  • 📚 Multiple Content Types: Access Bible lessons and devotionals
  • 🔄 Async/Await Support: Fully asynchronous APIs with CancellationToken support
  • Throttling: Built-in concurrency control using SemaphoreSlim
  • 🔗 Rich Data Models: Type-safe DTOs for all content
  • 🌐 HTML Parsing: Leverages AngleSharp for reliable content extraction
  • 📅 Flexible Filtering: Search devotionals by keywords, week, or date range
  • 🎵 Media Support: Access to audio files and YouTube links

Installation

Add the NuGet package reference to your project:

dotnet add package AdventoAPI.CPB

Or manually add to your .csproj:

<PackageReference Include="AdventoAPI.CPB" Version="1.0.4" />

Quick Start

Bible Lessons (Adult)

using AdventoAPI.CPB.API;

// Create a client instance
var licaoAdulto = new LicaoAdulto();

// Get the current quarterly lessons
var trimestre = await licaoAdulto.GetLicoesAsync();
Console.WriteLine($"Quarter {trimestre.Trimestre} - Year {trimestre.Ano}");

// Get a specific lesson for the week
var licaoSemana = await licaoAdulto.GetLicaoAsync(trimestre.CurrentSemana);

// Get all lessons for the quarter
var todasAsLicoes = await licaoAdulto.GetAllLicoesTrimestreAsync();

// Get all audio lessons with concurrency control (max 3 concurrent requests)
var audios = await licaoAdulto.GetAllLicoesSemanaAudiosTrimestreThrottledAsync(maxConcurrency: 3);

Devotionals

// Create a devotional instance
var devocionalDiario = new DevocionalDiario();

// Get all weekly blocks of devotionals
var semanas = await devocionalDiario.GetDevocionaisAsync();

// Get meditation information
var meditacoes = await devocionalDiario.GetMeditacaoInfoAsync();

// Get a specific day's devotional
var devotionalDia = await devocionalDiario.GetDevocionalDia(new Uri("https://..."));

// Search devotionals by keyword
var resultados = await devocionalDiario.BuscarPalavraChaveDevocionais("fé");

// Search within a specific week
var resultadosSemana = await devocionalDiario.BuscarPalavrasChaveSemana(0, new[] { "amor", "graça" });

// Search by date range
var dataInicio = new DevocionalDayMonth(1, 1);
var dataFim = new DevocionalDayMonth(31, 12);
var resultadosPeriodo = await devocionalDiario.BuscarPalavrasChaveDataRange(dataInicio, dataFim, "esperança");

API Reference

LicaoAdulto

Main API for accessing adult Bible lessons.

Methods
Method Description
GetLicoesAsync() Retrieves the current quarter's lesson list
GetLicaoAsync(Uri/string/LicaoSemanaItem) Fetches a specific week's lesson
GetAllLicoesTrimestreAsync() Gets all lessons for the quarter
GetAllLicoesTrimestreThrottledAsync(int) Gets all lessons with concurrency control
GetLicaoSemanaAudiosAsync() Retrieves audio files for a week
GetAllLicoesSemanaAudiosTrimestreAsync() Gets all audios for the quarter
GetAllLicoesSemanaAudiosTrimestreThrottledAsync(int) Gets audios with throttling
GetLicoesAudiosTrimestreAsync() Retrieves all available audio lessons

DevocionalBase

Abstract base class for devotional content. Inherited by:

  • DevocionalDiario
  • DevocionalJovem
  • DevocionalMulher
Methods
Method Description
GetDevocionaisAsync() Retrieves all weekly devotional blocks
GetMeditacaoInfoAsync() Gets meditation metadata
GetDevocionalDia(Uri) Fetches a specific day's devotional
BuscarPalavraChaveDevocionais(string) Searches devotionals by keyword
BuscarPalavrasChaveDevocionais(IEnumerable<string>) Searches with multiple keywords
BuscarPalavraChaveSemana(int, string) Searches within a specific week
BuscarPalavrasChaveDataRange() Searches within a date range

Data Models

Key DTOs

LicaoSemanaData - A week's complete lesson content

public class LicaoSemanaData
{
    public LicaoSabado? Sabado { get; init; }        // Saturday lesson
    public LicaoDia? Domingo { get; init; }          // Daily lessons (Sunday-Friday)
    public LicaoDia? Segunda { get; init; }
    public LicaoDia? Terca { get; init; }
    public LicaoDia? Quarta { get; init; }
    public LicaoDia? Quinta { get; init; }
    public LicaoDia? Sexta { get; init; }
    public LicaoAuxiliar? Auxiliar { get; init; }    // Supplementary material
    public LicaoInformativo? Informativo { get; set; }
    public LicaoComentario? Comentario { get; init; }
}

DevocionalInfo - A specific devotional entry

public record DevocionalInfo(
    Uri Url,
    string DiadaSemanaNome,
    string DiaMesNome,
    string Title,
    string Content,
    string VersoBiblico
);

Configuration

Custom HTTP Client

Pass your own HttpClient for custom configuration:

var httpClient = new HttpClient(new SocketsHttpHandler
{
    PooledConnectionIdleTimeout = TimeSpan.FromMinutes(2),
    PooledConnectionLifetime = TimeSpan.FromMinutes(15)
});

var licaoAdulto = new LicaoAdulto(httpClient);

Custom Selectors

Customize HTML selectors if the website structure changes:

var customOptions = new LicaoAdultoOptions
{
    Selectors = new LicaoAdultoOptions.SelectorsOptions
    {
        CardsContainer = ".custom-container",
        // ... other selectors
    }
};

var licaoAdulto = new LicaoAdulto(options: customOptions);

Cancellation Token Support

All methods support cancellation tokens for better control over async operations:

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var licoes = await licaoAdulto.GetLicoesAsync(cts.Token);

Error Handling

The library throws standard .NET exceptions:

try
{
    var licao = await licaoAdulto.GetLicaoAsync(new Uri("https://invalid.url"));
}
catch (HttpRequestException ex)
{
    Console.WriteLine($"Network error: {ex.Message}");
}
catch (FormatException ex)
{
    Console.WriteLine($"Parsing error: {ex.Message}");
}

Requirements

  • .NET 10+
  • AngleSharp 1.4.0+ - For HTML parsing

Performance Tips

  1. Reuse HttpClient: Use a single HttpClient instance across your application
  2. Use Throttling: For batch operations, use the throttled methods to avoid overwhelming the server:
   await licaoAdulto.GetAllLicoesTrimestreThrottledAsync(maxConcurrency: 3);
  1. Cache Results: Store frequently accessed data locally

Contributing

Contributions are welcome! Please submit pull requests to the GitHub repository.

License

This project is licensed under the terms specified in LICENSE.md.

Repository

GenAI.CSharp on GitHub

Author

MauryDev

Support

For issues, questions, or suggestions, please visit the GitHub Issues page.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 92 5/24/2026
1.0.4 98 5/22/2026
1.0.3 93 5/21/2026
1.0.2 91 5/21/2026
1.0.1 88 5/20/2026
1.0.0 98 5/19/2026