Contact support

Making raw API calls

Making raw API calls

Below you will find examples on how to make “raw” API calls from your Python scripts in Peliqan.

Note: Peliqan provides SaaS API wrapper functions for a wide range of SaaS applications (CRM, ERP, accounting, messaging etc). For these connectors, you do not need to make “raw” API calls. More info:Interacting with SaaS APIsInteracting with SaaS APIs

Comparison between both methods:

Peliqan SaaS API wrapper functions
Raw API calls
Authentication is automatically handled
You have to handle authentication in your script
Headers, body, querystring etc. are automatically built
You have to build up the API request: method (GET, POST…), URL, querystring, headers, body


Example on making API calls to a REST API:

import requests

# Get data

url = ""
result = requests.get(url)
st.write(results) # show result

# Post data

headers = {
	"Authorization": "Bearer " + token 

data = {
	"key": "value"

result =, json = data, headers = headers)
st.write(results) # show result

SOAP Webservice API call

Example on making an API call to a SOAP Webservice:

import requests, base64, xmltodict, json

url = ""

# See the SOAP Webservice documentation for the correct SOAP envelope to use
xml = """<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
    <GetData xmlns="http://...">

headers = {
    "Content-Type": "text/xml; charset=utf-8",
    "SOAPAction": "",
    "Authorization": "Basic " + basic_auth # see below

result_xml =, data = xml, headers = headers).text
result_dict = xmltodict.parse(result_xml)
rows = result_dict["soap:Envelope"]["soap:Body"]["GetDataResponse"]["Result"]["Rows"]


Example of using Basic Authentication:

login = 'xxx'
pw = 'xxx'
basic_auth = base64.b64encode((login + ":" + pw).encode("ascii")) .decode("ascii") 

headers = {
	"Authorization": "Basic " + basic_auth 

result = requests.get(url, headers = headers)

Example of using a JWT or token:

headers = {
	"Authorization": "Bearer " + token 

result = requests.get(url, headers = headers)