Skip to main content
View as Markdown

Quick Start

You need a noon Partner account to follow this guide. If you don't have one yet, check noon's Partner onboarding process.

1. Get your credentials​

  1. Open the Access App
  2. Click Add Service Account, fill in a display name, username, and role, then click Add
  3. A .json key file will download — this is your credential file:
Keep this file secure

Never commit your .json credential file to source control. It contains your private key.

For the full walkthrough see Getting Your Credentials.

2. Authenticate​

Use your .json file to generate a JWT and exchange it for a session cookie. All subsequent API requests use that cookie.

Required header

All API requests must include a User-Agent header identifying your application. Requests without it may be rejected.

import json
import time
import uuid
import jwt
import requests

BASE_URL = "https://noon-api-gateway.noon.partners"
USER_AGENT = "NoonApiClient/1.0"

with open("noon_credentials_sensitive.json", "r", encoding="utf-8") as file:
credentials = json.load(file)

# Create a signed RS256 JWT for the login request.
def create_jwt():
return jwt.encode(
{
"sub": credentials["key_id"],
# iat must be current Unix time in seconds; do not apply a timezone offset.
"iat": int(time.time()),
"jti": str(uuid.uuid4()),
},
credentials["private_key"],
algorithm="RS256",
)

# Log in and return a requests session that keeps auth cookies.
def get_authenticated_session():
session = requests.Session()
session.headers.update({"User-Agent": USER_AGENT})

response = session.post(
f"{BASE_URL}/identity/public/v1/api/login",
json={
"token": create_jwt(),
"default_project_code": credentials["project_code"],
},
)
if response.status_code != 200:
raise Exception(f"Login failed with HTTP {response.status_code}: {response.text}")

return session

# Example authenticated request.
session = get_authenticated_session()

response = session.get(f"{BASE_URL}/identity/v1/whoami")

if response.status_code != 200:
raise Exception(f"Whoami failed with HTTP {response.status_code}: {response.text}")

print("Logged in as:", response.json())

You're authenticated. Where you go next depends on what you're building:

Ask AI about this page
Get an explanation, examples, or a summary of this doc.