# API for very begginers

**URL:** <https://community.aristotlemetadata.com/t/api-for-very-begginers/566>\
**Category:** API & Programming\
**Created:** [May 9, 2023, 11:06am UTC](https://community.aristotlemetadata.com/t/api-for-very-begginers/566 "2023-05-09T11:06:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iwona](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@Iwona](https://community.aristotlemetadata.com/u/Iwona)\
**Post date:** [May 9, 2023, 11:06am UTC](https://community.aristotlemetadata.com/t/api-for-very-begginers/566/1 "2023-05-09T11:06:48Z")

</div>

Hi,

I am just starting my adventure with API. I would like to write a simple program (in Python) to compare two value domains. Unfortunately my Python API query returns an empty body, although the query code is 200. Could you please help me? I don’t know if this has anything to do with each other, but the same problem occurs on the website.

Cheers,  
Iwona

```auto
import requests

headers = { 
           "accept": "application/json", 
           "Authorization": "XXXXX",
           "X-CSRFToken": "YYYYYY"
           }

params = {
            "page": "1",
            "page_size": "10"
        }

response = requests.get("https://liebherr.aristotlecloud.io/api/v4/metadata/valuedomain", params=params, headers=headers,verify=False)

print(response.status_code)
print(response.json())

```

![Screenshot 2023-05-09 130514](https://canada1.discourse-cdn.com/flex029/uploads/aristotle/original/1X/f4404d99c25ee41f7bc57b9c74173b6d9d80abc2.png)

---

<div class="post-metadata">

**Author:** ![bensilke](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@bensilke](https://community.aristotlemetadata.com/u/bensilke)\
**Post date:** [May 16, 2023, 2:54am UTC](https://community.aristotlemetadata.com/t/api-for-very-begginers/566/2 "2023-05-16T02:54:56Z")

</div>

Hey Iwona,

I think the issue is likely in the authorisation which you are using. When you submit your token, you need to structure the headers variable like this:

```auto
headers = {
    'Authorization': f'Token {TOKEN}',
}

```

The code below can be used to send a request or I’ve made a jupyter notebook which you can use. The notebook is [here.](https://gist.github.com/ben-silke/96109b6ee2007fbb0cf3abebc21a3dbd) You can download the file and then run it on your own computer.

```auto
# We are using the requests library to send this request. Requests has very good documentation if anything is not clear (https://requests.readthedocs.io/en/latest/)
import requests

# Please enter you token here.
TOKEN = ''
# Example url = https://aristotle.cloud/home/
# Please use your own url and enter it here.
client_url = ""

# For this example, we are trying to fetch value domains, but you can use this same format for any metadata object in aristotle.
# e.g. 'api/v4/metadata/dataset'
value_domain_endpoint = 'api/v4/metadata/valuedomain'

headers = {
    'Authorization': f'Token {TOKEN}',
}

# Create the url
url = client_url+value_domain_endpoint

# send the request
response = requests.get(url, headers=headers)

# Just print the first result. If you would like to see more you can use the value_domains object or use the request variable
value_domains = response.json()['results']
print(value_domains[0])

```

Please let me know if you have any issues,  
Hope this helps!  
Ben

---

<div class="post-metadata">

**Author:** ![Iwona](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@Iwona](https://community.aristotlemetadata.com/u/Iwona)\
**Post date:** [June 13, 2023, 6:34am UTC](https://community.aristotlemetadata.com/t/api-for-very-begginers/566/3 "2023-06-13T06:34:43Z")

</div>

Thank you! It solved my problem 🙂
