Search code examples
pythonapireddit

Using reddit api incorrectly?


import requests

def username_avail(user):
    payload = {'user': 'k9thebeast'}
    r = requests.post("https://reddit.com/api/username_availible",   data=payload)
    print(r.text)

username_avail("k9thebeast")

I want to check if my username is available. I keep getting a huge html page returned. I'm looking for a JSON response. Any ideas?


Solution

  • Try GET instead of POST.

    Also try spelling username_available correctly ;-)

    See https://www.reddit.com/dev/api#GET_api_username_available