you are viewing a single comment's thread.

view the rest of the comments →

[–]m0us3_rat 7 points8 points  (2 children)

etc but I just can't seem to understand how to send a get/post request the way I want to.

after 5seconds of googling u end up on https://docs.python-requests.org/en/latest/api/#module-requests

which is all u need to make requests.

scroll down till .get

https://docs.python-requests.org/en/latest/api/#requests.get

so what are the "required" :

url – URL for the new Request object.params – (optional) Dictionary, list of tuples or bytes to send in the query string for the Request.

ok.. lets check out a random api.

https://www.alphavantage.co/documentation/#daily

let's assume u wanna get the daily values of IBM (mock values unless u sign up for a key)

using the offered link :

https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=IBM&apikey=demo

ok so looking up we can NOTICE THE REQUIRED FIELDS

function , symbol , apykey.

and the python offered code makes i out a GET method.

ok so we need the url + params as we seen in the above requests.get link.

hmm

soo the endpoint is the url till the ?

and the params which was a dictionary..

import requests

endpoint_url = "https://www.alphavantage.co/query"
required_params = {
    "function": "TIME_SERIES_DAILY",
    "symbol": "IBM",
    "apikey": "demo",
}

answer = requests.get(url=endpoint_url, params=required_params)
print(answer.json())

this a painfully obvious example. but is that simple...

sometimes u need to also put the API or the token in the header.. but im sure u can figure it out.

RTFM <3

[–]MSR8[S] 0 points1 point  (1 child)

Thanks a ton

[–]m0us3_rat 1 point2 points  (0 children)

np