Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

MyPythonAnywhere

A python async package to communicate with PythonAnywhere api.

Installation

The beta package is available at PyPi.

Get Started

Requirements

  1. Api Token: get your api token from pythonanywhere account page.

  2. Determine if your account is US_Based or EU_Based ( It's commonly US. )

  3. Your username.

Create Client

from mypythonanywhere import AccountType, FriendlyPythonAnywhereClient

client = FriendlyPythonAnywhereClient(
    username='MerrilleChoate',
    token='API_TOKEN',
    account_type=AccountType.UsBased
)

Send Requests

Get cpu usage.

>>> result = await client.cpu.get_cpu_usage()
>>> print(result)
# CpuUsage(daily_cpu_limit_seconds=100, next_reset_time='2022-04-17T11:23:40', daily_cpu_total_usage_seconds=0.0) 

Get all of your consoles.

>>> result = await client.consoles.get_consoles()
>>> print(result)
# [Console(id=24036640, user='MerrilleChoate', executable='python2.7', arguments='', working_directory=None, name='Python2.7 console 24036640', console_url='/user/MerrilleChoate/consoles/24036640/', console_frame_url='/user/MerrilleChoate/consoles/24036640/frame/')]

A full example

Send requests one by one

import asyncio

async def main():

    client = FriendlyPythonAnywhereClient(
        username='MerrilleChoate',
        token='API_TOKEN',
        account_type=AccountType.UsBased
    )

    consoles = await client.console.get_consoles()
    print(consoles)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Send a batch of requests using one session

import asyncio

async def main():

    client = FriendlyPythonAnywhereClient(
        username='MerrilleChoate',
        token='API_TOKEN',
        account_type=AccountType.UsBased
    )

    async with client:
        consoles = await client.console.get_consoles()
        for x in consoles:
            await client.console.kill_console(x.id)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

Direct Call

from mypythonanywhere.pythonanywhere import PythonAnywhereClient
from mypythonanywhere.types.requests.console_requests import GetConsoleInfo

client = PythonAnywhereClient(
    # --- sniff ---
)

console = await client(GetConsoleInfo(123456789)) # Console

🍟 Not all methods are implemented yet! ...

Contribute

There're api methods that are not implemented. following the order of https://help.pythonanywhere.com/pages/API, methods related to files and below are yet to implement.

Implement Methods?

Take a look at requests dir for examples of implementing api methods.

All you need is to inherit from BaseRequest[T] ( where T is the method return type ). then filling the abstract methods, unless you face something new.

Automated tests

Tests are missing for most of methods.

Metadata

Release files for mypythonanywhere 0.1.5rc0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mypythonanywhere 0.1.5rc0
File Size Uploaded Provenance Actions
mypythonanywhere-0.1.5rc0.tar.gz 15.0 kB Without provenance Details for mypythonanywhere-0.1.5rc0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mypythonanywhere 0.1.5rc0
File Interpreter ABI Platform Actions
mypythonanywhere-0.1.5rc0-py3-none-any.whl Python 3 none any Details for mypythonanywhere-0.1.5rc0-py3-none-any.whl

Total release size: 38.0 kB

Release files / mypythonanywhere-0.1.5rc0.tar.gz

Download URL mypythonanywhere-0.1.5rc0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4f9705dec06cfa3f02fd76a760c01c61c4bef2724b9649148a5bf458c9ca3506
BLAKE2b-256 checksum
How to use checksums
16a5df5dceb7a3c879274df9ec15c3a646fdb0165fb72944565f72cac3ec2fd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Release files / mypythonanywhere-0.1.5rc0-py3-none-any.whl

Download URL mypythonanywhere-0.1.5rc0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb1e5deb474dbbfb14338c4d5acae42910b19596898e6f6f0ed42245afddb17f
BLAKE2b-256 checksum
How to use checksums
4381c1912d920aba765383021d0e4ea242798ae926e0d5958aaa8ff3b96c6110
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Security for mypythonanywhere 0.1.5rc0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page