ApiClientTemplate 1.0.0
dotnet new install ApiClientTemplate::1.0.0
ApiClientTemplate
ApiClientTemplate is a RESTful APIs client in C# applications.
If you like this project please give a star and a cup of coffee =)
Installation
To install ApiClientTemplate, you can use the NuGet package manager in Visual Studio. Simply search for "ApiClientTemplate" and click "Install".
Alternatively, you can install ApiClientTemplate using the command line:
Install-Package ApiClientTemplate
Getting Started
Firstly obtain valid ApiClientTemplate API key if it is required.
Without using dependency injection:
var apiClient = new ApiClientTemplateClient(new ApiClientTemplateOptions()
{
ApiKey = Environment.GetEnvironmentVariable("MY_API_KEY")
});
Using dependency injection:
In your secrets.json or other settings.json
"ApiClientTemplateOptions": {
//"ApiKey": "Your api key goes here",
//"ApiBaseAddress": "Your api base address goes here"
},
Program.cs
serviceCollection.AddApiClientTemplateClient();
or using Environment Variable
serviceCollection.AddApiClientTemplateClient(settings => { settings.ApiKey = Environment.GetEnvironmentVariable("MY_API_KEY"); });
NOTE: do NOT put your API key directly to your source code.
After injecting your service you will be able to get it from service provider
var apiClient = serviceProvider.GetRequiredService<ApiClientTemplateClient>();
or injecting in the constructor of your class
public class MyService
{
private readonly ApiClientTemplateClient _apiClient;
public NewsService(ApiClientTemplateClient apiClient)
{
_apiClient = apiClient;
}
}
Logging and Exception handling
For diagnostic there are 'DelegatingHandler'-s such as 'LoggingHandler' and 'ExceptionHandler'. You can always extend them
-
net6.0
- No dependencies.
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.0 | 890 | 3/14/2023 |