Twitter API 403 error when using POST instead of GET


#1

Hello,
I am using twython package to scrap twitter users.
Due to the number of handles I am dealing with, I cannot use the “lookup_user” function. So I started using “request” function instead.
The information regarding how to use “lookup_user” and “request” can be found at:

https://twython.readthedocs.org/en/latest/api.html#core-interface

My question is, according to the twython documentation found at above link, “request( )” usage is defined as follows:

   request(endpoint, method='GET', params=None, version='1.1')¶
   Return dict of response received from Twitter’s API

   Parameters:	
   endpoint (string) – (required) Full url or Twitter API endpoint (e.g. search/tweets)
   method (string) – (optional) Method of accessing data, either GET or POST. (default GET)
   params (dict or None) – (optional) Dict of parameters (if any) accepted the by Twitter API endpoint you are trying to access (default None)
   version (string) – (optional) Twitter API version to access (default 1.1)
 
   Return type:	
   dict

my question is, what exactly does “Twitter API endpoint” mean (to use as the value for the parameter “endpoint”)? is “Twitter API endpoint” something user-specific? if not, what is it? to get information about the user “3Degrees_Inc”, for instance, I used “https://twitter.com/3Degrees_Inc” for my “Twitter API endpoint”, but it’s throwing me an 403 error…am I understanding “Twitter API endpoint” concept correctly?

thank you


#2

An old quirk of the Twitter REST API is that it considers all POST actions write actions, as far as the “permission level” of an access token or application is concerned.

If your application (and by result, the access token) you’re using to make requests is read-only, you won’t be able to use POST on users/lookup.

In the case of the library you’re using, I think endpoint either means a fully qualified API resource URL or just a fragment. A fragment example would be: “users/lookup” while the more verbose variation would be “https://api.twitter.com/1.1/users/lookup.json