Fetch data from a specific column of a board using python

I have the following code in Python->
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())

This code displays everything (all the items) from a specific board but doesn’t always return the values of a column. How could I fix that? Also, I don’t want to fetch data from every column, I want to fetch data from a specific column. Could someone please modify my code in order to do so?

dude trust me, do pip install monday in the terminal
then do from monday import MondayClient

this is going to save you so much time

GitHub - ProdPerfect/monday: Python client for Monday.com documentation here

What do you mean it doesn’t return all the values of a column? Can you show the example?

You can use the library I shared above to get the column id (or through enabling dev mode and getting the col_id), then use a different function with the column id to fetch from that specific function

Here’s a snippet

client = MondayClient(apiKey)
ret = client .boards.fetch_columns_by_board_id(board_id) # you also have to know the board id which is in the url 
##Parse ret['data']['boards'][0]['columns'] for the column id
 ret=mPT.boards.fetch_items_by_board_id(1684237949)
#now parse ret using the column id for the col values you are looking for, you can use list comprehension here  for example 
 arr = client.boards.fetch_items_by_board_id(board)
 names = [item['name'] for item in [item for item in arr['data']['boards'][0]["items"]]]
#will give you the names of the items, play with it a bit