What you need
You need an account to use the API. Without signing in it answers “401 sign-in required”. The only exceptions are the calls that the pages of Frag den Bund make themselves for visitors, for example the search for authorities in the request form.
Documentation
Every address, field and filter is described in the interactive documentation (visible with an account). You can download the schema (OpenAPI) for your tools. The API lives at /api/v1/ and answers with JSON; lists are also available as ?format=csv.
Access for programs
Programs do not sign in with your password but with an access key (token) through OAuth 2.0 (authorization code). This is how it works:
-
Register an app (account, settings, developer). You receive a client ID. Redirect addresses must start with
https://. Programs in a browser or on a phone are public apps and must use PKCE. - The person whose account the app uses opens the sign-in address and allows access. That person can be you.
- The app exchanges the code for a token. The token is valid for 60 minutes; with the refresh token (valid for 30 days) the app gets a new one.
# 1. Open this address in the browser. The person signs in and allows access.
https://fragdenbund.ch/account/authorize/?response_type=code&client_id=CLIENT_ID&redirect_uri=https://app.example.org/callback&scope=read:request&code_challenge=CHALLENGE&code_challenge_method=S256
# 2. Exchange the code that arrives at your redirect address for a token.
curl -X POST https://fragdenbund.ch/account/token/ \
-d grant_type=authorization_code -d code=CODE -d client_id=CLIENT_ID \
-d redirect_uri=https://app.example.org/callback -d code_verifier=VERIFIER
# 3. Call the API with the token.
curl -H "Authorization: Bearer ACCESS_TOKEN" "https://fragdenbund.ch/api/v1/request/?format=json"
Whoever gave access can take it away at any time under Settings, Apps with access. An app can only do what was shown when access was allowed:
| Permission | Lets the app |
|---|---|
read:user
|
Access to user status |
read:profile
|
Read user profile information |
read:email
|
Read user email |
read:request
|
Read your (private) requests |
make:request
|
Make requests on your behalf |
write:request
|
Edit requests |
write:message
|
Add and edit messages |
write:attachment
|
Add and edit attachments |
follow:request
|
Follow/Unfollow requests |
read:document
|
Read your (private) documents |
Usage limits
To keep the site fast for everyone, these limits apply per minute:
- With an account: 300 calls.
- Searches (authorities, requests, full-text search): 60 calls.
- Without an account, for the few open calls: 120 calls.
When a limit is reached, the API answers “429” and tells you in Retry-After how many seconds to wait. Please build this into your program.
What you do not see
The API shows the same data as the website. Requests that are not public, replies that have not been released, names of requesters who do not publish them, and email addresses of authorities that we do not show are missing here as well.
Rules
The terms of use apply, in particular the section on the API, and so does the privacy policy. Anyone who gets around the limits or misuses data of third parties can be blocked.
Questions and errors: info@fragdenbund.ch