Get a list created by a user other than yourself

A memo when I wanted a list of followers / followers' lists and made Tools for making such things. At first I thought I'd do it with Tweepy, but I couldn't find a function to get lists other than myself, that is, lists / list, lists / ownerships, lists / subscriptions, etc. I ended up doing it myself. I wonder why ...

from requests_oauthlib import OAuth1Session
import json

session = OAuth1Session(consumer_key, consumer_secret, access_token, access_token_secret)

api_url = 'https://api.twitter.com/1.1/lists/ownerships.json'
params = {'user_id': userid}
req = session.get(api_url, params=params)

if req.status_code == 200:
    jsn = json.loads(req.text)
    for item in jsn['lists']:
        print(item['name'])
else:
    print('Error: %d' % req.status_code)

Recommended Posts

Get a list created by a user other than yourself
Get a list of Qiita likes by scraping
[Python] How to get a value with a key other than value with Enum
Get Redmine User list with DataFrame
[python] Get a list of instance variables
Get a domain owned by a specific organization
[Python] Get a list of folders only
Get a list of articles posted by users with Python 3 Qiita API v2
Get a list of IAM users with Boto3
A simple to-do list created with Python + Django