-
Re: Python script against the API to pull user data
pawans Nov 7, 2016 9:44 PM (in response to mpetrosky)I had writen few python 2.7 scripts for jive .
Here's my github repo --> GitHub - shahpawan/jive-python-scripts: Python scripts to perform several admin tasks on jive via jive rest apis
I have not updated this repo since several months. But most of it should still work.
-
Re: Python script against the API to pull user data
jmarc Oct 4, 2018 4:29 AM (in response to pawans)Hi Pawan,
I need to export my community and your scrpit would be a good starting point for me.
Could you pls give me a little bit of information about how to use it.
Running python JiveScripts.py does not produce any output.
Regards, JM
-
-
Re: Python script against the API to pull user data
parasg Nov 8, 2016 4:35 AM (in response to mpetrosky)2 people found this helpfulYour code was working fine.
When we were using the same API to pull user data, there were some missing records instead of duplicate ones. Sometimes API returns 24 records instead of 25.
I think that might be issue with Jive API.
There are few alterations done in the code below.
- Instead of incrementing the "startIndex" value, Jive JSON returns "next" fields in "link" which contains the next API url which can be used to pull next page data.
import requests, base64, csv, json # jive api pagination variables startIndex = 0 itemsPerPage = 25 # jive api username username = 'blablabla' password = 'blablabla' headers = {'Authorization': 'basicAuthKey'} url = 'https://community.community.com/api/core/v3/people?filter=include-disabled' with open('c:\users\xxx\documents\y_points.csv', 'wb') as csvfile: writer = csv.writer(csvfile, delimiter=',') while True: rest_data = requests.get(url, auth=(username, password), headers=headers) # convert the return into a json blob blob = rest_data.json() # parse the blob to pull out users and points for x in blob['list']: # points = (('level' in x['jive']) and ('points' in x['jive']['level']) and x['jive']['level']['points']) or '--' points = x['jive']['level']['points'] name = x['displayName'] user_id = x['jive']['username'] #write the values to the csv file writer.writerow([name.encode('utf-8'), str(points), user_id.encode("utf-8")]) # test to see if we've reached the end of the query if ('links' in blob) and ('next' in blob['links']): url = blob['links']['next']; else: break;