> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.sparkedhost.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to use the Pterodactyl API using Python

### How to use the Pterodactyl API using Python

Firstly, we need to create an API key. We will need this to interact with the panel. To do this, Click “API Credentials” on the left-hand side of the panel.

Set the description and the Allowed IPs. This is useful if you would like to secure the usage of the API key. Leave it blank if you would like to allow any IP address to the API key.

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/create_9oimhr.png)

The API key is now shown.

|| Note: Keep a backup of your API key. You will not be able to see it after you close this box!

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/key_13qwjuc.png)

We are now ready to start coding! You will require an HTTP library. In this case, we are going to use [requests](https://pypi.org/project/requests/). You are able to view all the pterodactyl endpoints [here](https://dashflo.net/docs/api/pterodactyl/v1/). Please note that the documentation page is not official!

In this example, We will cover the most useful endpoints.

**How to check server info**

To check the server status, you will need to make a request to `/api/client/servers/<server id>`. Of course, replace `<server id>` with your server id.

Here is an example of a request:

```python
import requests
import json
ApiKey = "My API Key"

response = requests.get("https://control.sparkedhost.us/api/client/servers/<server id>", headers={
    'Accept': 'application/json',
    'content-type': 'application/json',
    'Authorization': 'Bearer ' + ApiKey
}).json()

print(json.dumps(response, indent=1))
```


This is the response we get back from the panel:

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/resultspy1_1l4zqj7.png)

**How to receive server stats (e.g CPU, RAM, disk & network usage)**

In this case, you will need to make a request to `/api/client/servers/<server id>/resources`. Of course, replace `<server id>` with your server id. You are able to use the following code:

```python
import requests
import json
ApiKey = "My API Key"

response = requests.get("https://control.sparkedhost.us/api/client/servers/f7a7faee/resources", headers={
    'Accept': 'application/json',
    'content-type': 'application/json',
    'Authorization': 'Bearer ' + ApiKey
}).json()

print(json.dumps(response, indent=1))
```
This is the response we get back:

![](https://storage.crisp.chat/users/helpdesk/website/a79efd0b48a91800/resultspy2_1gbopcq.png)

---


If you require any further assistance, please create a ticket [here](https://billing.sparkedhost.com/submitticket.php).

---

Created By: Julián M.