Convert API authorization using Python

In order to use Convert's API, developers would first need to connect and authorize themselves. The code below is an example of how this can be done using Python.

from datetime import datetime
import hmac
import hashlib
import base64
import requests
import binascii

ApplicationID = 'AAAAAAA'; #Replace it with your APP ID
ApplicationSecretKey = 'SSSSSSS'; #Replace it with your APP SECRET KEY

Expires = 30; # In seconds. Request lifetime. If your requests take much time, try to increase this value

RequestURL = "";
RequestBody = '';

ExpiresTimestamp = int( + Expires;

SignString = ApplicationID + "\n" + str(ExpiresTimestamp) + "\n" +RequestURL + "\n" +RequestBody;

message = bytes(SignString, 'utf-8')
secret = bytes(ApplicationSecretKey, 'utf-8')

signature = str(binascii.hexlify(, message, digestmod=hashlib.sha256).digest()),'ascii')
Authorization = "Convert-HMAC-SHA256 Signature=" + signature;

headers={"Expires": ExpiresTimestamp, "Convert-Authorization": Authorization, "Convert-Application-ID": ApplicationID}
r = requests.get(RequestURL,headers=headers)



Need assistance? Start a conversation with our Support Team.

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features


  • Avatar
    Eugene Pyvovarov

    there are few errors in this sample code:
    1) RequestURL = ""; should be api not app
    2) "Convert-Authorization" in the header should be just "Authorization"
    3) headers={"Expires": ExpiresTimestamp - here you should change ExpiresTimestamp to str(ExpiresTimestamp)