Ich versuche, Daten von einer API zu extrahieren, aber in der Dokumentation wurde mir nur ein API-Schlüssel gegeben, den ich vermute, ist der private Schlüssel.Wie API-GET-Anfragen ohne API Public Key gemacht werden
Wenn dies der Fall ist, wie kann ich einen GET-Aufruf in Python machen ziehen Daten für etwa Inventar anhand von unten Dokumentation Dokumentation (nicht veröffentlichen gesamtes Dokument) und wenn keine URL zur Verfügung gestellt ?:
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
Dies ist mein Code so weit:
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()
Wenn ich ausführen, um die oben ich die folgende Meldung:
ValueError: No JSON object could be decoded
Ich bin nicht sicher, was ich die Daten bekommen tue, wenn ich eine Antwort Status 200.
bearbeiten bekommen:
Ran print (R.TEXT) diese Nachricht erhalten:
<!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>
Wie kann der Browser veraltet sein, wenn ich Informationen in ein Python-Anaconda-Fenster ziehe?
ausführen 'print (R.TEXT)' – eyllanesc
eine bearbeitet, lief print (R.TEXT) bekam Nachricht Browser (siehe oben) nicht mehr aktuell zu sagen. Wie kann das sein, wenn Daten in Python Anaconda Modul kommen? – RustyShackleford
Weiß nicht Anakonda, aber wenn es eine JSON API ist, möchtest du nicht JSON GET machen? –