python linkedin

Download LinkedIn contacts with Python

Hello everybody!

This post will be about two new things: Using Python for getting Social Data and working with the LinkedIn API and is based on Matthew A. Russell´s book “Mining the Social Web“. If you are interested in that topic you should really take a look at this book.

The main feature of this API is getting contacts and this is what I will do in this tutorial. In the following tutorials I will show you then how to visualize you contacts. But for now we download our contacts.


First of all we have to get an API key. You can get it at

linkedin pythonYou have to login into your account and then on “Add New Application”. linkedin python

There you have to give your new app a name and fill in some other details. For our purpose, as we don´t want to publish the app, you can write whatever you want. It is just important  “r_basicprofile” in the section OAuth User Agreement. linkedin python

Then just click on “Add Application” and you can see your app keys.

Download LinkedIn contacts with Python

Ok now we have our keys and can start with the Python part. You can use whatever Python IDE you want. I would recomment pyCharm as it works really great for me.

For downloading the contacts we use the linkedin-python package and for displaying them we use the prettytable package. Just open a terminal and type in:

Let´s take a look at the python code.
First of all we have to import the needed packages, set our LinkedIn app keys create create a so called “app” in the python code. This app will be our connection to the LinkedIn API.

Then we can use the prettytable packe and print them as a nice looking table:


Julian Hillebrand

During my time at university and learning about the basics of economics I started heavily exploring the possibilities and changes caused by digital disruptions and the process of digital transformation, whereby I focused on the importance of data and data analytics and combination with marketing and management.
My personal focus of interest lies heavily on technology, digital marketing and data analytics. I made early acquaintance with programming and digital technology and never stop being interested in following the newest innovations.

I am an open, communicative and curious person. I enjoy writing, blogging and speaking about technology.