# Python Example

Python code example to retrieve the total tokens by each investor group

```python
import requests
import pandas as pd

url = 'https://api.tokeline.com/tokenomics/pro/apt'
headers = {
    'auth-token-x': 'API Token',
}
response = requests.get(url, headers=headers)

if response.status_code == 200:
    data = response.json() 
    df = pd.json_normalize(data['data'])
    df = df.dropna(how='all', axis=1) #drops all empty columns
    df.columns = df.columns.str.replace('_', ' ')
    df.columns = df.columns.str.title()
    df.set_index('Token Emissions', inplace=True)  #Token Emissions contains the dates
    num = df.select_dtypes(include=['number'])
    df[num.columns] = num.where(num >= 0, 0) #Cliff Periods are saved as "-1" and have to be adjusted

    pd.options.display.float_format = "{:,.2f}".format

    print("\nTotal Tokens per Investor:")
    print(df.sum())

else:
    print(f"Request failed with status code {response.status_code}")

```

```
Output:

Total Tokens per Investor:
Community           510,217,359.20
Core Contributors   189,999,999.90
Foundation          164,999,999.60
Investors           134,782,640.16
Staking Rewards     694,021,738.32
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tokeline.com/api-documentation/python-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
