mmohades / Venmo

Venmo API client for Python
GNU General Public License v3.0
145 stars 43 forks source link

NameError: name 'venmo_api' is not defined #16

Closed ironclock closed 3 years ago

ironclock commented 3 years ago

This happens when I try to run this code

def callback(transactions_list): for transaction in transactions_list: print(transaction)

# callback is optional. Max number of transactions per request is 50. venmo_api.user.get_user_transactions(user_id='0000000000000', callback=callback)

ironclock commented 3 years ago

(need to import venmo_api)

Documentation makes no mention of this

mmohades commented 3 years ago

You only need Client from venmo_api

from venmo_api import Client

access_token = " your access token"

client = Client(access_token=access_token)

client.user.   #.  -> user related methods, like client.user.get_user_transactions()
client.payment.  # -> payment related methods , like client.payment.get_payment_methods()
mmohades commented 3 years ago

If you don't have your access token, you can get it using the cli method:

from venmo_api import Client

access_token = Client.get_access_token(username='myemail@random.com',
                                       password='your password')
print(access_token)

You don't have to login every time, just keep a note of your access token and pass it to Client() next time. Also, make sure to keep your access token somewhere safe since it never gets expired.