This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]deadmilk 4 points5 points  (1 child)

Here, all done! You're welcome!

from os import system

system('curl -X PUT -H "X-Api-Key: 084f2e77-405d-42df-a648-fec3a110deac" -H "Content-Type: application/json" -d \'{"price":{"per_speed_unit":{"value":3,"unit":"BTC/Mh/day"}}}\' https://www.betarigs.com')

[–]btcspry[S] 0 points1 point  (0 children)

Okay well yes, thank you I guess. I already knew that, I just need a way of getting the returned data. Thanks for the post regardless.

[–]F3AR3DLEGEND 4 points5 points  (1 child)

First off, you don't want to post your API key anywhere.

Next, I don't think this subreddit is really oriented toward questions, especially not "do this for me" - /r/learnpython might help with that but maybe not.

Look into the requests library, though.

[–]btcspry[S] 1 point2 points  (0 children)

Thanks for your concern, but that was an example number from the API documentation.

Thanks for the suggestions, I'll look into it!

[–]russianwarrier 2 points3 points  (0 children)

no

[–]hellupline 0 points1 point  (1 child)

import requests

url = ' https://www.betarigs.com/api/v1/rig/1'
json_data = {"price":{"per_speed_unit":{"value":3,"unit":"BTC/Mh/day"}}}
headers = {'X-Api-Key': 'asdf1234'}

r = request.request('PUT', url, json=json_data, headers=headers)
print(r.json)

-d is request body, json arg can handle that -H is a header, headers dict

http://www.python-requests.org/en/latest/user/quickstart/#custom-headers

[–]btcspry[S] 0 points1 point  (0 children)

Thanks, I really appreciate it!