Skip to main content

I need to first extract all the data using Python from a specific board and parse it so that each item from the board is on a different line.


Here is my code->

import requests

import json


apiKey = “my api key”

apiUrl = “https://api.monday.com/v2

headers = {“Authorization” : apiKey}


query2 = ‘{boards (ids: 2257165976) { name id description items { name column_values{title id type text } } } }’

data = {‘query’ : query2}


r = requests.post(url=apiUrl, json=data, headers=headers) # make request

print(r.json())


Now, I do get all the items in the output but I’m not sure how to put each of them in different lines. Could someone please modify my code so that I get the desired output please?

Hello @rajniali and welcome to the community!


I hope you like it here 💪


I do not have experience with Python, but you might be able to find some useful information by searching for the posts related to Python in the community.


Hope you find what you are looking for 🙂


Cheers,

Matias


Hi,


I think the Python json functionality is broken, what is returned fails json formatting tests. It’s also mentioned in another post on here with the same error I see.


Best Regards,

Delos


Quite late to this thread, but I’ve found that running python vars through json.dumps usually fixes the main formatting issues


I’m going to see if I can help a little bit, and also hoping someone else may be to help me in return. I ran a “simple” query and then was able to parse the json dictionary values. This resulted in a nice pandas dataframe.


Step #2 for me is to replicate the “full” query like the OP did for a full board query in an attempt to get all the data nicely formatted in rows & columns.


Here is my simple query, with json parse code:


Setup the query we want to run:


query = ‘{ boards (limit:5) {name id} }’

data = {‘query’ : query}


Run the desired query:


r = requests.post(url=apiUrl, json=data, headers=headers) # makes request


Set the result dictionary to a variable:


json_data = r.json()


Extract key-value pairs from the nested dictionary


data_frame =

for board in json_datab‘data’] ‘boards’]:

data_frame.append({‘Board_Name’: boardp‘name’], ‘Board_Id_Num’: board‘id’]})


Convert the key-value pairs to a DataFrame


df = pd.DataFrame(data_frame)


View the DataFrame


print(df)


Sorry, some of that did not format nicely because of HTML. Will try and screenshot the parsing.


image


Reply