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")
Exception handling
You can import KopeechkaApiError to catch errors
Example:
from kopeechka import KopeechkaApiError, MailActivations
api = MailActivations(api_token="WRONG_TOKEN")
try:
api.user_balance()
except KopeechkaApiError as e:
print(e) # -> BAD_TOKEN
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("vk.com")
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("vk.com")
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.