# WhatPulse API Python Package
This Package makes use of the WhatPulse Client API, making you able to easily use the API for any purpose (almost).
## Introduction to the Package
1. Setting the API up
To set up the API, you need to download and use the WhatPulse Application on PC.
Click on the Settings Tab, then Enable the Client API and choose a Port (or use the standard 3490 Port).
1. Start Coding (Setting up API)
First you have to import this Package, then define the API Object by calling the WhatPulse Class. Here you need the port you connect to, the retriever (more on that later) and if the Bot gets automatically set up (more on that later too)
```
import WhatPulseAPI as wp_api
my_api = wp_api.WhatPulse(<port>, <retriever>, <auto-setup?>)
```
## **Explanations (Docs)**
### **Retrievers:**
Retrievers are the last part of the URL to the API, usually the URL looks something like this: "http://localhost:3490/v1/account-totals". In this case "account-totals" is the retriever.
```
import WhatPulseAPI as wp_api
my_api = wp_api.WhatPulse(3490, "account-totals", True)
```
**All Retrievers:**
- account-totals (shows your total stats)
- realtime (shows stats per second e.g. Clicks Per Second)
- unpulsed (reveals all unpulsed stats)
- all-stats (all of the above)
- profiles (returns all profiles)
- pulse (pulses WhatPulse)
- open-window (opens WhatPulse window)
- profiles/activate (not implemented yet)
### **Auto-Setup:**
Auto-Setup essentially automatically sends a request to the API as soon as you initialize the WhatPulse class. Meaning that this code would instantly open the WhatPulse window as soon as you run this program.
```
import WhatPulse_API as wp_api
my_api = wp_api.WhatPulse(3490, "open-window", True)
```
If you want to send a request later, then do this:
```
# Opens WhatPulses window after 5 seconds.
import WhatPulse_API as wp_api, time
my_api = wp_api.WhatPulse(3490, "open-window", False)
time.sleep(5)
my_api.setup_api()
```
### **return_all_keys_values()**
The JSON File called by the API is essentially a bunch of tuples we can append all keys to one list and all the values to the corresponding keys in another list.
```
import WhatPulseAPI as wp_api
my_api = wp_api.WhatPulse(3490, "account-totals", True)
all_keys, all_values = my_api.return_all_keys_values()
print(all_keys, all_values)
> all_keys: ['clicks', 'clicks_formatted', 'distance_formatted', 'distance_miles', 'download', 'download_formatted', 'keys', 'keys_formatted', 'ranks', 'scrolls', 'scrolls_formatted', 'upload', 'upload_formatted', 'uptime', 'uptime_formatted']
> ['2311327', '2.311.327', '415km, 701m', '258.305', '2501209', '2,39TB', '6239937', '6.239.937', {'rank_clicks': '42866', 'rank_clicks_formatted': '42.866th', 'rank_distance': '3281', 'rank_distance_formatted': '3.281st', 'rank_download': '22213', 'rank_download_formatted': '22.213th', 'rank_keys': '30767', 'rank_keys_formatted': '30.767th', 'rank_scrolls': '5375', 'rank_scrolls_formatted': '5.375th', 'rank_upload': '16702', 'rank_upload_formatted': '16.702nd', 'rank_uptime': '60442', 'rank_uptime_formatted': '60.442nd'}, '1762076', '1.762.076', '577453', '563,92GB', '8971926', '103d, 20h, 12m']
```
### **return_value(key)**
Returns the value to the corresponding key.
```
import WhatPulseAPI as wp_api
my_api = wp_api.WhatPulse(3490, "account-totals", True)
value = my_api.return_value('clicks')
print(value)
> 2311327
```
### **return_all_ranks()**
Returns all ranks, one list for all the ranks that have not been formatted yet and one list for the formatted ranks as you can see here in the small code snippet.
```
import WhatPulseAPI as wp_api
my_api = wp_api.WhatPulse(3490, "account-totals", True)
all_ranks, all_ranks_formatted = my_api.return_all_ranks()
print(all_ranks[0], all_ranks_formatted[0])
> all_ranks[0] -> ('rank_clicks', '42866')
> all_ranks_formatted[0] -> ('ranks_clicks_formatted', '42.866th')
```
### **return_rank(key)**
Returns the value to the corresponding rank-key.
```
import WhatPulseAPI as wp_api
my_api = wp_api.WhatPulse(3490, "account-totals", True)
value = my_api.return_rank('rank_clicks_formatted')
print(value)
> 42.866th
```
### **all_profiles()**
Returns all profiles in your Whatpulse Account
```
import WhatPulse_API as wp_api
my_api = wp_api.WhatPulse(3490, "profiles", True)
my_profiles = my_api.all_profiles()
print(my_profiles)
>[{'name': 'gaming', 'id': 1, 'active': False, 'created_at': '2024-05-08T10:47:09.000', 'updated_at': '2024-05-10T09:40:22.000'}, {'name': 'test', 'id': 2, 'active': True, 'created_at': '2024-07-31T09:47:10.500', 'updated_at': '2024-07-31T12:22:50.000'}]
```
### **search_profile(retriever, value)**
This searches for a profile and if it finds a profile it returns a json dict with all the information regarding the profile.
```
import WhatPulse_API as wp_api
my_api = wp_api.WhatPulse(3490, "profiles", True)
profile_data = my_api.search_profile('name', 'gaming')
# if there is a profile with the name 'gaming':
print(profile_data)
> {'name': 'gaming', 'id': 1, 'active': False, 'created_at': '2024-05-08T10:47:09.000', 'updated_at': '2024-05-10T09:40:22.000'}
# if the program can't find a profile with the name 'gaming':
raise BaseException("No profiles have been found. Check if the value you're looking for is correct :D")
```
### **return_profile_value(retriever, profile_id)**
This returns the value from a specific retriever in a given profile
```
import WhatPulse_API as wp_api
my_api = wp_api.WhatPulse(3490, "profiles", True)
value = return_profile_value("name", 1)
"""
This program now looks for a profile with the ID 1 and
returns the name of the profile
"""
print(value)
> "gaming"
```
Raw data
{
"_id": null,
"home_page": null,
"name": "WhatPulse-API-Py",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "WhatPulse",
"author": "Fl\u00f6rian",
"author_email": "iaccidentlyatekerosin@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3c/33/836891eb450eebcc2c40edb7d177f1cfb6904868fd68031dc953e2d9bf1d/whatpulse_api_py-0.3.0.tar.gz",
"platform": null,
"description": "\u00ef\u00bb\u00bf# WhatPulse API Python Package\r\nThis Package makes use of the WhatPulse Client API, making you able to easily use the API for any purpose (almost).\r\n\r\n## Introduction to the Package\r\n\r\n1. Setting the API up\r\nTo set up the API, you need to download and use the WhatPulse Application on PC. \r\nClick on the Settings Tab, then Enable the Client API and choose a Port (or use the standard 3490 Port).\r\n\r\n1. Start Coding (Setting up API)\r\nFirst you have to import this Package, then define the API Object by calling the WhatPulse Class. Here you need the port you connect to, the retriever (more on that later) and if the Bot gets automatically set up (more on that later too)\r\n```\r\nimport WhatPulseAPI as wp_api\r\nmy_api = wp_api.WhatPulse(<port>, <retriever>, <auto-setup?>)\r\n```\r\n## **Explanations (Docs)**\r\n\r\n### **Retrievers:**\r\nRetrievers are the last part of the URL to the API, usually the URL looks something like this: \"http://localhost:3490/v1/account-totals\". In this case \"account-totals\" is the retriever.\r\n```\r\nimport WhatPulseAPI as wp_api\r\nmy_api = wp_api.WhatPulse(3490, \"account-totals\", True)\r\n```\r\n**All Retrievers:**\r\n- account-totals (shows your total stats)\r\n- realtime (shows stats per second e.g. Clicks Per Second)\r\n- unpulsed (reveals all unpulsed stats)\r\n- all-stats (all of the above)\r\n- profiles (returns all profiles)\r\n- pulse (pulses WhatPulse)\r\n- open-window (opens WhatPulse window)\r\n- profiles/activate (not implemented yet)\r\n\r\n### **Auto-Setup:**\r\n\r\nAuto-Setup essentially automatically sends a request to the API as soon as you initialize the WhatPulse class. Meaning that this code would instantly open the WhatPulse window as soon as you run this program.\r\n```\r\nimport WhatPulse_API as wp_api\r\nmy_api = wp_api.WhatPulse(3490, \"open-window\", True)\r\n```\r\nIf you want to send a request later, then do this:\r\n```\r\n# Opens WhatPulses window after 5 seconds.\r\nimport WhatPulse_API as wp_api, time\r\nmy_api = wp_api.WhatPulse(3490, \"open-window\", False)\r\n\r\ntime.sleep(5)\r\nmy_api.setup_api()\r\n```\r\n\r\n### **return_all_keys_values()**\r\nThe JSON File called by the API is essentially a bunch of tuples we can append all keys to one list and all the values to the corresponding keys in another list.\r\n```\r\nimport WhatPulseAPI as wp_api\r\nmy_api = wp_api.WhatPulse(3490, \"account-totals\", True)\r\nall_keys, all_values = my_api.return_all_keys_values()\r\n\r\nprint(all_keys, all_values)\r\n> all_keys: ['clicks', 'clicks_formatted', 'distance_formatted', 'distance_miles', 'download', 'download_formatted', 'keys', 'keys_formatted', 'ranks', 'scrolls', 'scrolls_formatted', 'upload', 'upload_formatted', 'uptime', 'uptime_formatted']\r\n> ['2311327', '2.311.327', '415km, 701m', '258.305', '2501209', '2,39TB', '6239937', '6.239.937', {'rank_clicks': '42866', 'rank_clicks_formatted': '42.866th', 'rank_distance': '3281', 'rank_distance_formatted': '3.281st', 'rank_download': '22213', 'rank_download_formatted': '22.213th', 'rank_keys': '30767', 'rank_keys_formatted': '30.767th', 'rank_scrolls': '5375', 'rank_scrolls_formatted': '5.375th', 'rank_upload': '16702', 'rank_upload_formatted': '16.702nd', 'rank_uptime': '60442', 'rank_uptime_formatted': '60.442nd'}, '1762076', '1.762.076', '577453', '563,92GB', '8971926', '103d, 20h, 12m']\r\n```\r\n\r\n### **return_value(key)**\r\nReturns the value to the corresponding key.\r\n\r\n```\r\nimport WhatPulseAPI as wp_api \r\nmy_api = wp_api.WhatPulse(3490, \"account-totals\", True) \r\nvalue = my_api.return_value('clicks')\r\nprint(value)\r\n\r\n> 2311327\r\n```\r\n\r\n### **return_all_ranks()** \r\nReturns all ranks, one list for all the ranks that have not been formatted yet and one list for the formatted ranks as you can see here in the small code snippet.\r\n```\r\nimport WhatPulseAPI as wp_api \r\nmy_api = wp_api.WhatPulse(3490, \"account-totals\", True) \r\nall_ranks, all_ranks_formatted = my_api.return_all_ranks()\r\n\r\nprint(all_ranks[0], all_ranks_formatted[0])\r\n\r\n> all_ranks[0] -> ('rank_clicks', '42866')\r\n> all_ranks_formatted[0] -> ('ranks_clicks_formatted', '42.866th')\r\n```\r\n\r\n### **return_rank(key)**\r\nReturns the value to the corresponding rank-key.\r\n```\r\nimport WhatPulseAPI as wp_api \r\nmy_api = wp_api.WhatPulse(3490, \"account-totals\", True) \r\nvalue = my_api.return_rank('rank_clicks_formatted')\r\nprint(value)\r\n\r\n> 42.866th\r\n```\r\n\r\n### **all_profiles()**\r\nReturns all profiles in your Whatpulse Account\r\n```\r\nimport WhatPulse_API as wp_api\r\nmy_api = wp_api.WhatPulse(3490, \"profiles\", True)\r\nmy_profiles = my_api.all_profiles()\r\nprint(my_profiles)\r\n\r\n>[{'name': 'gaming', 'id': 1, 'active': False, 'created_at': '2024-05-08T10:47:09.000', 'updated_at': '2024-05-10T09:40:22.000'}, {'name': 'test', 'id': 2, 'active': True, 'created_at': '2024-07-31T09:47:10.500', 'updated_at': '2024-07-31T12:22:50.000'}]\r\n```\r\n### **search_profile(retriever, value)**\r\nThis searches for a profile and if it finds a profile it returns a json dict with all the information regarding the profile.\r\n```\r\nimport WhatPulse_API as wp_api\r\nmy_api = wp_api.WhatPulse(3490, \"profiles\", True)\r\nprofile_data = my_api.search_profile('name', 'gaming')\r\n\r\n# if there is a profile with the name 'gaming':\r\nprint(profile_data)\r\n\r\n> {'name': 'gaming', 'id': 1, 'active': False, 'created_at': '2024-05-08T10:47:09.000', 'updated_at': '2024-05-10T09:40:22.000'}\r\n\r\n# if the program can't find a profile with the name 'gaming':\r\nraise BaseException(\"No profiles have been found. Check if the value you're looking for is correct :D\")\r\n```\r\n\r\n### **return_profile_value(retriever, profile_id)**\r\nThis returns the value from a specific retriever in a given profile\r\n```\r\nimport WhatPulse_API as wp_api\r\nmy_api = wp_api.WhatPulse(3490, \"profiles\", True)\r\nvalue = return_profile_value(\"name\", 1)\r\n\r\n\"\"\"\r\nThis program now looks for a profile with the ID 1 and\r\nreturns the name of the profile\r\n\"\"\"\r\n\r\nprint(value)\r\n> \"gaming\"\r\n``` \r\n",
"bugtrack_url": null,
"license": "GNU General Public License v3.0 or later",
"summary": "Easy Module to work with WhatPulse Client API.",
"version": "0.3.0",
"project_urls": null,
"split_keywords": [
"whatpulse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "073ead59e79a8f639d2eecec4d38610cd8de00f54256e33a45e1b03e008949a7",
"md5": "8048dfd86aebc4fb2e8dec85b59a8dca",
"sha256": "7233110384a2015ce0087470b22444b8b204a2ad9117e30d2dc1ae80d30e8540"
},
"downloads": -1,
"filename": "WhatPulse_API_Py-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8048dfd86aebc4fb2e8dec85b59a8dca",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17221,
"upload_time": "2024-07-31T13:35:39",
"upload_time_iso_8601": "2024-07-31T13:35:39.141194Z",
"url": "https://files.pythonhosted.org/packages/07/3e/ad59e79a8f639d2eecec4d38610cd8de00f54256e33a45e1b03e008949a7/WhatPulse_API_Py-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3c33836891eb450eebcc2c40edb7d177f1cfb6904868fd68031dc953e2d9bf1d",
"md5": "ae1f7c0d9d45f8e104efd6c52144c213",
"sha256": "7d937161575f71ec5693281de0649fd744bdc6038330076e0355428806d47536"
},
"downloads": -1,
"filename": "whatpulse_api_py-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "ae1f7c0d9d45f8e104efd6c52144c213",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 17211,
"upload_time": "2024-07-31T13:35:50",
"upload_time_iso_8601": "2024-07-31T13:35:50.344973Z",
"url": "https://files.pythonhosted.org/packages/3c/33/836891eb450eebcc2c40edb7d177f1cfb6904868fd68031dc953e2d9bf1d/whatpulse_api_py-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-31 13:35:50",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "whatpulse-api-py"
}