ProtonMail / proton-python-client

Python Proton client module
GNU General Public License v3.0
343 stars 62 forks source link

API calls documentation is nowhere to be found #34

Open ShellCode33 opened 2 years ago

ShellCode33 commented 2 years ago

Hey, thanks for this Python module, but I'm not sure I get it...

You provide Python code, talk about APIs, but you don't give a single API endpoint ? Is this repo for internal tooling purposes or do you plan to document the API at some point ?

Nllii commented 2 years ago

You provide Python code, talk about APIs, but you don't give a single API endpoint ? Is this repo for internal tooling purposes or do you plan to document the API at some point ?

This is a just a fancy http module to save you time in reverse engineering. I have provided a starting point incase anyone from google comes here. You can get the endpoints simply by looking at the traffic.

from proton_python_client import proton
from proton_python_client.proton.api import Session
from proton_python_client.proton.exceptions import ProtonError
import os 
import pprint 

cwd = os.getcwd()
__allow_alternative_routing__= True

proton_session = Session(
    'https://api.protonmail.ch',
    os.path.join(cwd, "logs"),
    os.path.join(cwd, "cache"),

    tls_pinning=False,

)

proton_session.enable_alternative_routing = False
proton_session.authenticate(username= "admin", password ="🧑🎨🎨")

def getMails():
   info_response = proton_session.api_request("/mail/v4/conversations")
   for conversation in info_response['Conversations']:
       get_email_id = conversation['ID']
       get_email_content= proton_session.api_request("/mail/v4/conversations/" + get_email_id)
       pprint.pprint(get_email_content)
dademiller360 commented 1 year ago

there is no ProtonDrive implementation right? thanks

pcroland commented 1 year ago

Why is this example not in the readme?

twintersx commented 6 months ago

This worked for me, thank you!

Do you know how I can decode the email body properly?

decoded_body = base64.b64decode(body).decode('utf-8')

Returns garbage.

CaffeineLab commented 4 months ago

I had to make this change:

from proton.api import Session
from proton.exceptions import ProtonError

from proton_python_client import proton from proton_python_client.proton.api import Session from proton_python_client.proton.exceptions import ProtonError