# What is the equivalent Julia code for this code in Python using requests?

**URL:** https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468
**Category:** New to Julia
**Created:** [April 17, 2021, 9:29am UTC](https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468 "2021-04-17T09:29:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)
#### Post date: [April 17, 2021, 9:29am UTC](https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468/1 "2021-04-17T09:29:07Z")

</div>

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)

```

---

<div class="post-metadata">

### Author: ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)
#### Post date: [April 17, 2021, 9:40am UTC](https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468/2 "2021-04-17T09:40:25Z")

</div>

Your python example is incomplete. Look dictionary: [Collections and Data Structures · The Julia Language](https://docs.julialang.org/en/v1/base/collections/#Base.Dict) and tuples [Functions · The Julia Language](https://docs.julialang.org/en/v1/manual/functions/#Tuples) from the documentation.

---

<div class="post-metadata">

### Author: ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)
#### Post date: [April 17, 2021, 9:54am UTC](https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468/3 "2021-04-17T09:54:55Z")

</div>

Sorry, I left out the last part. Thank you for the reference.

---

<div class="post-metadata">

### Author: ![danielw2904](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielw2904/32/10890_2.png) [@danielw2904](https://discourse.julialang.org/u/danielw2904)
#### Post date: [April 17, 2021, 10:19am UTC](https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468/4 "2021-04-17T10:19:41Z")

</div>

This could be helpful

> [@Help translating curl command to HTTP.jl](https://discourse.julialang.org/t/help-translating-curl-command-to-http-jl/53790):
>
> 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](https://juliaweb.github.io/HTTP.jl/stable/public_interface/#HTTP.request)

---

<div class="post-metadata">

### Author: ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)
#### Post date: [April 17, 2021, 12:31pm UTC](https://discourse.julialang.org/t/what-is-the-equivalent-julia-code-for-this-code-in-python-using-requests/59468/5 "2021-04-17T12:31:31Z")

</div>

You can do something like this

```julia
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 => {…

```
