Python - Get Data through API with Bearer Token (I) - Data Collection
As a Python beginner, I’m going to complete my first formal research task by Python, getting data from one open databank through API. But token is needed to be provided. So the blog is divided into two parts: retrieving token and calling API.
My work is mainly based on the requests
module in Python. [1] [2]
Retrieve Token
We need username
and password
(clinet_id
and clinet_secret
) to retrieve temporary token.
1 |
|
Here are the returned results:
1 |
|
Call API
Return status code to check whether your request works well. [3]
1 |
|
Here are returned results:
1 |
|
It should be noticed that, json()
is successfully called does not mean your request works well. [4]
Python - Get Data through API with Bearer Token (I) - Data Collection
http://arwenzhou.github.io/2020/11/12/Python-requests-API_1/