Package: kopeechka
kopeechkakopeechka- This module is a representation of the kopeechka.store API in PythonAPI documentation RUShttps://link.kopeechka.store/CzXxp6?lang=ru&k=APIAPI documentation ENGhttps://link.kopeechka.store/CzXxp6?lang=en&k=APIInstallationInstall the current version with pip:pip install kopeechkaUsageYou can get a token in your personal account on the kopeechka.store websitefromkopeechkaimportMailActivationsapi=MailActivations(api_token="TOKEN")LoggerYou can set logger with your settingsfromkopeechkaimportLogger,MailActivationsnew_logger=Logger()# In the arguments you can set the settingsapi=MailActivations(api_token="TOKEN",logger=new_logger)You also can disable a loggerimportlogginglogger=logging.getLogger("kopeechka")logger.setLevel(logging.CRITICAL+1)Exception handlingYou can import KopeechkaApiError to catch errors
To catching timeout error import TimeOutExample:fromkopeechkaimportKopeechkaApiError,MailActivations,TimeOutapi=MailActivations(api_token="WRONG_TOKEN")try:api.user_balance()exceptKopeechkaApiErrorase:print(e)# -> BAD_TOKENexceptTimeOutase:print(e)# -> If it timed out, it return "Timed out"TypesYou can import all types from kopeechka or kopeechka.kopeechka_typesSync methodsYou can import class to work with methods from kopeechkafromkopeechkaimportMethodsapi=Methods(api_token="TOKEN")Sync examplefromkopeechkaimportMailActivations,KopeechkaApiErrorapi=MailActivations("TOKEN")defmain():try:ans_1=api.user_balance()print(ans_1)exceptKopeechkaApiErrorase:print(e)try:ans_2=api.mailbox_get_email("vk.com")print(ans_2)exceptKopeechkaApiErrorase:print(e)try:ans_3=api.mailbox_get_message(ans_2.id,1)print(ans_3)exceptKopeechkaApiErrorase:print(e)try:ans_4=api.mailbox_cancel(ans_2.id)print(ans_4)exceptKopeechkaApiErrorase:print(e)try:ans_5=api.mailbox_reorder("vk.com",ans_2.mail)print(ans_5)exceptKopeechkaApiErrorase:print(e)try:ans_6=api.mailbox_get_fresh_id("vk.com",ans_2.mail)print(ans_6)exceptKopeechkaApiErrorase:print(e)try:ans_7=api.mailbox_get_domains("vk.com")print(ans_7)exceptKopeechkaApiErrorase:print(e)try:ans_8=api.mailbox_zones(1,1)print(ans_8)exceptKopeechkaApiErrorase:print(e)if__name__=='__main__':main()Async methodsYou can import class to work with async methods from kopeechkafromkopeechkaimportAsyncMethodsapi=AsyncMethods(api_token="TOKEN")Async examplefromkopeechkaimportAsyncMailActivations,KopeechkaApiErrorimportasyncioapi=AsyncMailActivations("TOKEN")asyncdefmain():try:ans_1=awaitapi.user_balance()print(ans_1)exceptKopeechkaApiErrorase:print(e)try:ans_2=awaitapi.mailbox_get_email("vk.com")print(ans_2)exceptKopeechkaApiErrorase:print(e)try:ans_3=awaitapi.mailbox_get_message(ans_2.id,1)print(ans_3)exceptKopeechkaApiErrorase:print(e)try:ans_4=awaitapi.mailbox_cancel(ans_2.id)print(ans_4)exceptKopeechkaApiErrorase:print(e)try:ans_5=awaitapi.mailbox_reorder("vk.com",ans_2.mail)print(ans_5)exceptKopeechkaApiErrorase:print(e)try:ans_6=awaitapi.mailbox_get_fresh_id("vk.com",ans_2.mail)print(ans_6)exceptKopeechkaApiErrorase:print(e)try:ans_7=awaitapi.mailbox_get_domains("vk.com")print(ans_7)exceptKopeechkaApiErrorase:print(e)try:ans_8=awaitapi.mailbox_zones(1,1)print(ans_8)exceptKopeechkaApiErrorase:print(e)if__name__=='__main__':asyncio.run(main())