简体   繁体   English

用 python 拉 Swagger API

[英]Pulling Swagger API with python

Can someone explain how I can pull this API info with python or point me in the right direction?有人可以解释我如何使用 python 提取此 API 信息或指出正确的方向吗?

On the swagger documentation page for the API I am trying to access, I go to the header authentication section;在我试图访问的 API 的 swagger 文档页面上,我 go 到 Z099FB995346F331E5E39 认证部分; paste in the API key, and am returned with a 'Base XXXXXXXXXXXX" key. Which I learned is an encoded base64 key. Then I paste the Basic key into the API key input filed in another section (See screenshot) and am successful in pulling the API information.粘贴在 API 密钥中,并返回一个“Base XXXXXXXXXXXX”密钥。我了解到这是一个编码的 base64 密钥。然后我将基本密钥粘贴到 ZDB974238714CA8DE634A7CE1D083A 中的另一个部分中的屏幕截图中成功输入API 信息。

However, I cannot figure out how to pull that information with python requests or postman.但是,我无法弄清楚如何使用 python 请求或 postman 提取该信息。 When I google "Pulling API with basic API key" It says I need a username and password.当我用谷歌搜索“使用基本的 API 密钥提取 API”时,它说我需要用户名和密码。

Any help would be appreciated.任何帮助,将不胜感激。 My apologize for the noob question enter image description here我为菜鸟问题道歉 在此处输入图片描述

API 文档的屏幕截图

I found the answer.我找到了答案。

from hashlib import new from unicodedata import name from urllib import response import requests import pandas as pd url = 'URL' from hashlib import new from unicodedata import name from urllib import response import requests import pandas as pd url = 'URL'

headers = {'Authorization': 'Basic xxxxxxxxxxx'} headers = {'授权':'基本 xxxxxxxxxxx'}

r = requests.get(url,headers=headers ) r = requests.get(url,headers=headers)

data = r.json()数据 = r.json()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM