Documentation
The API is documented with openAPI:
Authentication
Public endpoints, such as the list of exercises or the ingredients can be accessed without authentication. For user owned objects such as workouts, you need to authenticate.
JWT Authentication
This is the suggested way. Generate an access token from the /token/
endpoint. Send a username and password, and you will get the access
token
which you can use to access the private endpoints.
curl \ -X POST \ -H "Content-Type: application/json" \ -d '{"username": "example_username", "password": "example_password "}' \ https://wger.de/api/v2/token/ ... { "access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNDU2LCJqdGkiOiJmZDJmOWQ1ZTFhN2M0MmU4OTQ5MzVlMzYyYmNhOGJjYSJ9.NHlztMGER7UADHZJlxNG0WSi22a2KaYSfd1S-AuT7lU", "refresh":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImNvbGRfc3R1ZmYiOiLimIMiLCJleHAiOjIzNDU2NywianRpIjoiZGUxMmY0ZTY3MDY4NDI3ODg5ZjE1YWMyNzcwZGEwNTEifQ.aEoAYkSJjoWH1boshQAaTkf8G3yn0kapko6HFRt7Rh4" }
Additionally, you can send an access token to /token/verify/
endpoint to verify that token.
When this short-lived access token expires, you can use the longer-lived
refresh
token to obtain another access token.
curl \ -X POST \ -H "Content-Type: application/json" \ -d '{"refresh":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImNvbGRfc3R1ZmYiOiLimIMiLCJleHAiOjIzNDU2NywianRpIjoiZGUxMmY0ZTY3MDY4NDI3ODg5ZjE1YWMyNzcwZGEwNTEifQ.aEoAYkSJjoWH1boshQAaTkf8G3yn0kapko6HFRt7Rh4"}' \ https://wger.de/api/v2/token/refresh/ ... {"access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNTY3LCJqdGkiOiJjNzE4ZTVkNjgzZWQ0NTQyYTU0NWJkM2VmMGI0ZGQ0ZSJ9.ekxRxgb9OKmHkfy-zs1Ro_xs1eMLXiR17dIDBVxeT-w"}
Token
You can also pass a permanent token in the header to authenticate, but this method should be considered deprecated. If you want to generate a token use this page.
Username and password
You can also get a token from the login
endpoint.
Send a username and password in a POST request. IF the user doesn't
currently have a token, a new one will be generated for you
Public endpoints
- daysofweek
- equipment
- exercise
- exercisealias
- exercisecategory
- exercisecomment
- exerciseimage
- exercisebaseinfo
- ingredient
- ingredientinfo
- ingredienttoweightunit
- language
- license
- muscle
- setting-repetitionunit
- setting-weightunit
- variation
- weightunit
Private endpoints
- day
- gallery
- meal
- mealitem
- nutritiondiary
- nutritionplan
- schedule
- schedulestep
- set
- setting
- userprofile
- weightentry
- workout
- workoutlog
Format negotiation
At the moment only JSON and the browsable HTML view are supported. That means that you can use the same endpoints from your browser or a client. Because of this, for the majority of REST clients it will not be necessary to explicitly set the format, but you have the following options:
- Set the Accept header:
application/json
-
application/json; indent=4
- useful for debugging, will indent the result -
text/html
- browsable HTML view
-
Set the format directly in the URL:
-
/api/v2/<endpoint>.json/
-
/api/v2/<endpoint>/?format=json
-
/api/v2/<endpoint>.api/
- browsable HTML view
-
Miscellaneous operations
Ordering
Simply use ?ordering=<fieldname>
to order by that field.
You can also specify more than one field name, just give it a list separated
by commas ?ordering=<field1>,<field2>
. To reverse
the order use like in django a -
in front of the field.
Pagination
By default all results are paginated by 20 elements per page. If you want to
change this value, add a ?limit=<xxx>
to your query.
You will find in the answer JSON the next
and previous
keywords with links to the next or previous result pages.
Filtering resources
You can easily filter all resources by specifying the filter queries in the
URL: ?<fieldname>=<value>
, combinations are possible,
the filters will be AND-joined:
?<f1>=<v1>&<f2>=<v2>
.
Please note that for boolean values you must pass 'False' or 'True' other
values, e.g. 1, 0, false, etc. will be ignored. Like with not filtered queries,
your objects will be available under the 'results' key.
Note that it is not currently possible to specify more than one value, e.g.
category 1 or 2. The only exception to this is the exercises endpoint,
there it is possible to OR different values, e.g. ?muscles=2,7
which will search for exercises that train muscle 2 OR 7.
Some examples:
- All exercises in German:
api/v2/exercise/?language=1
- 'Main' image for all exercises:
api/v2/exerciseimage/?is_main=True
- Exercises that train the biceps with barbells:
api/v2/exercise/?muscles=1&equipment=3