Authentication using tweepy-User authentication and application authentication (Python)

auth.py


import tweepy
consumer_key = ""
consumer_secret = ""
access_token = ""
access_token_secret = ""

At that time

User authentication (user auth)

auth.py


auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)

App authentication (app auth)

auth.py


auth = tweepy.AppAuthHandler(consumer_key, consumer_secret)
api = tweepy.API(auth)

It will be. User authentication and app authentication have completely different rate limits! https://developer.twitter.com/en/docs/basics/rate-limits bandicam 2020-02-08 06-15-52-799.jpg

Also, it is in the form of api =, which is an API object in tweepy and is http://docs.tweepy.org/en/latest/api.html bandicam 2020-02-08 06-18-13-870.jpg print(api.rate_limit_status()) If you do like bandicam 2020-02-08 06-19-23-455.jpg The number of remaining requests will be returned like this (JSON). And when you want to search for tweets, bandicam 2020-02-08 06-20-19-954.jpg If you open the reference like this, you can see various things.

Thank you very much.

fixed phrase I'm always on Twitter (@ kenkensz9) so if you have any questions I hope you like it!

Recommended Posts

Authentication using tweepy-User authentication and application authentication (Python)
Clustering and visualization using Python and CytoScape
Function synthesis and application in Python
Notes using cChardet and python3-chardet in Python 3.3.1.
From Python to using MeCab (and CaboCha)
Passwordless authentication with RDS and IAM (Python)
Using Python and MeCab with Azure Databricks
Python: Application of image recognition using CNN
Setting up Basic authentication using Python @Lambda
I'm using tox and Python 3.3 with Travis-CI
Setting up Digest authentication using Python @Lambda
Start using Python
Python Https Authentication
Scraping using Python
I want to make a web application using React and Python flask
Head orientation estimation using Python and OpenCV + dlib
I tried web scraping using python and selenium
Notes on installing Python3 and using pip on Windows7
Develop and deploy Python APIs using Kubernetes and Docker
Python development flow using Poetry, Git and Docker
I tried object detection using Python and OpenCV
Create a web map using Python and GDAL
[Introduction to Udemy Python3 + Application] 64. Namespace and Scope
[Python3] Automatic sentence generation using janome and markovify
Try using tensorflow ① Build python environment and introduce tensorflow
Create a Mac app using py2app and Python3! !!
Try using ChatWork API and Qiita API in Python
[Introduction to Udemy Python3 + Application] 35. Comparison operators and logical operators
[python] Compress and decompress
Initial settings for using Python3.8 and pip on CentOS8
Python and numpy tips
[Python] pip and wheel
Operate Redmine using Python Redmine
Searching for pixiv tags and saving illustrations using Python
Extendable skeletons for Vim using Python, Click and Jinja2
Fibonacci sequence using Python
Try creating a compressed file using Python and zlib
Aggregate Git logs using Git Python and analyze associations using Orange
Batch design and python
Python iterators and generators
[Python] Easy Google Translate app using Eel and Googletrans
Data analysis using Python 0
(Python) Try to develop a web application using Django
Pass the authentication proxy through communication using python urllib3
Python packages and modules
Vue-Cli and Python integration
Ruby, Python and map
Parse and visualize JSON (Web application ⑤ with Python + Flask)
Data cleaning using Python
Send and receive Gmail via the Gmail API using Python
python input and output
Using Python #external packages
Python and Ruby split
Implementing a generator using Python> link> yield and next ()> yield
WiringPi-SPI communication using Python
Age calculation using python
Get and automate ASP Datepicker control using Python and Selenium
Read and write NFC tags in python using PaSoRi
Web application using Bottle (1)
Search Twitter using Python
Speech transcription procedure using Python and Google Cloud Speech API