Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation - Python contribution #227

Open
joaovcoelho opened this issue Jan 12, 2022 · 0 comments
Open

Documentation - Python contribution #227

joaovcoelho opened this issue Jan 12, 2022 · 0 comments

Comments

@joaovcoelho
Copy link

Hi there! At the website we can't find any reference for the Python use of the API, but I've found the solution (it is somebody else's code, but I've modified it a bit. I've found a guy named "Dr. Worm" using it). It could be useful if this example were at the official documentation as well, for everyone to see.

Here it goes:

import json
import requests


client_id = 'your_client_id'
client_secret = 'your_client_secret'
api_url = 'https://api.artsy.net/api/tokens/xapp_token'


# Catches token
r = requests.post(api_url, 
 	data={"client_id":client_id,
              "client_secret":client_secret})

j = json.loads(r.text)
token = j["token"]


# Connects and Requests information
headers = {"X-Xapp-Token": token}

artist = "andy-warhol"
url = "https://api.artsy.net/api/artists/" + artist

r = requests.get(url, headers = headers)

data = json.loads(r.text)

Good job, guys. Thanks for the API!
@dblock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant