Welcome To Mam Zdanie API documentation. Here you will find a complete methods documentation with examples as well.
In order to call a specific API Method, you need to understand few things:
BASE_URL?AUTH&METHOD&OPTIONS
where:
Example API call should look like:
https://mamzdanie.org.pl/api/service?api_key=b3hf7jnms23hase8902uiosw6hj7445f&method=get_consultations&active=true
In order to use Mam Zdanie API you need to be registered as an organization. To be specific:
Then, after you log-in, please click on your profile page (Twój profil), and at the bottom of the page, you will find your API KEY (Twój kod autoryzacyjny API).
When invoking Mam Zdanie API methods you will be returned with an XML response which is one of the following:
correct response - each method has it’s own correct XML response. For example get_consultations method XML response looks like:
<consultations>
<consultation>
<id>18855</id>
<signature>ACTA-komentarz2012</signature>
<subject>komentarz MAC do umowy ACTA</subject>
<dateFrom>21-02-2012 00:00</dateFrom>
<dateTo>22-03-2012 00:00</dateTo>
<userName>Malgorzata Steiner</userName>
<userId>18043</userId>
<replies>13</replies>
<url>http://mamzdanie.org.pl/web/guest/konsultacje/-/message_boards/message/18855</url>
<active>true</active>
<organizationId>18049</organizationId>
<organizationName>Ministerstwo Administracji i Cyfryzacji</organizationName>
</consultation>
</consultations>
error response - if an error occurs, an error XML is returned:
<error>
<errorDate>20-03-2012 10:57:37</errorDate>
<errorCode>107</errorCode>
<errorMsg>Niepoprawny parametr method</errorMsg>
</error>
Each error response consists of:
Here is a complete list of error codes:
Here is a complete list of API Methods:
This simple example written in Python shows how to get all active consultations:
#
# Copyright (C) 2012 Pretius Sp. z o.o.
#
# Author: Robert Olejnik <rolejnik@pretius.com>
#
# This simple example shows how to display all active consultations
from lxml import etree
import requests
MZ_BASE_URL = "https://mamzdanie.org.pl/api/service"
MZ_API_KEY = "b7f2a21c345317ec23452359sla2aa08"
MZ_URL = MZ_BASE_URL + "?api_key=" + MZ_API_KEY + "&method="
method = "get_consultations&active=true"
r = requests.get(MZ_URL + method)
consultations = r.content
root = etree.fromstring(consultations)
if root.tag != "error":
for consultation in root:
print "Consultation:"
for atr in consultation:
print " - %s: %s" % (atr.tag, atr.text)
else:
print "[ERROR] We have occurred an error:"
print "[ERROR] Code: %s" % root[1].text
print "[ERROR] Description: %s" % root[2].text
Successful result should be as follows:
teon> python mamzdanie-active_consultations.py
Consultation:
- id: 18855
- signature: ACTA-komentarz2012
- subject: komentarz MAC do umowy ACTA
- dateFrom: 21-02-2012 00:00
- dateTo: 22-03-2012 00:00
- userName: Malgorzata Steiner
- userId: 18043
- replies: 13
- url: http://mamzdanie.org.pl/web/guest/konsultacje/-/message_boards/message/18855
- active: true
- organizationId: 18049
- organizationName: Ministerstwo Administracji i Cyfryzacji
And if an error occurs:
teon> python mamzdanie-active_consultations.py
[ERROR] We have occurred an error:
[ERROR] Code: 102
[ERROR] Description: Niepoprawny klucz