Cuttly 1.0.4

dotnet add package Cuttly --version 1.0.4
NuGet\Install-Package Cuttly -Version 1.0.4
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="Cuttly" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Cuttly --version 1.0.4
#r "nuget: Cuttly, 1.0.4"
#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 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 =)

"Buy Me A Coffee"

Installation

NuGet Badge

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 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. 
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.4 608 3/9/2023
1.0.3 633 3/28/2022
1.0.0 465 3/24/2022