FatSecretDotNet 1.0.1
See the version list below for details.
dotnet add package FatSecretDotNet --version 1.0.1
NuGet\Install-Package FatSecretDotNet -Version 1.0.1
<PackageReference Include="FatSecretDotNet" Version="1.0.1" />
paket add FatSecretDotNet --version 1.0.1
#r "nuget: FatSecretDotNet, 1.0.1"
// Install FatSecretDotNet as a Cake Addin
#addin nuget:?package=FatSecretDotNet&version=1.0.1
// Install FatSecretDotNet as a Cake Tool
#tool nuget:?package=FatSecretDotNet&version=1.0.1
FatSecretDotNet
.Net 5.0 Class Library to wrap the Fat Secret public REST API.
Summary
FatSecretDotNet is a .Net 5.0 class library which makes it super simple to access the Fat Secret public REST API.
As of Version 1.0 only the methods granted under the basic scope are implemented. Premier scope methods coming soon.
Getting Started
Prerequisites
To begin using this library in your project first make sure you Register for a FatSecret developer account once registered apply for API access to retrieve your client id and client secret, these will be needed to authenticate.
Installing
FatSecretDotNet is hosted on Nuget and can easily be added to your project by using a Nuget package manager or by using the .net cli.
dotnet add package FatSecretDotNet --version 1.0.0
Usage
The fat secret API is accessed through an instance of the FatSecretClient
class. This classes constructor takes your credentials and will automatically manage authentication for your requests
Creating an instance of the client
The client must be instantiated before a request is made. Each client contains its own AuthManager scheme which means each client will try to get its own access token. For this reason it is recommended to reuse the client when possible, and to register it with your DI container if you are using one.
var credentials = new FatSecretCredentials()
{
ClientId = "Your Client Id",
ClientSecret = "Your Client Secret",
Scope = "your scope" // basic or premier
};
var client = new FatSecretClient(credentials);
Dependency Injection
An extension method is also available to easily add a client to the dot net DI container
services.AddFatSecretClient(credentials);
The client can then be provided to any class as so
private readonly IFatSecretClient _fsClient;
public WeatherForecastController(IFatSecretClient fsClient)
{
_fsClient = fsClient;
}
Note: It is not recommended to ever store your secret in plain text, please use a secure method to store your secret in your application
Using the client
The client has a method for each FatSecret API resource. Each Method takes a Request Object that is used to form the parameters of the request
var foodSearchRequest = new FoodsSearchRequest()
{
SearchExpression = "Apples"
};
var foods = client.FoodsSearch(foodSearchRequest);
See more usage examples here
Technical Details
Client Methods
Each client method is modeled after the Fat Secret REST API Documentation The method names should match the name of the method in the docs.
Request Objects
Each client method takes a unique request object, the request object is modeled after the required and optional parameters as documented in the FatSecret API Docs
Response Objects
Each client method returns a unique response object, the response object is modeled exactly after the example responses in the FatSecret API Docs. Two Additional properties are added to each response object, Successful
and Error
which are populated with information regarding any errors returned by the API.
Product | Versions 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. |
-
net5.0
- Microsoft.Extensions.DependencyInjection (>= 5.0.1)
- Newtonsoft.Json (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.