OpenEnergyPlatform / open-MaStR

A collaborative software to download the energy database Marktstammdatenregister (MaStR)
https://open-mastr.readthedocs.io/en/latest/
GNU Affero General Public License v3.0
84 stars 17 forks source link

`GetMarktakteur` not part of `soap_api.download.MaStRAPI` #479

Closed FlorianK13 closed 1 week ago

FlorianK13 commented 8 months ago

The API call GetMarktakteur, as described here cannot be called using the python wrapper.

FlorianK13 commented 8 months ago

@chrwm Do you understand why this is the case?

FlorianK13 commented 8 months ago

The error it throws is 'MaStRAPI' has no attribute GetMarktakteur

maxcave commented 3 weeks ago

I have the same problem did you find a workaround?

FlorianK13 commented 3 weeks ago

I shortly checked the following:

Unfortunately I have no time within the next weeks to dig deeper. I can investigate this later or maybe @nesnoj has some time?

maxcave commented 3 weeks ago

I have tried a workaround using zeep on my own. This is probably a bit trivial for you @FlorianK13 but could prove useful if someone is looking to access any functions not yet implemented here.

from zeep import Client
wsdl_url = 'https://www.marktstammdatenregister.de/MaStRAPI/wsdl/mastr.wsdl'
apiKey = '4fil24gnio2gno24g2...' # example add your own here
marktakteurMastrNummer = 'SNB91234567890' # example add your "username" here

client = Client(wsdl_url)
client_bind = client.bind('Marktstammdatenregister', 'Akteur')
result = client_bind.GetMarktAkteur(
    apiKey=apiKey, 
    marktakteurMastrNummer=marktakteurMastrNummer, 
    mastrNummer='SNB91234567890') # Final argument is the Akteurnummer your are requesting
print(result)

I personally still have the issue that my apiKey does not have the writes to access any but suppose that is not an implementation problem.

If you want to adapt this to other functions then you change the 'Akteur' in client.bind() to the heading under which your function is featured in the documentation and the operation you call in the following line.

nesnoj commented 2 weeks ago

Hey @maxcave,

I digged a bit and it worked out: With zeep I wasn't able to get any data ("ValueError: second must be in 0..59"), cf. #10. But with the own MaStRAPI it worked like a charm (the timing error is suppressed here)...ok, almost like a charm:

As you already state for the service

If you want to adapt this to other functions then you change the 'Akteur' in client.bind() to the heading under which your function is featured in the documentation and the operation you call in the following line.

you have to change it in open-MaStR's code as well here as it is hard-coded :thinking:. After setting it to service_port="Akteur" the function GetMarktakteur is available (you'll probably need to install from source to change..).

Working snippet:

from open_mastr.soap_api.download import MaStRAPI

apiKey = "..."   # your own key
marktakteurMastrNummer = "..."   # your own Marktakteur ID
mastr_api = MaStRAPI(user=marktakteurMastrNummer, key=apiKey)
mastr_api.GetMarktakteur(mastrNummer="SNB941690671609")  # should return data from E.DIS Netz GmbH

# Result:
# {'Ergebniscode': 'OK', 'AufrufVeraltet': False, 'AufrufLebenszeitEnde': None, 'AufrufVersion': 1, 'MastrNummer': 'SNB941690671609', ....

I personally still have the issue that my apiKey does not have the writes to access any but suppose that is not an implementation problem.

I used my personal key which has no advanced permissions..

Does this solution work at your end @maxcave?

We should remove this hard-coded "service_port" and allow to pass it as parameter. I will create a separate issue.

nesnoj commented 2 weeks ago

As #557 has been merged, you can now just use branch develop and instantiate MaStRAPI(user, key, service_port="Akteur")

nesnoj commented 1 week ago

Has been fixed, I will close.. Please reopen if necessary @maxcave