Giter Club home page Giter Club logo

zoho-crm-api-python's Introduction

zoho-crm-api-python

Overview

Zoho provides a Python SDK that can be integrated with Zoho CRM, but it seems a bit complicated. Hence, this repo shows how to set up Python for Zoho CRM and fetch Zoho CRM data with Python.

step1 Create application

2.Visit the page https://api-console.zoho.com/ and click ADD CLIENT

3.choose Server-based Application

(the easiest way to setup api)

4.fill data

Enter Client Name, Homepage URL, and Authorized Redirect URI. Click CREATE.You can fill your personal or company homepage url in these two url fields.

(Not recommended)if you don't have any url, you can fill any website you trust, maybe such as google.

5.get Client ID and Client Secret

step2 Send Authorization Request to Generate 「code」

1.visiting the specific url

https://accounts.zoho.com/oauth/v2/auth?response_type=code&client_id={your_client_id}&scope=AaaServer.profile.Read,ZohoCRM.Modules.ALL&redirect_uri={your_redirect_uri}

Make sure the scope contains"AaaServer.profile.Read". And if you have to get all zoho data, you can add the scope"ZohoCRM.Modules.ALL".

2.After visiting the url, you can see this page contains your service.

click Submitand accept

3.get authorization grant code

After you click submit and accept, you will redirect to the website you fill in the previous step.

And you have to get the authorization grant code on url(after"code=")

Warning: Authorization Grant Code Lifetime : one minute.

step3 Setting Up Python Environment

1.Install SDK

pip install zcrmsdk

2.set up config to initialize

from zcrmsdk import ZCRMRecord,ZCRMRestClient,ZohoOAuth,ZCRMModule
config =  { 'currentUserEmail':'YOUR_ZOHO_EMAIL',
            'sandbox':'False',
            'applicationLogFilePath':'./log',
            'client_id':'YOUR_CLIENT_ID',
            'client_secret':'YOUR_CLIENT_SECRET',
            'redirect_uri':'YOUR_REDIRECT_URI',
            'accounts_url':'YOUR_ACCOUNTS_URL',
            'token_persistence_path':"."}
ZCRMRestClient.initialize(config)
oauth_client = ZohoOAuth.get_client_instance()
grant_token = "Authorization_Grant_Code"
oauth_tokens = oauth_client.generate_access_token(grant_token)
print(oauth_tokens)

currentUserEmail: you have to check your zoho email

client_id and client_secret: in the previous step

redirect_uri: in the previous step

accounts_url: Based on your domain,default:https://accounts.zoho.com

Authorization_Grant_Code:in the previous step

3.create log file

You have to create a log file for saving log details. After you run the code below, the oauth.log will create in the file automatically. Also the zcrm_oauthtokens.pkl will create automatically.

step4 Fetch Zoho Data With Python

  • Get a Record by Id
record = ZCRMRecord.get_instance('Leads',id)
resp = record.get()
print(resp.data.field_data['Email'])
  • Get Module Records
module_ins = ZCRMModule.get_instance('Leads') 
resp=module_ins.get_records(page=3,per_page=100)
for records in resp.data:
    print(records)

Reference

OAuth Authentication

Zoho CRM Python SDK Doc

Zoho CRM Python SDK repo

Web Server Applications

Get Records API

zoho-crm-api-python's People

Contributors

hackmd-deploy avatar snhou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.