twython icon indicating copy to clipboard operation
twython copied to clipboard

Premium search APIs

Open D4thor opened this issue 6 years ago • 2 comments

Hey, how do I setup twython with the full-archive endpoint for which premium API access? https://developer.twitter.com/en/docs/tweets/search/api-reference/premium-search In the endpoints.py I found no hint where to define the search URL described in the link above.

The background of my research project is as follows: For a sentiment analysis, I need to crawl Tweets related to a specific topic / hashtags "from date" "to date" in 2016. Btw, please let me if you have any tips how I can perform my search request with twython. So far my skills are quite limited.

Thanks and all the best, David

D4thor avatar Feb 05 '19 11:02 D4thor

Hi,

You should be able to just authenticate with OAuth 1 or 2 and then call get:

t = Twython(...)
t.get('search/<product>/<label>')

Hope this helps!

michaelhelmick avatar Feb 05 '19 14:02 michaelhelmick

Thanks for the fast reply!

Unfortunately I don't understand exactly what you mean, respectively where do I have to change my credentials. That is, in the official Twitter Dev Api ( https://github.com/twitterdev/search-tweets-python ) they write about an authentification like this:

YAML method For premium customers, the simplest credential file should look like this:

search_tweets_api:
  account_type: premium
  endpoint: <FULL_URL_OF_ENDPOINT>
  consumer_key: <CONSUMER_KEY>
  consumer_secret: <CONSUMER_SECRET>

For developers who have multiple endpoints and/or search products, you can keep all credentials in the same file and specify specific keys to use. --credential-file-key specifies this behavior in the command line app. An example:

search_tweets_30_day_dev:
  account_type: premium
  endpoint: <FULL_URL_OF_ENDPOINT>
  consumer_key: <KEY>
  consumer_secret: <SECRET>
  (optional) bearer_token: <TOKEN>


search_tweets_30_day_prod:
  account_type: premium
  endpoint: <FULL_URL_OF_ENDPOINT>
  bearer_token: <TOKEN>

search_tweets_fullarchive_dev:
  account_type: premium
  endpoint: <FULL_URL_OF_ENDPOINT>
  bearer_token: <TOKEN>

search_tweets_fullarchive_prod:
  account_type: premium
  endpoint: <FULL_URL_OF_ENDPOINT>
  bearer_token: <TOKEN>

D4thor avatar Feb 06 '19 09:02 D4thor