Skip to content

avestura/KuttSharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KuttSharp

.NET Package for kutt.it url shortener

Installation

NuGet NuGet Downloads

Simply add KuttSharp nuget package to your project

API

First create a new instance of KuttApi then use examples below:

var api = new KuttApi("apiKey");

Submit

var submitedItem = await api.SubmitAsync(
      target: "https://example.com",
      customUrl: "customUrl",
      password: "password",
      reuse: true
    );

// Now you can use properties of created item
if (submitedItem.IsPasswordRequired)
{
    Console.WriteLine(submitedItem.CreatedAt.Year);
}

Delete

await api.DeleteAsync(id: "url_id");

GetUrls

var list = await api.GetUrlsAsync();
Console.WriteLine($"First item visits count: {list[0].Visits}");

GetStats

var stats = await api.GetStatsAsync(id: "url_id");

Console.WriteLine(stats.LastWeek.ClientStats.Referrer[0].Name);

Error handling

var api = new KuttApi("apiKey");

try
{
    var result = await api.SubmitAsync("https://example.com", reuse: true);
}
catch (KuttException kex) when (kex.Message == "No id has been provided.")
{
    // Handle custom kutt exception
}
catch (KuttException)
{
    // Handle all other kutt exceptions
}
catch
{
    // Handle other errors
}

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages