Nash
April 17, 2021, 9:29am
1
In attempt to use a new service that provides plenty of Python examples, I would like to know the equivalent to the following in Julia. Hopefully I can then work through the remaining examples myself:
import requests
headers = {
"apikey": "c1a274360-9ebf-11eb-86374-ffd0a6421e7d"}
params = (
("type","prematch"),
);
response = requests.get('https://app.sportdataapi.com/api/v1/soccer/odds/120423', headers=headers, params=params);
print(response.text)
Your python example is incomplete. Look dictionary: Collections and Data Structures · The Julia Language and tuples Functions · The Julia Language from the documentation.
1 Like
Nash
April 17, 2021, 9:54am
3
Sorry, I left out the last part. Thank you for the reference.
This could be helpful
I would like to scrape data using the Spotify API and I cannot seem to get the example curl command to translate to HTTP.jl
I am trying to get the accesstoken using my credentials. The relevant (working) curl command run through Julia is:
run(`curl -X "POST" -H "Authorization: Basic $refreshtoken" -d grant_type=client_credentials https://accounts.spotify.com/api/token -o creds.json`)
My attempt in HTTP.jl is:
HTTP.request("POST",
"https://accounts.spotify.com/api/token",
["Authori…
https://juliaweb.github.io/HTTP.jl/stable/public_interface/#HTTP.request
You can do something like this
using HTTP
using JSON3
headers = ["apikey" => "c1a274360-9ebf-11eb-86374-ffd0a6421e7d"]
params = ["type" => "prematch"]
uri = "https://app.sportdataapi.com/api/v1/soccer/odds/120423"
res = HTTP.get(uri, query = params, headers = headers)
res = JSON3.read(res.body)
julia> res
JSON3.Object{Vector{UInt8}, Vector{UInt64}} with 2 entries:
:query => {…
:data => {…
3 Likes