Kippt.NET


KipptClient

KipptClient is the base class that provides rights for sending and receiving data by affecting the username and the token to every request's headers made to the server. To execute any api request, we need to instanciate this class.

var client = new KipptClient(username, token);
Parameter Description
username Your kippt username
token Token is used to access protected resources using a HTTP basic authentications. Token can be found here (Authentication required).

if you're using the library for creating third party application that might need the user authentication you can obtain a KipptAccount instance and a ready KipptClient instance by just using the combination username / password.

var client = new KipptClient(); // Creates an empty client
var account = KipptAccount.Authenticate(client, username, password);

The Authenticate method uses the username and the password to login into the user account returning a KipptAccount instance with the informations of the logged in user as well as filling the KipptClient instance with the required informations (username & token).

Once done, the KipptClient instance is ready to execute any other api request.

My Account

Returns a KipptAccount instance describing the logged in user.

var me = KipptAccount.Me(client);
Console.WriteLine(me.UserName); // Prints the username

User Informations

The GetUser method returns a KipptAccount instance containing informations about a user.

var account = KipptAccount.GetUser(client, 12345);
Console.WriteLine(account.UserName); // Prints the username

KipptAccount Class

Property Type Description
Id Int Your kippt identifier
UserName String Username
ApiToken String Token is used to access protected resources using a HTTP basic authentications. Token can be found here (Authentication required).
Avatar String Avatar url (Gravatar)
Lists String Lists relative uri
AppUrl String Profile relative uri
ResourceUri String Api relative uri
Method Return Description
Me KipptAccount Returns informations about the logged in user.
GetUser KipptAccount Returns informations about a user.
Authenticate KipptAccount Authentication Process.

GetLists

GetLists returns a KipptListCollection object. The returned object contains :

  • Meta : Contains pagination information ( Limit, Offset, TotalCount ).
  • Lists : List of KipptList objects.

var collection = KipptList.GetLists();
// Loop over your lists
foreach (var list in collection.Lists)
{
	Console.WriteLine(list.Title);
}

GetList

GetList returns a KipptList object by its id.

var list = KipptList.GetList(12345);
If not found, a KipptException will be raised.

Pagination

The GetLists method returns 20 results by defaults giving the user the ability of pagination and reducing the amount of data sent by the server. To override the default value of returned results :

// Get 50 lists
var collection = KipptList.GetLists(50);

For more flexibility, we can add an offset to get a specific range (a page) of lists :

// KipptList.GetLists(limit, offset);
var collection = KipptList.GetLists(10, 5);

GetClips

GetClips returns a KipptClipCollection object. The returned object contains :

  • Meta : Contains pagination information ( Limit, Offset, TotalCount ).
  • Clips : List of KipptClip objects.

var collection = KipptClip.GetClips();
// Loop over your clips
foreach (var clip in collection.Clips)
{
	Console.WriteLine(clip.Title);
}

To get the clips associated to a specific list :

// KipptClip.GetClips(listId)
var collection = KipptClip.GetClips(12345);

If not found, a KipptException will be raised.

GetClip

The GetClips method returns a KipptClip object by its id.

var clip = KipptClip.GetClip(12345);

If not found, a KipptException will be raised.

Pagination

The same concept of pagination in lists is applied in clips for the GetClips(), GetClips(listId) and Search(query) methods.

// Get 50 clips
var collection = KipptClip.GetClips(50);
// KipptClip.GetClips(limit, offset);
var pageOfClips = KipptClip.GetClips(10, 5);
// KipptClip.GetClips(listId, limit)
var listedClips = KipptClip.GetClips(123, 50);
// KipptClip.GetClips(listId, limit, offset)
var pageOfListedClips = KipptClip.GetClips(123, 10, 5);
// KipptClip.Search(query, limit)
var searchResults = KipptClip.Search("Kippt.NET", 50);
// KipptClip.Search(query, limit, offset)
var pageOfSearchResults = KipptClip.Search("Kippt.NET", 10, 5);

Search

The Search method returns a list of clips matching the input query.

var results = KipptClip.Search("Kippt.NET");

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ligula erat, lobortis eget placerat at, tristique in odio. Mauris libero felis, fermentum eget sollicitudin sit amet, consequat nec ante. Sed ultricies, augue porttitor vestibulum faucibus, lacus dolor varius tellus, sed malesuada elit purus sit amet elit. Proin lobortis quam a turpis scelerisque malesuada. Sed at nisi ligula. Phasellus in sapien sapien, nec condimentum mauris. Phasellus arcu orci, adipiscing convallis sodales at, condimentum dictum sapien. Nunc a porttitor sem. In dictum ipsum ac enim sodales sed convallis lorem pellentesque. Cras sapien tortor, egestas ut laoreet nec, porttitor ut lacus. Sed consequat diam at enim tristique feugiat. Duis in nunc at leo tristique aliquam. Nulla pharetra risus non odio feugiat iaculis.

Kippt.NET can be used asynchronously. All you have to do is add Async suffix.

var client = new KipptClient(username, token);
// Get list of clips
KipptList.GetListsAsync(client);
client.Completed += KipptClient_Completed(object sender, KipptEventArgs e);

void KipptClient_Completed(object sender, KipptEventArgs e)
{
    if (e.Error == null) // Make sure everything is OK
    {
        var lists = (KipptListCollection)e.Result;
    }
}

Or using lambda expressions :

var client = new KipptClient(username, token);
// Get list of clips
KipptList.GetListsAsync(client);
client.Completed += (sender, e) =>
{
    // To Do
}

KipptEventArgs Class

Property Type Description
Result Object Resulted object from a successfull api request. You can cast this object to the wanted type.
RawResponse String Raw response returned by a request (json string usfull for debugging).
Error KipptException Property indicating whether an error has occured when processing a request. If this property is null, everything is good.
HttpStatusCode HttpStatusCode Contains the values of status codes defined for HTTP.