bundesAPI / dip-bundestag-api

Bundestag: Dokumentations- und Informationssystem für Parlamentsmaterialien
https://dip.bundestag.api.bund.dev/
15 stars 2 forks source link

Issues with installation and usage of the package #8

Open deakkon opened 2 years ago

deakkon commented 2 years ago

Hi everyone,

thank you for wrapping the APIs with some code.

I have had several issues with the package so far; I will list them here, with the hope this will generate some interest to fix them :)

Installation via pip and usage

The instructions on the PyPI site are slightly confusing, as there are two listed ways of installing the package:

  1. pip install de-dip-bundestag
  2. pip install deutschland[dip_bundestag]

Once installed, the code example provided is not working, as the api package doesn't contain anything called _defaultapi (or an object called DefaultApi anywhere in the code).

Are the instructions for an older/different version of the package?

Installation via git clone and python -m pip install .

I also tried an alternative way, where I cloned the repo and installed it directly from the subfolder python_client via python -m pip install .

(dpp) ➜  python-client git:(main) python -m pip install .
Processing /Users/jurica/Projects/dip-bundestag-api/python-client
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: urllib3>=1.25.3 in /Users/jurica/miniconda3/envs/dpp/lib/python3.9/site-packages (from de-dip-bundestag==0.1.0) (1.26.9)
Requirement already satisfied: python-dateutil in /Users/jurica/miniconda3/envs/dpp/lib/python3.9/site-packages (from de-dip-bundestag==0.1.0) (2.8.2)
Requirement already satisfied: six>=1.5 in /Users/jurica/miniconda3/envs/dpp/lib/python3.9/site-packages (from python-dateutil->de-dip-bundestag==0.1.0) (1.12.0)
Building wheels for collected packages: de-dip-bundestag
  Building wheel for de-dip-bundestag (pyproject.toml) ... done
  Created wheel for de-dip-bundestag: filename=de_dip_bundestag-0.1.0-py3-none-any.whl size=56847 sha256=295dff258699721ec8f3c0467be513723ebc9db7d2cd3d7d90d487823627fcc9
  Stored in directory: /Users/jurica/Library/Caches/pip/wheels/4a/43/a8/4cbe73ea69d4784ba92625838fb9cf42ff5d3929831566fcfe
Successfully built de-dip-bundestag
Installing collected packages: de-dip-bundestag
Successfully installed de-dip-bundestag-0.1.0

The installation is without any issues. The provided code example in the readme.MD, in the python-client subfolder, seems to be matching the provided API.

Unfortunately, the provided example is still not working, as I keep on getting a 401, although I provided an API key, as per the instructions.

/Users/jurica/miniconda3/envs/dpp/bin/python /Users/jurica/Projects/data-processing-pipeline/policy_pipeline/bundestag.py
Exception when calling AktivitaetApi->aktivitaet: Status Code: 401
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'date': 'Tue, 12 Jul 2022 14:02:11 GMT', 'server': 'Apache', 'www-authenticate': 'apikey realm="realm"', 'content-type': 'application/json', 'content-length': '215', 'via': '1.1 search.dip.bundestag.de', 'access-control-allow-headers': 'origin, x-requested-with, content-type, authorization, content-disposition, accept', 'access-control-allow-methods': 'OPTIONS,GET,PUT,POST,DELETE,HEAD', 'access-control-allow-credentials': 'true', 'x-frame-options': 'SAMEORIGIN', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'x-permitted-cross-domain-policies': 'none', 'strict-transport-security': 'max-age=31536000'})
HTTP response body: {"code":401,"message":"An API key is required to access this service. Please refer to https://dip.bundestag.de/über-dip/hilfe/api how to apply for a key. Misuse of this service may lead to blocking your requests."}

It seems that none of the examples actually work as described/presented.

Is there anything I can do to make this work on my end?

t-huyeng commented 1 year ago

As far as I know, the examples and the readme are automatically created from the bot. Could you share a gist of how you used the example? Did you try to add a prefix to the API Key?