MartineApiNet 1.0.14

dotnet add package MartineApiNet --version 1.0.14                
NuGet\Install-Package MartineApiNet -Version 1.0.14                
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="MartineApiNet" Version="1.0.14" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MartineApiNet --version 1.0.14                
#r "nuget: MartineApiNet, 1.0.14"                
#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.
// Install MartineApiNet as a Cake Addin
#addin nuget:?package=MartineApiNet&version=1.0.14

// Install MartineApiNet as a Cake Tool
#tool nuget:?package=MartineApiNet&version=1.0.14                

MartineApi Wrapper

nuget version downloads

https://api.martinebot.com/v1/docs

Overview

MartineAPI is a an API made by the owner of Martine Bot

If you find any errors/issues or want any features added, create an issue

Getting started

Installing the package

Add the NuGet package MartineApiNet to your project:

dotnet add package MartineApiNet

Simple usage

using System;
using System.Threading.Tasks;
using MartineApiNet;

public class ExampleClass
{
  private readonly MartineApi _martineApi;

  public ExampleClass() 
    => _martineApi = new MartineApi();

  public async Task GetRandomMeme() 
  {
    var image = await _martineApi.RedditApi.GetRandomMeme();

    Console.WriteLine(image.Data.PostUrl);
  }
}

Example using custom HttpClient

You can provide your own HttpClient instance, but you have to set the BaseAddress manually

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using MartineApiNet;

public ExampleClass() 
{
  var httpClient = new HttpClient 
  {
    BaseAddress = new Uri("https://api.martinebot.com/v1")
  };

  _martineApi = new MartineApi(httpClient);
}

Example using dependency injection

Create a ServiceCollection, then add an instance of the MartineApi class to it

using System;
using System.Threading.Tasks;
using MartineApiNet;
using Microsoft.Extensions.DependencyInjection;

public class Startup 
{
  private MartineApi _martineApi;

  private IServiceProvider _serviceProvider;

  public void Init() 
  {
    var services = new ServiceCollection();

    _martineApi = new MartineApi();

    ConfigureServices(services);
    _serviceProvider = services.BuildServiceProvider();
  }

  public async Task RunAsync() 
  {
    var exampleClass = _serviceProvider.GetService<ExampleClass>();

    var image = await exampleClass.GetRandomMeme();

    Console.WriteLine(image.Data.PostUrl);
  }

  private void ConfigureServices(IServiceCollection services) 
  {
    services.AddSingleton(_martineApi);
    services.AddSingleton<ExampleClass>();
  }
}

Using this in a class:

using System.Threading.Tasks;
using MartineApiNet;
using MartineApiNet.Models.Images;

public class ExampleClass 
{
  private readonly MartineApi _martineApi;

  public ExampleClass(MartineApi martineApi) 
    => _martineApi = martineApi;

  public async Task<RedditPost> GetRandomMeme()
    => await _martineApi.GetRandomMeme();
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
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.14 1,457 8/6/2022
1.0.13 384 8/6/2022
1.0.12 502 7/22/2022
1.0.11 369 7/22/2022
1.0.10 368 7/22/2022
1.0.9 383 7/22/2022
1.0.8 381 7/22/2022
1.0.7 383 7/22/2022
1.0.6 1,231 2/20/2022
1.0.5 403 2/20/2022
1.0.4 401 2/20/2022
1.0.3 417 2/20/2022 1.0.3 is deprecated because it has critical bugs.
1.0.2 429 2/18/2022 1.0.2 is deprecated because it has critical bugs.
1.0.1 431 2/18/2022 1.0.1 is deprecated because it has critical bugs.
1.0.0 441 2/18/2022 1.0.0 is deprecated because it has critical bugs.