Developer & IMAP Guide
REST API v1 & OAuth2 Setup
Automate wholesale purchases from your funded Wallet and exchange Microsoft refresh_token credentials for IMAP / Graph access tokens.
1. Live Stock & Wallet Purchase API (/api/v1)
Current live inventory: 0 Hotmail · 0 Outlook. Authenticate private endpoints with Authorization: Bearer ms_live_...
| Method & Endpoint | Auth | Purpose |
|---|---|---|
| GET /api/v1/stock | Public | Live Hotmail / Outlook stock counts & volume price tiers |
| GET /api/v1/balance | Bearer Key | Check funded USDT wallet balance in USD & cents |
| POST /api/v1/orders | Bearer Key | Debit wallet atomically & return allocated accounts JSON immediately |
| GET /api/v1/orders/:ref | Bearer Key | Retrieve delivered email|password|refresh_token|client_id lines |
cURL Purchase Example
curl -X POST https://mailstock.shop/api/v1/orders \
-H "Authorization: Bearer ms_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{"type":"Hotmail","quantity":100}'
2. Python: Exchange Refresh Token & Read IMAP via XOAUTH2
Microsoft retired basic password IMAP auth. Parse each line as email, password, refresh_token, client_id = line.split('|') and exchange the refresh token at Microsoft's live token endpoint:
Python 3 (requests + imaplib)
import imaplib, requests
def fetch_access_token(refresh_token: str, client_id: str) -> str:
r = requests.post(
"https://login.microsoftonline.com/common/oauth2/v2.0/token",
data={
"client_id": client_id,
"refresh_token": refresh_token,
"grant_type": "refresh_token",
},
timeout=15,
)
r.raise_for_status()
return r.json()["access_token"]
def connect_imap(email: str, refresh_token: str, client_id: str):
token = fetch_access_token(refresh_token, client_id)
auth_str = f"user={email}\x01auth=Bearer {token}\x01\x01".encode()
imap = imaplib.IMAP4_SSL("outlook.office365.com", 993)
imap.authenticate("XOAUTH2", lambda _: auth_str)
imap.select("INBOX")
return imap
3. Node.js: Order + Refresh Token Helper
async function getAccessToken(refreshToken, clientId) {
const body = new URLSearchParams({
client_id: clientId,
refresh_token: refreshToken,
grant_type: 'refresh_token',
});
const res = await fetch('https://login.microsoftonline.com/common/oauth2/v2.0/token', {
method: 'POST',
body,
});
if (!res.ok) throw new Error(await res.text());
const data = await res.json();
return data.access_token;
}