2

A website I'm accessing requires an API key ID and secret key as the username and password for (I'm assuming) basic authorization.

I'm using the HTTP.get function from the HTTP module but I can't find how to include my key ID and secret key.

Example HTTP.get("https://api.mybitx.com/api/1/balance")

and this returns "HTTP.StatusError: received a '401 - Unauthorized' status in response"

The website has an API guide but the only help they give is an example using cURL $ curl -u keyid:keysecret https://api.mybitx.com/api/1/balance

I would appreciate any help

Links: https://github.com/JuliaWeb/HTTP.jl

4
  • Using your example, might this work? HTTP.get(https://keyid:[email protected]/api/1/balance Commented Dec 8, 2017 at 17:33
  • trying to find the same answer. Was this ever figured out? Commented May 2, 2018 at 10:32
  • Have you tried with: julia auth = base64encode(user * ":" * pass); HTTP.get(server, headers = ["Authorization" => "Basic $(auth)"]) ? It's working for me Commented May 28, 2018 at 7:18
  • Yes I was able to get it to work, sorry for not replying sooner. The code is below: temp = "Basic " * base64encode("your_api_key_here") usr = Dict("Authorization" => temp) balances = JSON.parse(String(HTTP.get("https://api.mybitx.com/api/1/balance"; headers = usr))) Commented Jul 31, 2018 at 13:54

1 Answer 1

1

The API requires the key and secret code to be in the form: temp = Basic " + base64encode("your_api_key_here").

You then create a dictionary like so: usr = Dict("Authorization" => temp)

and finally

JSON.parse(String(HTTP.get("https://api.mybitx.com/api/1/balance"; headers = usr)))

The JSON.parse(String()) might need to change as I ran the code on quite an old Julia version last time this worked

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.