Skip to main content

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

with open('noon_credentials_sensitive.json', 'r') as file:
credentials = json.load(file)

def create_jwt():
private_key_pem = credentials['private_key']

payload = {
"sub": credentials['key_id'],
"iat": int(time.time()),
"jti": str(uuid.uuid4())
}

token = jwt.encode(
payload,
private_key_pem,
algorithm="RS256",
)

return token

def get_authenticated_session():
session = requests.Session()
session.headers.update({'User-Agent': 'REPLACE_WITH_YOUR_USER_AGENT'})
response = session.post('https://noon-api-gateway.noon.partners/identity/public/v1/api/login', data=json.dumps({
'token': create_jwt(),
'default_project_code': credentials["project_code"]
}))
assert response.status_code == 200, response.json()
return session

# the response from above will contain the auth cookie,
# which can be used for subsequent authenticated requests
# if using an HTTP client which maintains cookies
session = get_authenticated_session()
data = session.get('https://noon-api-gateway.noon.partners/identity/v1/whoami')
assert data.status_code == 200
print('Logged in as: ' + json.dumps(data.json()))

You're authenticated. Visit the API Reference for the full list of available endpoints.