Skip to content

Commit

Permalink
Pre-Release-Version
Browse files Browse the repository at this point in the history
Updated how authentication is handled. Updated readme and documentation in code.
  • Loading branch information
jschibberges committed Nov 5, 2022
1 parent ca0bbc8 commit d5933b3
Show file tree
Hide file tree
Showing 7 changed files with 1,191 additions and 1,218 deletions.
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,71 +25,80 @@ The API requires a key to authenticate requests. Personal key can be requested f
## Usage
To save your API key create a connection-object, that you can then pass to the search functions. It will save you time, should you have to change API keys at a later date. If you don't supply an API key, the official API key will be used until 31st of May 2023.
```
import bundestag_api as bta
con = bta.BTA_Connection() #if you want to use your own API key, supply it via "apikey="XXX")
import bundestag_api
bta = bundestag_api.btaConnection() #if you want to use your own API key, supply it via "apikey="XXX")
data = bta.query(resource="vorgang")
for d in data:
print(d["drucksachetyp"]+": "+d["titel"])
```
The package has one general search function that can be used to query all resources of the API. However, you will also have to specify all relevant parameters for your search. Data is returned as a dictionary (which can easily be saved as json). Minimally an API key and the resource type need to specified.
The query-function serves as a general search function that can be used to query all resources of the API. However, you will also have to specify all relevant parameters for your search. Data is returned as a dictionary (which can easily be saved as json). Minimally the resource type needs to specified.

For each resource type the api offers a search function and a get function are implemented. Get functions retrieve data for specific entity ids while search function offer all parameters that are relevant to the resource type. Example for documents (Drucksachen):
```
data = bta.btapi_query(apikey=con, resource="vorgang")
bta.search_document(datestart="2022-11-01",dateend="2022-11-01",institution="BT")
bta.get_document(btid=264030)
```

The Bundestag API serves 8 different resources though 2 are doubled with the only difference being whether the document text is returned via the API. For all resources there are two functions, search and get.
The Bundestag API serves 8 different resources though 2 are doubled with the only difference being whether the document text is returned via the API.

### Activities ("Aktivität")
Get one or more activities by their ID
```
get_activity(apikey, btid)
bta.get_activity(btid)
```
Search for documents by specifying parameters for start and end date or institution. Important: The standard number of documents returned are 100. If more are desired, the "num" parameter must be set.
```
search_activity()
bta.search_activity()
```
### Documents / Full-Text ("Drucksache")
Get one or more documents by their ID
```
get_document(apikey, btid)
bta.get_document(btid)
```
Search for documents by specifying parameters for start and end date or institution. Important: The standard number of documents returned are 100. If more are desired, the "num" parameter must be set.
```
search_document()
bta.search_document()
```
The API differentiates between documents and documents incuding full-text of the document. The functions always query the full-text resource.

### Persons ("Person")
Get one or more persons by their ID
```
get_person(apikey, btid)
bta.get_person(btid)
```
Search for persons by specifying parameters for start and end date or institution. Important: The standard number of documents returned are 100. If more are desired, the "num" parameter must be set.
```
search_person()
bta.search_person()
```
### Plenary Protocols / Full-Text ("Plenarprotokoll")
Get one or more plenary protocols by their ID
```
get_plenaryprotocol(apikey, btid)
bta.get_plenaryprotocol(btid)
```
Search for plenary protocols by specifying parameters for start and end date or institution. Important: The standard number of documents returned are 100. If more are desired, the "num" parameter must be set.
```
search_plenaryprotocol()
bta.search_plenaryprotocol()
```
The API differentiates between plenary protocols and plenary protocols incuding full-text of the protocol. The functions always query the full-text resource.

### Procedures ("Vorgang")
Get one or more procedures by their ID
```
get_procedure(apikey, btid)
bta.get_procedure(btid)
```
Search for procedures by specifying parameters for start and end date or institution. Important: The standard number of documents returned are 100. If more are desired, the "num" parameter must be set.
```
search_procedure()
bta.search_procedure()
```
### Procedure Positions ("Vorgangsposition")
Get one or more procedure positions by their ID
```
get_procedure(apikey, btid)
bta.get_procedure(btid)
```
Search for procedure positions by specifying parameters for start and end date or institution. Important: The standard number of documents returned are 100. If more are desired, the "num" parameter must be set.
```
search_procedure()
bta.search_procedure()
```

## ToDo's
- Parallelize requests for larger queries
- Extend Class methods
7 changes: 1 addition & 6 deletions bundestag_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# -*- coding: utf-8 -*-
"""
Python wrapper for the official Bundestag API
@author: Julian Schibberges
"""

from .bta_utils import btapi_query, BTA_Connection, Person, Role, Drucksache, \
from .bta_wrapper import BTA_Connection, Person, Role, Drucksache, \
Aktivitaet, Vorgang, Vorgangsposition, Plenarprotokoll
from .functions import search_procedure, search_document, search_person, \
search_plenaryprotocol, get_procedure, get_document, get_person, \
get_plenaryprotocol
Loading

0 comments on commit d5933b3

Please sign in to comment.