Software Architect / Microsoft MVP (AI) and Pluralsight Author

C#, Social Opinion API, Twitter API v2

How To Fetch a List of Muted Accounts on Twitter

In an earlier blog post support was implemented for the Twitter API V2 Mute and Unmute enpoint. A new enpoint is now available.

This is available in my NuGet package and on GitHub. It’s written in C#.

This endpoint lets you programmatically fetch a list of users who are muted by the specified user ID.

You could use this method to create logic that determines if you want to interact with certain types of people on Twitter.

Using The Get Mutes Enpoint with the Social Opinion API

You can use this end point with a few lines of code. The first thing you need to do is create an instance of the Tweet Service and pass in your OAuth tokens:

BlocksService tweetsService = new BlocksService(oAuthInfo);

You are now free to call GetMutes method.

Get Mutes

This method returns a list of users who are muted by the specified id.

List<MutesModel> mutes = muteService.GetMutes("958676983", 100);

The first parameter is the user id.

The second parameter is the maximum number of results to return.

Example Data

The method will return a collection of Datum objects:

public class Datum
{
    public DateTime created_at { get; set; }
    public string name { get; set; }
    public bool verified { get; set; }
    public string username { get; set; }
    public string pinned_tweet_id { get; set; }
    public bool @protected { get; set; }
    public PublicMetrics public_metrics { get; set; }
    public string id { get; set; }
    public Entities entities { get; set; }
    public string location { get; set; }
    public string description { get; set; }
    public string profile_image_url { get; set; }
    public string url { get; set; }
}

Digging into the Entities objects gets you more insights into the accounts that are muted:

public class Entities
{
     public Url url { get; set; }
     public Description description { get; set; }
}

public class Description
{
     public List<Mention> mentions { get; set; }
     public List<Url> urls { get; set; }
     public List<Hashtag> hashtags { get; set; }
}

public class Url
{
     public int start { get; set; }
     public int end { get; set; }
     public string url { get; set; }
     public string expanded_url { get; set; }
     public string display_url { get; set; }
}

public class UrlList
{
     public List<Url> urls { get; set; }
}

public class Mention
{
    public int start { get; set; }
    public int end { get; set; }
    public string username { get; set; }
}

public class PublicMetrics
{
    public int followers_count { get; set; }
    public int following_count { get; set; }
    public int tweet_count { get; set; }
    public int listed_count { get; set; }
}

Use Cases

In addition to using this code to determine if you want to interact with certain types of people, you could use the Timeline API + Context Annotations and take samples of tweets from muted accounts.

Applying text analytics to these samples datasets and aggregating content or topics being regularly discussed by muted accounts can help you better understand your followers or audience.

Use these insights to further tailor your content or better understand your audience.

~

 

You can use this code by downloading the free Social Opinion API NuGet package here.

If you want to understand your followers, get richer analytics, perform social media monitoring, schedule content on Twitter and LinkedIn (Facebook and Instagram coming soon), try Social Opinion.

 

JOIN MY EXCLUSIVE EMAIL LIST
Get the latest content and code from the blog posts!
I respect your privacy. No spam. Ever.

Leave a Reply