Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Learning how to access APIs

Options
  • 29-08-2017 11:32pm
    #1
    Registered Users Posts: 5,856 ✭✭✭


    I'm not a very experienced programmer at all (solid beginner level in Python, intermediate in R and SQL) and I've spent the last week trying to figure out how to gain access to an API using Python, but to no avail.

    Basically I need to access an API using Python via "basic authentication sent in the header of the request". I guess I need to pass my username and password into the header somehow but I know enough to know I'm seriously out of my depth and was wondering if anyone could recommend any good books, websites, or online courses to help me learn HTTP and get access to this API. I've searched the usual suspects (coursera and udemy) but nothing seems quite appropriate. I've looked at the documentation for the requests library for Python but it's too advanced for me. I've played around with things like
    response = requests.get(url)
    
    and
    print(response.headers())
    
    but I really want to avoid copying and pasting a load of code I don't understand as this is for work and the information at the other end is sensitive. Any help much appreciated and let me know if I haven't posted enough information.


Comments

  • Registered Users Posts: 1,148 ✭✭✭punk_one82


    Valmont wrote: »
    Basically I need to access an API using Python via "basic authentication sent in the header of the request". I guess I need to pass my username and password into the header

    A quick look at the python docs shows basic authentication is as simple as
    requests.get('https://api.github.com/user', auth=('user', 'pass'))
    

    All you need to do is replace the URL, username and password. Hopefully you're using HTTPS.


  • Registered Users Posts: 5,856 ✭✭✭Valmont


    I've figured it out...! Immersion learning.


  • Registered Users Posts: 895 ✭✭✭Dubba


    www.programmableweb.com/apis/directory is a good resource for APIs


Advertisement