Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API calls documentation is nowhere to be found #34

Open
ShellCode33 opened this issue Dec 3, 2021 · 7 comments
Open

API calls documentation is nowhere to be found #34

ShellCode33 opened this issue Dec 3, 2021 · 7 comments

Comments

@ShellCode33
Copy link

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
Copy link

Nllii commented May 1, 2022

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
Copy link

there is no ProtonDrive implementation right? thanks

@pcroland
Copy link

pcroland commented Jan 4, 2023

Why is this example not in the readme?

@twintersx
Copy link

twintersx commented Feb 22, 2024

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
Copy link

CaffeineLab commented Apr 24, 2024

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

@pezhore
Copy link

pezhore commented Nov 8, 2024

@Nllii has the closest to a working example I've found - but does anyone else have a working endpoint for the session start? I'm not sure what the updated url should be. This guess doesn't seem to be working:

proton_session = Session(
    'https://mail.proton.me',
    os.path.join(cwd, "logs"),
    os.path.join(cwd, "cache"),
    tls_pinning=False,
)

@akshualy
Copy link

@pezhore The "officially" used API URL is now https://mail.proton.me/api. The endpoints, versions or data structure did not change since then to get conversations and their content. Another thing, the newest Session class does not accept a logs and cache folder from what I can see, so you'll want to remove those arguments.

proton_session = Session(
    api_url="https://mail.proton.me/api",
    TLSPinning=False,
)
proton_session.authenticate("em@il", "password")
conversations = proton_session.api_request("/mail/v4/conversations")
...

TLSPinning=False is unfortunately required until PR 47 is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants