Making a simple request to APIs in python
- 2023年2月14日
- 技術情報
Today, I would like to share about making a API request using ‘requests’ library in Python. Let’s take a look.
First of all, install the ‘requests’ library by the following command.
pip install requestsor
pip3 install requestsHere is the code to make a GET request to a public API.
import requests
api = 'https://catfact.ninja/fact'
response_data = requests.get(api)
response_data_json = response_data.json()
print(response_data_json)The result is as follows.
{'fact': 'Lions are the only cats that live in groups, called prides. Every female within the pride is usually related.', 'length': 109}This is the example request to a public API. You can learn more HERE for advanced usage.
Hope you enjoy that.
By Asahi
waithaw at 2023年02月14日 10:00:00

 大人が楽しめるヒーリング絵本河童のカパと静かな森
大人が楽しめるヒーリング絵本河童のカパと静かな森 パワースポット 日本三大神滝布引の滝
パワースポット 日本三大神滝布引の滝 佐藤・広幸ドイツ魂
佐藤・広幸ドイツ魂 Himeji Castle姫路城
Himeji Castle姫路城 ボイドタイムお知らせアプリVoid Time 〜月を無視できない〜
ボイドタイムお知らせアプリVoid Time 〜月を無視できない〜 撮った写真をカレンダーに撮りカレ
撮った写真をカレンダーに撮りカレ ライブ壁紙竹田城ライブ壁紙
ライブ壁紙竹田城ライブ壁紙 赤ちゃんにっこりBaby+Smile
赤ちゃんにっこりBaby+Smile 電子書籍[for iPhone]ターラのアストロロジー
電子書籍[for iPhone]ターラのアストロロジー JSpreadsheet カラム設定Tips
									JSpreadsheet カラム設定Tips