如何在没有API公钥的情况下发出API GET请求

问题描述 投票:-1回答:1

我试图从API中提取数据但在文档中我只给了一个API密钥,我假设它是私钥。

如果是这种情况,我如何在python中进行GET调用,根据以下文档文档(无法发布整个文档)提取数据,如果没有提供URL?:

Public Inventory API
 1.0 
[ Base url: https://partner-gateway.staging.mjplatform.com/v1] https://partners.mjfreeway.com/docs/inventory
API data related to inventory management

Schemes

catalog

GET
/catalog
Listing of Sellable Products
This request provides a detailed listing of all sellable products, also referred to throughout the system as "item masters", for the active facility. The listing can be filtered by some simple parameters.
Parameters
Name    Description
category_id
integer
(query) 
The ‘id’ of a single category to which you want to limit results
subcategory_id
integer
(query) 
The ‘id’ of a single subcategory to which you want to limit results
strain_id
integer
(query) 
The ‘id’ of a single strain to which you want to limit results
item_number
string
(query) 
The item number of a particular item master, i.e. BKSA00000003
uom_type
string
(query) 
The method of measurement for the item. Valid options are discrete, weight, and volume
available_online
boolean
(query) 
A boolean indicator of whether the item can be sold online

到目前为止这是我的代码:

import requests

# api-endpoint
URL = "https://www.mjplatform.com/catalog"

# location given here
key = "123abc"

# defining a params dict for the parameters to be sent to the API
PARAMS = {URL:key}

# sending get request and saving the response as response object
r = requests.get(url = URL, params = PARAMS)

# extracting data in json format
data = r.json()

当我运行上面的内容时,我收到以下消息:

ValueError: No JSON object could be decoded

如果我得到响应状态200,我不知道我在做什么来获取数据。

编辑:

Ran print(r.text)收到此消息:

<!DOCTYPE html><html lang="en"><head><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"><title>MJ Platform</title><link href="/main.b21e9284629fc8bfb7bc9b4158ad44b9.css" rel="stylesheet"></head><body><div id="defaultLoadingMessage"><div style="height:40px"></div><div class="col-md-4 col-md-offset-4"><div><h1 style="text-align:center">Loading MJ Platform</h1><div class="text-muted" style="text-align:center;width:600px;margin:auto;color:#aaa">If you continue to see this message for more than a few seconds, your browser is most likely out of date or incompatible. We support Chrome and Firefox. Other browsers may work but not provide an optimal experience. <strong>Safari and MS IE are specifically not supported.</strong></div></div></div></div><div id="app"></div><script type="text/javascript" src="/main.cccbe56cf819e9f8a6e3.js"></script></body></html>

如果我将信息拉入python anaconda窗口,浏览器怎么会过时?

python-2.7 python-requests api-design
1个回答
0
投票

给出了文档中未包含的其他API信息。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.