Software Architect / Microsoft MVP (AI) and Pluralsight Author

Social Opinion API, Startups, Twitter API v2

Support for Twitter Spaces API added to Social Opinion API

I’ve implemented support all new Twitter Spaces API endpoints that were recently shipped by Twitter.

These are available in my NuGet package and on GitHub.

You can do the following with this latest update:

  • Search and discover the Spaces you care about
  • Lookup a Space by the Space ID
  • Lookup Spaces by a collection of Space IDs
  • Discover Spaces created by user ids

 

You can use them with a few lines of code. The first thing you need to do is create an instance of the new Spaces service and pass in your OAuth tokens:

SpacesService spacesService = new SpacesService(oAuthInfo);

 

You are now free to call each of the methods.

Searching and Discovering Spaces

This method will get you search for any Twitter Spaces that match your criteria.

Each item in the list will contain all publicly available properties for a Space.

SpacesModel results = spacesService.Search("AI", SpacesService.State.scheduled, 10);

You can see an example of the user data each item will contain here:

public class SpacesModel
{
    public List<Data> data { get; set; }
    public Includes includes { get; set; }
    public Meta meta { get; set; }
}
public class Data
{
       	public string lang { get; set; }
        public DateTime created_at { get; set; }
        public DateTime started_at { get; set; }
        public DateTime updated_at { get; set; }
        public string state { get; set; }
        public DateTime scheduled_start { get; set; }
        public string title { get; set; }
        public List<string> host_ids { get; set; }
        public bool is_ticketed { get; set; }
        public int participant_count { get; set; }
        public string id { get; set; }
        public string creator_id { get; set; }
}

Lookup Space by ID

This method lets you fetch a Twitter Space for a given space id:

SpaceModel space = spacesService.Lookup("1rmGPzoqAqVxN");

You can see an example of some of the Space data each item will contain here:

public class Data
{
        public string lang { get; set; }
        public DateTime created_at { get; set; }
        public DateTime started_at { get; set; }
        public DateTime updated_at { get; set; }
        public string state { get; set; }
        public DateTime scheduled_start { get; set; }
        public string title { get; set; }
        public List<string> host_ids { get; set; }
        public bool is_ticketed { get; set; }
        public int participant_count { get; set; }
        public string id { get; set; }
        public string creator_id { get; set; }
}

Lookup Spaces by IDs

This method lets you fetch a list Twitter Spaces for a list of Space IDs:

List<string> spaceIds = new List<string> { "1rmGPzoqAqVxN", "1zqJVXYLmwPKB" };

SpacesModel spaces = spacesService.Lookup(spaceIds);

Lookup Spaces by Creator IDs

This method lets you fetch a list Twitter Spaces by your favourite creator ids:

List<string> creatorIds = new List<string> { "4897735439", "2244994945" };

SpacesModel spacesByCreators = spacesService.LookupByCreatorId(creatorIds);

Use Cases

Main use cases for this latest update to the open-source .NET developer SDK are centred around the discovery of Twitter Spaces.  Here you can see a Twitter Spaces search feature (beta) in Social Opinion:

This can help you discover and manage Twitter Spaces that you might be interested in. It helps you do this by:

  1. Supply your search criteria
  2. Find Spaces you are interested in
  3. Register and a diary appointment is sent to remind you

This hasn’t been published yet and it still going through testing but is a use case that might be useful.

~

Free NuGet Package: You can find the free NuGet package here.

More information on the Spaces API here.

If you want to quickly understand your followers, analytics or automate aspects of your Twitter account, 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