There are many websites providing API (Application Programming Interface) to explore and use website data. Some companies release API wrappers, while others just publish an API and independent developer group will wrap their API in common programming language (e.g. 🐍 Python), which can be used by large community.
An organisation creates a public-facing API with the intent that others can use. APIs may be well documented by the company if not, there could be API wrappers created by smart developers for us 🙂. So, a startup or creative developer community can build something better for users, third parties clients (mobile or web apps) with improved UI.
- Install the Tweepy using pip (pip install tweepy)
- Import tweepy and set up your keys and secrets
- Create authentication handler and set access tokens
- Create Twitter API object and fetch tweets via the user_timeline method
Actually you can do almost all actions for our tweets which we can do in a browser on Twitter. Please check out more on their API doc.
WIKIPEDIA : As we know Wikipedia is an online free-content encyclopedia project helping to create a world in which everyone can freely share in the sum of all knowledge. It is constantly updated and has millions of articles. Wikipedia also has a simple API that’s been wrapped for Python in the wikipedia package.
- Install the wikipedia package using pip (pip install wikipedia)
- Import wikipedia and search or view summary of a page.
If we just search for the word “Python” on Wikipedia, it is going to return a list of items containing word “Python”. So we need to be more specific. In next line, we are trying to get summary of the “Python (programming language)” item, and it prints few summary items as well.
Let’s see more info using page method:
Now, we can access and parse data from Wikipedia. And we can do many operations like search Wikipedia, get article summaries, get data like links and images from a page, and more.
This article was only about to highlight Python API wrappers available for many websites and few simple examples . Hope this will encourage us to explore more available Python API wrappers libraries. We can create our own client apps for these popular websites. It would be fun to add some kind of user interface to these client apps.
Please refer below link to have a quick look of Python API wrappers: