-
Notifications
You must be signed in to change notification settings - Fork 0
JSON REST API
The endpoints are defined as follows. By default, all endpoints return JSON unless otherwise stated.
- GET
/rest/projects/Will return the latest 20 Projects by default - GET
/rest/projects?limit=40Will return the latest 40 projects - GET
/rest/events?limit=40&union=muenster,osnabrueckWill return the latest 40 projects for Weitblick Muenster and Osnabrück - GET
/rest/projects?start=2019-10-01&end=2020-01-01&limit=30Will return 30 projects in the specified time range - GET
/rest/projects/123Project with id 123
-
limitRestricts the number of elements to be returned. Default is 20. -
unionFilter for a corresponding host / union, use the slag ids, e.g., `osnabrueck,muenster -
startSpecifies the start date, all entries after that date will be returned with respect to the other filters -
endSpecifies the end date, all entries before that date will be returned with respect to the other filters -
archiveFilters for a specific month or year, e.g.,2018or2017-06. Only active if start or end is not set. -
searchFilters for a specific search value / word(s) -
countryFilters for countries, e.g.,de,en, oren,de -
visibilityFilters forcompletedprojects and forcurrentprojects, if not specified, all projects are returned with respect to the other filter parameters
- GET
/rest/events/Will return the latest 20 events by default - GET
/rest/events?limit=40Will return the latest 40 events - GET
/rest/events?limit=40&host=muenster, osnabrueckWill return the latest 40 events for Weitblick Muenster and Osnabrück - GET
/rest/events?start=2019-10-01&end=2020-01-01&limit=30Will return 30 events in the specified time range - GET
/rest/events/123Event with id 123
-
limitRestricts the number of elements to be returned. Default is 20. -
unionFilter for a corresponding host / union, use the slag ids, e.g., `osnabrueck,muenster -
startSpecifies the start date, all entries after that date will be returned with respect to the other filters -
endSpecifies the end date, all entries before that date will be returned with respect to the other filters -
archiveFilters for a specific month or year, e.g.,2018or2017-06. Only active if start or end is not set. -
searchFilters for a specific search value / word(s)
- GET
/rest/blog/Will return the latest 20 blog posts by default - GET
/rest/blog?limit=40Will return the latest 40 posts - GET
/rest/nlog?limit=40&host=muenster,osnabrueckWill return the latest 40 blog posts for Weitblick Muenster and Osnabrück - GET
/rest/blog?start=2019-10-01&end=2020-01-01&limit=30Will return 30 posts in the specified time range - GET
/rest/blog/123Blog-Post with id 123
-
limitRestricts the number of elements to be returned. Default is 20. -
unionFilter for a corresponding host / union, use the slag ids, e.g., `osnabrueck,muenster -
startSpecifies the start date, all entries after that date will be returned with respect to the other filters -
endSpecifies the end date, all entries before that date will be returned with respect to the other filters -
archiveFilters for a specific month or year, e.g.,2018or2017-06. Only active if start or end is not set. -
searchFilters for a specific search value / word(s)
- GET
/rest/news/Will return the latest 20 news posts by default - GET
/rest/news?limit=40Will return the latest 40 posts - GET
/rest/events?limit=40&host=muenster,osnabrueckWill return the latest 40 news posts for Weitblick Muenster and Osnabrück - GET
/rest/news?start=2019-10-01&end=2020-01-01&limit=30Will return 30 posts in the specified time range - GET
/rest/news/123News-Post with id 123
-
limitRestricts the number of elements to be returned. Default is 20. -
unionFilter for a corresponding host / union, use the slag ids, e.g., `osnabrueck,muenster -
startSpecifies the start date, all entries after that date will be returned with respect to the other filters -
endSpecifies the end date, all entries before that date will be returned with respect to the other filters -
archiveFilters for a specific month or year, e.g.,2018or2017-06. Only active if start or end is not set. -
searchFilters for a specific search value / word(s)
Hosts are the city associations, e.g., Weitblick Osnabrück, or Weitblick Münster
- GET
/rest/hosts/Will return all hosts - GET
/rest/news/osnabrueckWill return the Host Meta Data for Weitblick Osnabrück e.V.
- GET
/rest/locations/Will return all locations - GET
/rest/locations/123Will return the location with the id 123
- GET
/rest/addresseswill return all addresses - GET
/rest/addresses/123will return the address with the id 123
Check the credentials and return the REST Token if the credentials are valid and authenticated.
Accept the following POST parameters: username, email, password Return the REST Framework Token key.
- POST
/rest/auth/login/
Request:
{
"username": "",
"email": "",
"password": ""
}
Response:
{
"key": "{{ token }}"
}
- POST
/rest/auth/logout/ - Header:
Authorization: Token {{ token }}Logout delets the Token object assigned to the current User object.
- POST
/rest/auth/password/change/ - Header:
Authorization: Token {{ token }}
Accepts the following POST parameters: new_password1, new_password2 Returns the success/fail message.
{
"new_password1": "{{ new password 1 }}",
"new_password2": "{{ new password 2 }}",
}
- POST
/rest/auth/password/reset/
Accepts the following POST parameters: email Returns the success/fail message.
{
"email": "{{ email }}",
}
- POST
/rest/auth/password/reset/confirm/
Password reset e-mail link is confirmed, therefore this resets the user's password. Accepts the following POST parameters: token, uid, new_password1, new_password2 Returns the success/fail message.
{
"new_password1": "{{ new password 1 }}",
"new_password2": "{{ new password 2 }}",
"uid": "{{ uid }}",
"token": "{{ token }}",
}
- GET, PUT, PATCH
/rest/auth/user/ - Header:
Authorization: Token {{ token }}
Reads and updates UserModel fields Accepts GET, PUT, PATCH methods. Default accepted fields: username, first_name, last_name Default display fields: pk, username, email, first_name, last_name Read-only fields: pk, email Returns UserModel fields.
Request:
{
"username": "{{ username }}",
"first_name": "{{ first name }}",
"last_name": "{{ last name }}"
}
Response:
{
"pk": "{{ private key }}",
"username": "{{ username }}",
"email": "{{ email }}",
"first_name": "{{ first name }}",
"last_name": "{{ last name }}",
"image": "{{ user image uri }}",
}
- GET
/rest/cycle/donations/
Returns the cycle donation objects structured as follows:
[
{
"id": "1",
"projects": [
{
"project": 1,
"cycle_donation": 1,
"current_amount": 100.0,
"goal_amount": 10000.0,
"finished": false
}
],
"partner": 1,
"logo": "/media/WeitblickOsnabrueckLogo.png",
"name": "Fahren von Weitblick Osnabrück",
"description": "Test Beschreibung",
"goal_amount": 10000.0,
"rate_euro_km": 0.1
}
]
- POST
/rest/cycle/segment/adds a cycle segment for a user. - Header:
Authorization: Token {{ token }}
Request The request should contain the following JSON structure:
{
"start": "2019-10-01T07:08:04Z",
"end": "2019-10-01T07:08:14Z",
"distance": 0.16,
"project": 1,
"tour": 0,
}
Response
{
"tour": 0,
"project": {
"id": "1",
"hosts": [
"osnabrueck"
],
"cycle": [
{
"project": 1,
"cycle_donation": 1,
"current_amount": 100.016,
"goal_amount": 10000.0,
"finished": false
}
]
},
"finished": false,
"euro": 0.016,
"km": 0.16
}
- GET
/rest/cycle/rankingreturns the cycle ranking with user objects. - Header:
Authorization: Token {{ token }}
Returns a list of user objects with the following content:
{
"user_field": [
{
"username": "{{ user name }}",
"image": {{ user image URI }},
"km": {{ cycled km of user }},
"euro": {{ cycled amount of donations in euros }}
}, ...],
"best_field":
[
{
"username": "{{ user name }}",
"image": {{ user image URI }},
"km": {{ cycled km of user }},
"euro": {{ cycled amount of donations in euros }}
}, ....]
}
- GET
/rest/cycle/tours/ - Header:
Authorization: Token {{ token }}
Response
[
{
"tour": 0,
"project": {
"id": "1",
"hosts": [
"osnabrueck"
],
"cycle": [
{
"project": 1,
"cycle_donation": 1,
"current_amount": 100.016,
"goal_amount": 10000.0,
"finished": false
}
]
},
"finished": false,
"euro": 0.016,
"km": 0.16
}
]