VineClient - is an unofficial C# library for the 🔗Vine.
PM> Install-Package VineClient
var username = "[email protected]";
var password = "superpass1";
var client = new VineClient();
await client.Authenticate(username, password);
// Gets a list of trending posts.
var resp = await client.Timelines.GetTrending();
if (resp.IsSuccess)
{
ShowVines(resp.Data);
}
client.Dispose();
or even simpler:
using (var client = new VineClient())
{
await client.Authenticate("[email protected]", "superpass1");
var resp = await client.Timelines.GetTrending();
// ...
}
VineClient brings all the advantages of 🔗async programming. Which means there are only a couple of non-async methods and all the rest are async. So you need to await
them.
Calling to the API will always result in Response
object which describes the next data structure:
public class Response<T>
{
// Field returned by the API.
string Code,
// Response data (if any).
T Data,
// Whether the request response is success.
bool IsSuccess,
// Response error (if any).
string Error
}
So, for example, retrieving followers list using GetFollowers
method will result in Response<RecordsList<User>>
, where Data
property would be of type RecordsList<User>
.
There are few options using which you can control how VineClient handles response errors.
// If set to true, then an exception will be thrown in case of response error,
// instead of passing an error object to the Response object.
client.EnsureResponseSuccess = true;
// If set to true, then Response.Raw will be filled with raw JSON response string.
client.IncludeRawResponse = true;
try
{
var followers = await client.Users.GetFollowers(1);
}
catch (VineClientException ex)
{
MessageBox.Show(ex.Message);
}
Some of the methods have its own parameters. Keep in mind, VineClient would throw an exception if not all required parameters filled with data. Optional parameters may be omitted.
In order to call most API methods, your application require user authorization.
Authorization may be performed using the Authorize method passing user credentials.
string username = "yourusername",
password = "yourpassword",
optionalDeviceToken = null;
await client.Authenticate(username, password, optionalDeviceToken);
In case if a user has not Vine account so far then the one may be obtained using the Signup
method.
string username = "yourusername",
password = "yourpassword1",
email = "[email protected]";
await client.Signup(username, password, email);
To close the session you should use the Logout
method.
await client.Logout();
You may want to get full control on what you send through the request. VineClient exposes Request
method to send Vine API requests. All the VineClient API methods are build on top of the one. The signature is next:
async Task<Response<T>> Request<T>(string endpoint, string reqType = "get", MethodParams reqParams = null)
Values:
endpoint
- Method endpoint.reqType
- Request type. Can be eitherPost
,Get
orDelete
.reqParams
- Request parameters.
The next example shows how to get a list of user's followers using the Request method:
var followers = await client.Request<RecordsList<User>>($"users/{1}/followers");
All the method grouped by corresponding categories e.g. Timelines
, Users
, Posts
etc.
Returns a list of featured channels.
Response<RecordsList<Channel>> resp = await client.Channels.GetFeatured();
Adds the post to the Likes list of the current user.
Response<Like> res = await client.Posts.LikePost(postId: 125);
Deletes the post from the Likes list of the current user.
Response<Empty> res = await client.Posts.DeleteLike(postId: 125);
Adds a comment to a post.
Response<Comment> res = await client.Posts.CreateComment(postId: 125, comment: "say what");
Deletes a comment on a post.
Response<Empty> res = await client.Posts.DeleteComment(postId: 125, commentId: 654);
Revines a post.
Response<Repost> res = await client.Posts.Revine(postId: 125);
Unrevines a post.
Response<Empty> res = await client.Posts.Unrevine(postId: 125, revineId: 369);
Reports (submits a complaint about) a post.
Response<Empty> res = await client.Posts.Report(postId: 125);
Adds a new post.
Response<Empty> res = await client.Posts.Post(videoUrl: "video_url", thumbnailUrl: "thumb_url", description: "My first vine");
Deletes a post by given post Id.
Response<Empty> res = await client.Posts.Delete(postId: 125);
Gets a list of trending tags.
Response<RecordsList<Tag>> res = await client.Tags.GetTrending();
Returns a list of tags matching the search criteria.
Response<RecordsList<Tag>> res = await client.Tags.Search(query: "UMF", size: 15, page: 1);
Returns a post by its Id.
Response<RecordsList<Post>> res = await client.Timelines.GetPostById(postId: 125);
Returns a list of posts from user by user Id.
Response<RecordsList<Post>> res = await client.Timelines.GetUserTimeline(userId: 1, size: 15, page: 1);
Returns a list of posts liked by user with specified user Id.
Response<RecordsList<Post>> res = await client.Timelines.GetUserLikes(userId: 1, size: 15, page: 1);
Returns a list of posts by specified tag name.
Response<RecordsList<Post>> res = await client.Timelines.GetTagTimeline(tagName: "UMF", size: 15, page: 1);
Returns a list of posts from the main timeline.
Response<RecordsList<Post>> res = await client.Timelines.GetMainTimeline(size: 15, page: 1);
Returns a list of popular posts.
Response<RecordsList<Post>> res = await client.Timelines.GetPopular(size: 15, page: 1);
Returns a list of trending posts.
Response<RecordsList<Post>> res = await client.Timelines.GetTrending(size: 15, page: 1);
Returns a list of promoted posts.
Response<RecordsList<Post>> res = await client.Timelines.GetPromoted(size: 15, page: 1);
Returns a list of recent posts from a channel.
Response<RecordsList<Post>> res = await client.Timelines.GetChannelPopular(channelId: 258, size: 15, page: 1);
Returns a list of venues posts.
Response<RecordsList<Post>> res = await client.Timelines.GetVenue(venueId: 159, size: 15, page: 1);
Returns a list of similar posts by given post Id.
Response<RecordsList<Post>> res = await client.Timelines.GetSimilar(postId: 125, size: 15, page: 1);
Returns detailed information on the current user.
Response<User> res = await client.Users.GetMe();
Returns detailed information on the user with specified Id.
Response<User> res = await client.Users.GetUserById(userId: 1);
Allows to edit the current account info.
Response<User> res = await client.Users.UpdateProfile(userId: 1, description: "Bohdan Shtepan", location: "US", locale: "EN", privateProfile: false, phoneNumber: null);
Sets explicit profile to true.
Response<Empty> res = await client.Users.SetExplicit(userId: 1);
Sets explicit profile to false.
Response<Empty> res = await client.Users.UnsetExplicit(userId: 1);
Follows the user with given Id.
Response<Empty> res = await client.Users.Follow(userId: 1);
Unfollows the user with given Id.
Response<Empty> res = await client.Users.Unollow(userId: 1);
Blocks the user with given Id.
Response<Empty> res = await client.Users.Block(userId: 1);
Unblocks the user with given Id.
Response<Empty> res = await client.Users.Unblock(userId: 1);
Returns the number of pending notifications.
Response<int> res = await client.Users.GetPendingNotificationsCount(userId: 1);
Returns a list of notifications.
Response<RecordsList<Notification>> res = await client.Users.GetNotifications(userId: 1);
Returns a list of followers of the user with given Id.
Response<RecordsList<User>> res = await client.Users.GetFollowers(userId: 1);
Returns a list of users following by the user with given Id.
Response<RecordsList<User>> res = await client.Users.GetFollowing(userId: 1);
Returns a list of users matching the search criteria.
Response<RecordsList<User>> res = await client.Users.Search(query: "virtyaluk": size: 15, page: 1);
VineClient is compiled for .NET 4.5, as well a Portable Class Library (Profile 111) supporting:
- .NET 4.5
- ASP.NET Core 1.0
- Windows 8
- Windows Phone 8.1
- Xamarin.Android
- Xamarin.iOS
- Xamarin.iOS (Classic)
Based on the Vine API documentation by @neuegram and starlock.
Licensed under the GPLv3 license.
Copyright (c) 2016-2020 Bohdan Shtepan
modern-dev.com  · GitHub @virtyaluk  · Twitter @virtyaluk