Get all users using the API

I am trying to get all users from monday using the API v2.

This query below displays all users with the details specified on the query:

query {
  users{
    id
    name
    email
  }
}

So now I’m trying the below request from a python script:

            headers = {"Authorization" : config['api_key']}
            apiUrl = "https://api.monday.com/v2"

            query = {"query": "users { id email }"}

            res = r.post(url=apiUrl, json=query, headers=headers)

            res_data = res.json()

I ma getting the following error:

{'errors': [{'message': 'Parse error on "users" (IDENTIFIER) at [1, 1]', 'locations': [{'line': 1, 'column': 1}]}], 'account_id': 9415663}

Please help, what am I doing wrong?

Hello @mxolisi,

Have you looked into moncli?

You can retrieve users with the following code:

from moncli import client

client.api_key = 'API_KEY'
users = client.get_users('id', 'name', 'email')

Please let me know if you have any questions.

Thanks and happy coding!

1 Like

Thanks Andrew,

This worked.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.