Skip to main content

This code is a representation of the kopeechka.store API in Python

Project description

kopeechka

kopeechka - This module is a representation of the kopeechka.store API in Python

API documentation RUS https://link.kopeechka.store/CzXxp6?lang=ru&k=API

API documentation ENG https://link.kopeechka.store/CzXxp6?lang=en&k=API

Installation

Install the current version with pip:

pip install kopeechka

Usage

You can get a token in your personal account on the kopeechka.store website

from kopeechka import MailActivations

api = MailActivations(api_token="TOKEN")

Logger

In version 8.0 there's no longer. We've decide to delete it, because it was useless

Exception handling

You can import KopeechkaApiError to catch errors To catching timeout error import TimeOut

Example:

from kopeechka import KopeechkaApiError, MailActivations, TimeOut

api = MailActivations(api_token="WRONG_TOKEN")

try:
    api.user_balance()
except KopeechkaApiError as e:
    print(e) # -> BAD_TOKEN
except TimeOut as e:
    print(e) # -> If it timed out, it return "Timed out"

Types

You can import all types from kopeechka or kopeechka.kopeechka_types

Sync methods

You can import class to work with methods from kopeechka

from kopeechka import Methods

api = Methods(api_token="TOKEN")

Sync example

from kopeechka import MailActivations, KopeechkaApiError

api = MailActivations("TOKEN")


def main():
    try:
        ans_1 = api.user_balance()
        print(ans_1)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_2 = api.mailbox_get_email("vk.com")
        print(ans_2)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_3 = api.mailbox_get_message(ans_2.id, 1)
        print(ans_3)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_4 = api.mailbox_cancel(ans_2.id)
        print(ans_4)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_5 = api.mailbox_reorder("vk.com", ans_2.mail)
        print(ans_5)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_6 = api.mailbox_get_fresh_id("vk.com", ans_2.mail)
        print(ans_6)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_7 = api.mailbox_get_domains()
        print(ans_7)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_8 = api.mailbox_zones(1, 1)
        print(ans_8)
    except KopeechkaApiError as e:
        print(e)


if __name__ == '__main__':
    main()

Async methods

You can import class to work with async methods from kopeechka

from kopeechka import AsyncMethods

api = AsyncMethods(api_token="TOKEN")

Async example

from kopeechka import AsyncMailActivations, KopeechkaApiError
import asyncio

api = AsyncMailActivations("TOKEN")


async def main():
    try:
        ans_1 = await api.user_balance()
        print(ans_1)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_2 = await api.mailbox_get_email("vk.com")
        print(ans_2)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_3 = await api.mailbox_get_message(ans_2.id, 1)
        print(ans_3)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_4 = await api.mailbox_cancel(ans_2.id)
        print(ans_4)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_5 = await api.mailbox_reorder("vk.com", ans_2.mail)
        print(ans_5)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_6 = await api.mailbox_get_fresh_id("vk.com", ans_2.mail)
        print(ans_6)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_7 = await api.mailbox_get_domains()
        print(ans_7)
    except KopeechkaApiError as e:
        print(e)

    try:
        ans_8 = await api.mailbox_zones(1, 1)
        print(ans_8)
    except KopeechkaApiError as e:
        print(e)


if __name__ == '__main__':
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kopeechka-8.0.tar.gz (5.4 kB view details)

Uploaded Source

File details

Details for the file kopeechka-8.0.tar.gz.

File metadata

  • Download URL: kopeechka-8.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for kopeechka-8.0.tar.gz
Algorithm Hash digest
SHA256 351ae203a9c30fcede734246c33b44cc13fe46647d5aec6d4be49eff4baecc60
MD5 546b1fd2ee1c775113666bb414eed19c
BLAKE2b-256 78d63741f5b68267132ce5fdbec077e7cc13ee97b52d2b62bdbeedd3a2e41530

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page