Hey there,
Since we still don’t have documentation for our REST API, I have decided, under the pressure of a load of questions from users, to create a simple description of how to retrieve data from our API with simple curl
commands.
First of all, you need to generate a public access API token with “read all” scope. How to get one is described in my previous post: Introducing a new API token type for full read access to our REST API
To communicate with Karmen with CURL (or with any other tools or from your application), you need to add an Authorization header to your request. So a very simple HTTP GET request with curl
would be as follows:
curl -k -H "Authorization: Token YOUR_TOKEN_HERE" https://backend.next.karmen.tech/api/2/users/me/
This request should give you data about your account:
{
"id":"abcdefgh",
"last_login":"2024-03-07T13:31:08.630545Z",
"username":"abc@efg.com",
"date_joined":"2022-03-23T21:28:51Z",
...
}
How to get a list of printers? This needs to be done with two requests. First, we’ll get a list of groups you are a member of. Then, you can call the group endpoint to list its printers.
List your groups:
curl -k -H "Authorization: Token YOUR_TOKEN_HERE" https://backend.next.karmen.tech/api/2/users/me/groups/
From the response identify your group ID:
[
{
"id":"123abc45",
"name":"this is my group name",
...
}
]
With the group ID construct your next request to list printers from the specified group identified by ID “123abc45”:
curl -k -H "Authorization: Token YOUR_TOKEN_HERE" https://backend.next.karmen.tech/api/2/groups/123abc45/printers/
In response, you get a list of your printers from the group with ID “123abc45”.
That’s it. Consuming the Karmen API is very easy. And since we are still lacking documentation (sorry for that), I’ll add some more endpoints below you can call in the same way. If you have any questions or need help, just let me know, and I’m happy to help!
We try to build our API to be self-described, so hopefully, you will see and understand how to construct your request URL easily. Here is a list of API endpoints to be used with the “read API token”.
https://backend.next.karmen.tech/api/2/files/<file_id>/videos/
https://backend.next.karmen.tech/api/2/files/<pk>/preview-images/<image_id>/
https://backend.next.karmen.tech/api/2/groups/<group_id>/file-labels/
https://backend.next.karmen.tech/api/2/groups/<group_id>/file-labels/<pk>/
https://backend.next.karmen.tech/api/2/groups/<group_id>/files/
https://backend.next.karmen.tech/api/2/groups/<group_id>/files/<pk>/
https://backend.next.karmen.tech/api/2/groups/<group_id>/print-jobs/
https://backend.next.karmen.tech/api/2/groups/<group_id>/print-queue/
https://backend.next.karmen.tech/api/2/groups/<group_id>/print-queue/<pk>/
https://backend.next.karmen.tech/api/2/groups/<group_id>/printers/
https://backend.next.karmen.tech/api/2/groups/<group_id>/users/
https://backend.next.karmen.tech/api/2/groups/<group_id>/users/<user_id>/
https://backend.next.karmen.tech/api/2/groups/<group_id>/videos/
https://backend.next.karmen.tech/api/2/groups/<group_id>/videos/<pk>/
https://backend.next.karmen.tech/api/2/printers/<pk>/
https://backend.next.karmen.tech/api/2/users/me/
https://backend.next.karmen.tech/api/2/users/me/api_keys/
https://backend.next.karmen.tech/api/2/users/me/api_keys/<pk>/
https://backend.next.karmen.tech/api/2/users/me/groups/
https://backend.next.karmen.tech/api/2/users/me/groups/<pk>/
https://backend.next.karmen.tech/api/2/groups/<id:group_id>/avatar
Martin