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 PyPI:

pip install kopeechka

Usage

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

from kopeechka import MailActivations

body = MailActivations(token="TOKEN")

Exception handling

You can import all exceptions from kopeechka.errors

List of all exceptions with description:

ACTIVATION_CANCELED - The mail was canceled.
ACTIVATION_NOT_FOUND - First letter has not been received, reorder isn't possible.
BAD_BALANCE - There are not enough funds to perform the operation.
BAD_COMMENT - Activattion not found (It's not your activation).
BAD_DOMAIN - We do not have such a domain/domain zone.
BAD_EMAIL - Mail was banned.
BAD_SITE - You specified the site incorrectly.
BAD_TOKEN - Invalid token.
NO_ACTIVATION - Invalid TASK_ID activation.
OUT_OF_STOCK - There is no mail with such settings. Try changing MAIL_TYPE or write to support - we'll try to add mailboxes.
SYSTEM_ERROR - Unknown, system error. Contact support - we will help!
TIME_LIMIT_EXCEED - The limit of mail orders per second has been reached (applies to special tariffs), it is necessary to expand the tariff.
WAIT_LINK - The letter hasn't arrived yet.
UNKNOWN ERROR - Unknown error (the text of the exception may be different in different situations.)

Types

You can import all types from kopeechka.types_kopeechka

Methods

You can import all methods from kopeechka.methods

Sync example

from kopeechka import MailActivations

body = MailActivations(token="TOKEN")

#balance request
try:
    data = body.user_balance()
    print(data.data) # returns a dictionary with data from json
    print(data.balance) # returns a user balance
    print(data.status) # returns a response status
except Exception as e:
    print(e) # returns a string with an error
    print(e.data) # returns the data received by api Kopeechka

#mail request
try:
    data = body.mailbox_get_email(site="site", mail_type="mail_type", sender="sender", regex="regex", soft_id=0, investor=0, subject="subject")
    print(data.data) # returns a dictionary with data from json
    print(data.status) # returns a response status
    print(data.id) # returns a task_id this mail
    print(data.mail) #returns a email address
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#letter request
try:
    data = body.mailbox_get_message(full=0, id=123)
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
    print(data.value) # returns a url
    print(data.fullmessage) # returns a full message from email
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#cancel mail
try:
    data = body.mailbox_cancel(id=123)
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#reorder mail
try:
    data = body.mailbox_reorder(site="site", email="email", regex="regex", subject="subject")
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
    print(data.id)  # returns a task_id this mail
    print(data.mail)  # returns a email address
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#find ID activation of email
try:
    data = body.mailbox_get_fresh_id(site="site", email="email")
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
    print(data.id)  # returns a task_id this mail
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#set a comment to the ordered mail
try:
    data = body.mailbox_set_comment(id=123, comment="comment")
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#mail search by parameters
try:
    data = body.mailbox_get_bulk(count=1, comment="comment", email="email", site="site")
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
    print(data.count) # returns a count of items
    print(data.items) # returns a list with found data
    for item in data.items:
        print(item.data) # returns a dictionary with data from json
        print(item.id) # returns a task_id
        print(item.service) # returns a service
        print(item.email) # returns a email
        print(item.date) # returns a date
        print(item.status) # returns a status
        print(item.value) # returns a link
        print(item.comment) # returns a comment
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#list of all service domains
try:
    data = body.mailbox_get_domains(site="site")
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
    print(data.count) # returns a count of items
    print(data.domains) # returns a list with domains
except Exception as e:
    print(e)  # returns a string with an error
    print(e.data)  # returns the data received by api Kopeechka

#get prices and zones
data = body.mailbox_zones(popular=1, zones=1)
print(data.data)  # returns a dictionary with data from json
print(data.status)  # returns a response status
print(data.popular) # returns a list with populars
for item in data.popular:
    print(item.data) # returns a dictionary with data from json
    print(item.name) # returns a name
    print(item.count) # returns a count
    print(item.cost) # returns a cost
print(data.zones) # returns a list with zones
for item in data.zones:
    print(item.data) # returns a dictionary with data from json
    print(item.name) # returns a name
    print(item.cost) # returns a cost

Async methods

You can import all async methods from kopeechka.async_methods

Async example

from kopeechka import AsyncMailActivations
import asyncio

async def main():

    body = AsyncMailActivations('TOKEN')

    # balance request
    try:
        data = await body.user_balance()
        print(data.data)  # returns a dictionary with data from json
        print(data.balance)  # returns a user balance
        print(data.status)  # returns a response status
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # mail request
    try:
        data = await body.mailbox_get_email(site="site", mail_type="mail_type", sender="sender", regex="regex", soft_id=0,
                                      investor=0, subject="subject")
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
        print(data.id)  # returns a task_id this mail
        print(data.mail)  # returns a email address
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # letter request
    try:
        data = await body.mailbox_get_message(full=0, id=123)
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
        print(data.value)  # returns a url
        print(data.fullmessage)  # returns a full message from email
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # cancel mail
    try:
        data = await body.mailbox_cancel(id=123)
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # reorder mail
    try:
        data = await body.mailbox_reorder(site="site", email="email", regex="regex", subject="subject")
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
        print(data.id)  # returns a task_id this mail
        print(data.mail)  # returns a email address
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # find ID activation of email
    try:
        data = await body.mailbox_get_fresh_id(site="site", email="email")
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
        print(data.id)  # returns a task_id this mail
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # set a comment to the ordered mail
    try:
        data = await body.mailbox_set_comment(id=123, comment="comment")
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # mail search by parameters
    try:
        data = await body.mailbox_get_bulk(count=1, comment="comment", email="email", site="site")
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
        print(data.count)  # returns a count of items
        print(data.items)  # returns a list with found data
        for item in data.items:
            print(item.data)  # returns a dictionary with data from json
            print(item.id)  # returns a task_id
            print(item.service)  # returns a service
            print(item.email)  # returns a email
            print(item.date)  # returns a date
            print(item.status)  # returns a status
            print(item.value)  # returns a link
            print(item.comment)  # returns a comment
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # list of all service domains
    try:
        data = await body.mailbox_get_domains(site="site")
        print(data.data)  # returns a dictionary with data from json
        print(data.status)  # returns a response status
        print(data.count)  # returns a count of items
        print(data.domains)  # returns a list with domains
    except Exception as e:
        print(e)  # returns a string with an error
        print(e.data)  # returns the data received by api Kopeechka

    # get prices and zones
    data = await body.mailbox_zones(popular=1, zones=1)
    print(data.data)  # returns a dictionary with data from json
    print(data.status)  # returns a response status
    print(data.popular)  # returns a list with populars
    for item in data.popular:
        print(item.data)  # returns a dictionary with data from json
        print(item.name)  # returns a name
        print(item.count)  # returns a count
        print(item.cost)  # returns a cost
    print(data.zones)  # returns a list with zones
    for item in data.zones:
        print(item.data)  # returns a dictionary with data from json
        print(item.name)  # returns a name
        print(item.cost)  # returns a cost

loop = asyncio.new_event_loop()
loop.run_until_complete(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-5.tar.gz (4.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: kopeechka-5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.0

File hashes

Hashes for kopeechka-5.tar.gz
Algorithm Hash digest
SHA256 b59ddc2b815f00225bb5c14be60406841dfe13862de95b87c6bd08089bfebb49
MD5 757bbb894fcdb6239528bf74e5faa7bd
BLAKE2b-256 e59eb0502c0842b19c861fdfaa8f294b5c8ab394980cf29d05f16c89d0b29d9f

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