View ProjeQtOr On SourceForge.net
ProjeQtOr - Project Management Tool
Support us on Capterra
OIN - Open Invention Network
ProjeQtOr free project management software - Getting data with the API using Python - ProjeQtOr
 
 

Getting data with the API using Python

More
28 Feb 2022 11:49 #1 by bgenolini
Hello,
I have tetsed a simple way to get data from the API with Python.
I'm working under Windows 10, with Anaconda, Python 3.9.7
This is quick and dirty code I have validated after validating the settings of the server with a colleague of mine.

Cheers

import requests
import pandas as pd

SERVER="your.server.here"
URL=f"http://{SERVER}/api"
MY_AUTH = ('user', 'password')

def GetData(req):
    # Returns a dictionnary structure form the request "req"
    return requests.get(f"{URL}/{req}", auth = MY_AUTH).json()

def GetDataPd(req):
   # Converts into a panda DataFrame
    return pd.DataFrame.from_dict(GetData(req))

if __name__ == '__main__':
   # Get the list of projects and print the names and parent's name of non closed projects
    projs = GetDataPd("Project/all")
    print(projs[projs != 'closed']'name', 'nameProject')
 

Bernard

Please Log in or Create an account to join the conversation.

Moderators: babynusprotion
Time to create page: 0.025 seconds

Cookies settings

×

Functional Cookies

Ce site utilise des cookies pour assurer son bon fonctionnement et ne peuvent pas être désactivés de nos systèmes. Nous ne les utilisons pas à des fins publicitaires. Si ces cookies sont bloqués, certaines parties du site ne pourront pas fonctionner.

Session

Please login to see yours activities!

Other cookies

Ce site web utilise un certain nombre de cookies pour gérer, par exemple, les sessions utilisateurs.