> For the complete documentation index, see [llms.txt](https://docs.tokeline.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokeline.com/api-documentation/python-example.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
