GuardianClient.NET 0.3.0-alpha

This is a prerelease version of GuardianClient.NET.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package GuardianClient.NET --version 0.3.0-alpha
                    
NuGet\Install-Package GuardianClient.NET -Version 0.3.0-alpha
                    
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="GuardianClient.NET" Version="0.3.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GuardianClient.NET" Version="0.3.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="GuardianClient.NET" />
                    
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 GuardianClient.NET --version 0.3.0-alpha
                    
#r "nuget: GuardianClient.NET, 0.3.0-alpha"
                    
#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 GuardianClient.NET@0.3.0-alpha
                    
#: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=GuardianClient.NET&version=0.3.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=GuardianClient.NET&version=0.3.0-alpha&prerelease
                    
Install as a Cake Tool

GuardianClient.NET


<p align="center"> <img src="./assets/guardian.png" width="150" alt="Guardian knight logo"/> </p>

A modern .NET client library for The Guardian's Content API. Provides strongly-typed models and simple methods for searching Guardian articles, tags, sections, and more.

NuGet Version Build Status

✨ Features

  • 🔍 Content Search - Search Guardian articles with full query support
  • 🏷️ Strongly Typed - Complete C# models for all API responses
  • 🔧 Dependency Injection - Easy setup with services.AddGuardianApiClient()
  • 📦 HttpClientFactory - Proper HttpClient lifecycle management
  • Async/Await - Modern async patterns with cancellation support

🚀 Quick Start

Installation

dotnet add package GuardianClient.NET

Setup with Dependency Injection

// Program.cs or Startup.cs
builder.Services.AddGuardianApiClient("your-api-key");

Usage

public class NewsService
{
    private readonly GuardianApiClient _client;

    public NewsService(GuardianApiClient client)
    {
        _client = client;
    }

    public async Task<ContentSearchResponse?> GetLatestNews()
    {
        return await _client.SearchAsync("politics", pageSize: 10);
    }
}

Manual Setup (without DI)

using var client = new GuardianApiClient("your-api-key");
var results = await client.SearchAsync("climate change", pageSize: 5);

foreach (var article in results.Results)
{
    Console.WriteLine($"{article.WebTitle} - {article.WebPublicationDate}");
}

🔑 Getting an API Key

  1. Visit The Guardian Open Platform
  2. Sign up for a free developer account
  3. Generate your API key

📋 Current Status

✅ Implemented:

  • Content search with basic parameters
  • Strongly-typed response models
  • Dependency injection support
  • HttpClientFactory integration

🔄 In Development:

  • Additional endpoints (tags, sections, editions)
  • Advanced search parameters
  • Deep pagination support

🤝 Contributing

This is an early-stage project. Issues and pull requests are welcome!

📄 License

MIT License - see LICENSE for details.


This is an unofficial library and is not affiliated with The Guardian.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
0.5.0-alpha 163 8/13/2025
0.4.0-alpha 153 8/12/2025
0.3.0-alpha 159 8/11/2025
0.2.1-alpha 149 8/10/2025
0.2.0-alpha 150 8/10/2025
0.1.0-alpha 157 8/10/2025