Cuttly 1.0.4
dotnet add package Cuttly --version 1.0.4
NuGet\Install-Package Cuttly -Version 1.0.4
<PackageReference Include="Cuttly" Version="1.0.4" />
paket add Cuttly --version 1.0.4
#r "nuget: Cuttly, 1.0.4"
// Install Cuttly as a Cake Addin #addin nuget:?package=Cuttly&version=1.0.4 // Install Cuttly as a Cake Tool #tool nuget:?package=Cuttly&version=1.0.4
Cuttly
Cuttly is a c# library for interacting with the Cuttly URL shortening service. It provides an easy-to-use interface for shortening URLs.
If you like this project please give a star and a cup of coffee =)
Installation
To install Cuttly, you can use the NuGet package manager in Visual Studio. Simply search for "Cuttly" and click "Install".
Alternatively, you can install Cuttly using the command line:
Install-Package Cuttly
Getting Started
Firstly obtain valid Cuttly API key from the https://cutt.ly/.
Sample
https://github.com/nurzhanme/CuttSharp
Without using dependency injection:
var CuttlyClient = new CuttlyClient(new CuttlyOptions()
{
ApiKey = Environment.GetEnvironmentVariable("MY_CUTTLY_API_KEY")
});
Using dependency injection:
In your secrets.json or other settings.json
"CuttlyOptions": {
//"ApiKey": "Your api key goes here",
//"ApiBaseAddress": "If api base has been changed (optional. by default: https://cutt.ly/api/api.php)"
},
Program.cs
serviceCollection.AddCuttlyClient();
or using Environment Variable
serviceCollection.AddCuttlyClient(settings => { settings.ApiKey = Environment.GetEnvironmentVariable("MY_CUTTLY_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 CuttlyClient = serviceProvider.GetRequiredService<CuttlyClient>();
or injecting in the constructor of your class
public class MyService
{
private readonly CuttlyClient _CuttlyClient;
public MyService(CuttlyClient CuttlyClient)
{
_CuttlyClient = CuttlyClient;
}
}
Shorten request
//string urlToShorten - may be input parameter
var respone = await CuttlyClient.Shorten(urlToShorten});
if (response.Url.Status == (int)ShortStatus.OK)
{
Console.WriteLine(response);
}
more details about requests https://cutt.ly/api-documentation/regular-api
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.