This tutorial help to access Marketo API using python.I will use python 3 with flask micro-framework.The Marketo’s provides powerful Rest API to access his resource.

Marketo’s(Powered By Adobe) is a powerful marketing automation software helps marketers master the art & science of digital marketing to engage customers and prospects.

How To Consume Marketo Example Using Python

Marketo exposes a REST API which allows for remote execution of many resources.These APIs generally fall into two broad categories: Lead Database, and Asset.Lead Database APIs allow for retrieval of, and interaction with Marketo person records and associated object types such as Opportunities and Companies. Asset APIs allow interaction with marketing collateral and workflow-related records.

  • Daily Quota: Most subscriptions are allocated 50,000 API calls per day (which resets daily at 12:00AM CST). You can increase your daily quota through your account manager.
  • Rate Limit: API access per instance limited to 100 calls per 20 seconds.
  • Concurrency Limit: Maximum of 10 concurrent API calls.

The Marketo rest api call allows URI length of 8KB and body size of 1MB. The api return a status code of 200 OK, even its failed and contains “success” member with a value of false with message into “errors” member.


  • API User – Must be registered with Marketo. You can get more information from official documents.
  • API token – You will get access_token after successfully registered api user with Marketo..
  • The Base URI – You will get after successfully registered api user with Marketo..
  • marketo-rest-python – A Python Client for the Marketo REST API.

Create Python Environment

We will create python enviornment using python and pip package.

Check Python Version

We will check python and pip version using following command –

python --version
pip --version

The python version must be > 3+.

How To Install flask and marketorestpython Package

We will create /hello-api folder and cd into this folder, Now install python flask framework and marketorestpython package using below command :-

pip install flask
pip install marketorestpython

Created a new file into /hello-api folder.

How To Consume HTTP GET Request

We will consume Marketo API using python marketorestpython package, I will pass base url, client id and token to request client.Let’s add below code into /hello-api/ fi;e

from flask import Flask
from flask_restful import Resource, Api
from flask_cors import CORS
import requests
from marketorestpython.client import MarketoClient
app = Flask(__name__)
CORS(app) ## To allow direct AJAX calls
@app.route('/employee', methods=['GET'])
def home():
munchkin_id = "" # fill in Munchkin ID, typical format 000-AAA-000/base host name
client_id = "" # enter Client ID from Admin > LaunchPoint > View Details
client_secret= "" # enter Client ID and Secret from Admin > LaunchPoint > View Details
mc = MarketoClient(munchkin_id, client_id, client_secret, api_limit, max_retry_time)
lead = mc.execute(method='get_lead_by_id', id=3482141, fields=['firstName', 'middleName', 'lastName', 'department'])
return r.json()
if __name__ == '__main__': = True)

We have created client and access lead information using GET call.

Genislab Technologies

NexGeneration complete end-2-end software testing & modern development operations tooling & solutions

Do you want to discuss your testing requirements with us? please don’t hesitate to hit the contact us button below, and we will get back to you at our earliest..