Python 2.7 and httplib

import sys
import httplib
import base64

URL = "get1.spirilookup.spirius.com"
PORT = 54011
CREDENTIALS = base64.b64encode("Username:Password")

def lookup(service, msisdn):
  try:
  h = httplib.HTTPSConnection(URL, PORT, timeout=60)
  query = "/v1/lookup/%s/%s" % (service, msisdn)
  h.putrequest("GET", query)
  h.putheader("Accept", "text/plain")
  h.putheader("Authorization", "Basic " + CREDENTIALS)
  h.endheaders()
    
  r = h.getresponse()
    
  if (r.status != 200):
    return ("%d %s") % (r.status, r.reason)
    
  return  r.read()
    
  except Exception, e:
  sys.stderr.write(str(e))
      
  finally:
  if h is not None:
    h.close()
      
print lookup("sweden", "46731290000")

Python 3 and requests

import requests
URL = "https://get.spirilookup.spirius.com"
PORT = "54011"
USER = "Username"
PASS = "Password"



def lookup(service, msisdn):
    path = f"/v1/lookup/{service}/{msisdn}"
    r = requests.get(
        f"{URL}:{PORT}{path}",
        headers={"Accept": "text/plain"},
        auth=(USER, PASS),
        verify=False
    )
    return r.text


print(lookup("sweden", "46731290000"))
print(lookup("basic", "46731290000"))