A simple program
Hint
Let’s create a simple program that retrieve Dossier’s states for each Dossier in the Demarche
Creating the Profile object
To begin, you need to create a Profile object that contains api token and manage connection with Demarches Simplifées, all objets in this package contains a reference to a Profile object.
1from demarches_simpy import Profile, Demarche, Dossier
2
3# Create a profile
4profile = Profile('API_KEY', verbose=True)
5
Note
You can set verbose to True to display all debug messages. Moreover you can trigger verbose all by running your python programm with the -v option.
Creating the Demarche object
Now you can create a Demarche object that contains all information about a Demarche.
1# Create a demarche
2demarche = Demarche(000000, profile, verbose=False)
Replace the 00000 by the demarche number you want to retrieve. To know this demarche number you need to the Démarches Simplifiées website, and be sure that your API token scope contains the demarche you want to retrieve. [1]
Note
You can also locate the verbose option to a specific object to get log only from this object and its children.
Getting Dossiers
Then you can use the function get_dossiers() to retrieve all Dossier from the Demarche object :
1
2for dossier in demarche.get_dossiers():
3 print(dossier.get_dossier_state())
The get_dossiers() function return a list of Dossier object, each Dossier object contains all information about a Dossier.
The complete exemple :
1from demarches_simpy import Profile, Demarche, Dossier
2
3# Create a profile
4profile = Profile('API_KEY', verbose=True)
5
6# Create a demarche
7demarche = Demarche(000000, profile, verbose=False)
8
9for dossier in demarche.get_dossiers():
10 print(dossier.get_dossier_state())