这是一个设计糟糕的API吗?

2024-09-26 22:53:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用geni.com API,但我对得到的响应感到困惑

特别是这个:https://www.geni.com/platform/developer/help/api?path=user%2Fmanaged-profiles&version=1

使用API密钥(成功)对自己进行授权后,我得到的响应取决于我调用的内容

如果我按如下方式使用Python,那么我将得到一个完整格式的HTML文档

Python snippet
URLManagedProfiles = "https://www.geni.com/api/user/managed-profiles"
r = requests.get(URLManagedProfiles)

如果我转到我的web浏览器,登录geni.com,然后将这个URL粘贴到浏览器栏中,我会得到一个纯json的GUID和名称列表,这就是我想要的

Browser address bar
https://www.geni.com/api/user/managed-profiles

{
results: [
{
guid: "6000000003440360004",
name: "xxxxx"
},
{
guid: "6000000004787958755",
name: "xxxxx"
},
{
guid: "6000000004828562356",
name: "xxxxx"
},
{
guid: "6000000004823232333",
etc

现在,网站上的文档似乎建议我应该使用javascript。。。。但我几乎没有接触过这种情况

问题:

  1. 这个API是以某种奇怪的方式构造的吗?我知道我们看不到它的背后是什么,但它的行为方式只是。。。出乎意料

  2. 我是否过于乐观地希望能够通过Python使用API


Tags: name文档httpscomapiwww方式profiles
1条回答
网友
1楼 · 发布于 2024-09-26 22:53:02

After authorising myself with my API key (successfully)

URLManagedProfiles = "https://www.geni.com/api/user/managed-profiles"
r = requests.get(URLManagedProfiles)

这里没有身份验证。您将获得登录页面的HTML

相关问题 更多 >

    热门问题