A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://twython.readthedocs.io/en/latest/usage/basic_usage.html below:

Basic Usage¶

This section will cover how to use Twython and interact with some basic Twitter API calls

Before you make any API calls, make sure you authenticated the user (or app)!

Note

All sections on this page will assume you’re using a Twython instance

Authenticated Calls¶ OAuth 1¶

Create a Twython instance with your application keys and the users OAuth tokens

from twython import Twython
twitter = Twython(APP_KEY, APP_SECRET,
                  OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
OAuth 2¶

Create a Twython instance with your application key and access token

from twython import Twython
twitter = Twython(APP_KEY, access_token=ACCESS_TOKEN)
Searching¶

Note

Searching can be done whether you’re authenticated via OAuth 1 or OAuth 2

Documentation: https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets

twitter.search(q='python')

Important

To help explain dynamic function arguments a little more, you can see that the previous call used the keyword argument q, that is because Twitter specifies in their search documentation that the search call accepts the parameter “q”. You can pass mutiple keyword arguments. The search documentation also specifies that the call accepts the parameter “result_type”

twitter.search(q='python', result_type='popular')

So, now, you’re pretty well versed on making authenticated calls to Twitter using Twython. Check out the advanced usage section, for some functions that may be a little more complicated.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4