Kodice.RapidAPI 2.0.6

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Kodice.RapidAPI --version 2.0.6
NuGet\Install-Package Kodice.RapidAPI -Version 2.0.6
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="Kodice.RapidAPI" Version="2.0.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kodice.RapidAPI --version 2.0.6
#r "nuget: Kodice.RapidAPI, 2.0.6"
#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 Kodice.RapidAPI as a Cake Addin
#addin nuget:?package=Kodice.RapidAPI&version=2.0.6

// Install Kodice.RapidAPI as a Cake Tool
#tool nuget:?package=Kodice.RapidAPI&version=2.0.6

Kodice.RapidAPI

Kodice.RapidAPI has been designed to promote the reuse of common and repetitive code required for authorizing and handling RapidAPI calls to your functions.

About the Project

As an example, if we want to use a new API with .NET Core on a Cloud service of our choice and integrate it with RapidAPI, there are certain steps that we must follow.

  • Validate the Secret Key sent via RapidAPI request headers.
  • Check if the Customer performing the request has the right to request a specific feature.

Usually these steps are quite tedious, repetitive, and prone to error.

Getting Started

Installing Kodice.RapidAPI

dotnet add package Kodice.RapidAPI

Project status

Environment Status
Development Build status
Production Build status

Usage

Minimal API

Minimal APIs are a simplified approach for building fast HTTP APIs with ASP.NET Core. You can build fully functioning REST endpoints with minimal code and configuration.

A simple example on how to add the Kodice.RapidAPI to your API project.

using Kodice.RapidAPI.Minimal;
using Kodice.RapidAPI.Models;
using Kodice.RapidAPI.Constsants;

app.MapGet("/minimal/test-01", () =>
{
    return "test-01";
})
    .AddRapidAPI(Plans.FromConfiguration(app.Configuration, "RapidAPI"));

app.MapGet("/minimal/test-02", () =>
{
    return "test-02";
})
    .AddRapidAPI(app.Configuration, "RapidAPI");

var grpA = app
    .MapGroup("/minimal/group-01")
    .AddRapidAPI(Plans.FromConfiguration(app.Configuration, "RapidAPI"));
grpA.MapGet("/test-01", () => { return "group-01"; });

var grpB = app
    .MapGroup("/minimal/group-02")
    .AddRapidAPI(app.Configuration, "RapidAPI");
grpB.MapGet("/test-01", () => { return "group-02"; });

app.Run();
Web API

ASP.NET Core supports creating web APIs using controllers or using minimal APIs. Controllers in a web API are classes that derive from ControllerBase. Controllers are activated and disposed on a per request basis.

A simple example on how to add the Kodice.RapidAPI to your API project. The attribute load settings from the application setting file starting from default JSON section "RapidAPI". You can define your own or multiple sections, and pass the string to the attribute.

using Kodice.RapidAPI.Models;
using Kodice.RapidAPI.WebAPI;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("[controller]")]
[RapidAPIAuthorization()]
public class WeatherForecastController : ControllerBase
{
    [HttpGet(Name = "GetWeatherForecast")]
    public IEnumerable<WeatherForecast> Get()
    { ... }
}

Also possible to add to single Method:

using Kodice.RapidAPI.Models;
using Kodice.RapidAPI.WebAPI;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
    [HttpGet(Name = "GetWeatherForecast")]
    [RapidAPIAuthorization("MY-CUSTOM-SECTION")]
    public IEnumerable<WeatherForecast> Get()
    { ... }
}

JSON Settings

The subscription object can be defined in code for Minimal API, and loaded from configuration for Web Api. The following is an example of application settings that include a Custom Subscription as well. The RapidAPI Secret is a mandatory property.

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "RapidAPI": {
    "Secret": "YOUR-SECRET-HERE",
    "Basic": [
      "feature-01",
      "feature-02"
    ],
    "Pro": [
      "feature-01",
      "feature-02",
      "feature-03",
      "feature-04"
    ],
    "Mega": [
      "feature-01",
      "feature-02",
      "feature-03",
      "feature-04",
      "feature-05",
      "feature-06"

    ],
    "Ultra": [
      "feature-01",
      "feature-02",
      "feature-03",
      "feature-04",
      "feature-05",
      "feature-06",
      "feature-07",
      "feature-08"
    ],
    "Others": {
      "CUSTOM-PRIVATE": [ "extra-feat-01", "extra-feat-02" ]
    }
  }
}

Support and Sponsor

Offer me a coffee Please consider supporting the development with a little help, just a coffee

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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
2.0.6 145 5/12/2023