Omada V2 API
How does one get info on the V2 API? I see on previous posts it was provided for V1, but nothing on the newest. I am currently running the Omada V4 Controller Software.
Example - https://community.tp-link.com/en/business/forum/topic/156627
Please advise.
- Copy Link
- Subscribe
- Bookmark
- Report Inappropriate Content
Here is an example that I have validated to work on version 5.0.30: https://gist.github.com/mbentley/03c198077c81d52cb029b825e9a6dc18
Also copied here for completeness:
# set variables OMADA_URL="https://omada.example.com:8443" USERNAME="admin" PASSWORD="test12345" # get controller id from the API CONTROLLER_ID="$(curl -sk "${OMADA_URL}/api/info" | jq -r .result.omadacId)" # login, get token, set & use cookies TOKEN="$(curl -sk -X POST -c "/tmp/omada-cookies.txt" -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/login" -d '{"username": "'"${USERNAME}"'", "password": "'"${PASSWORD}"'"}' | jq -r .result.token)" # once logged in, make sure you add the following header on additional API calls: # -H "Csrf-Token: ${TOKEN}" # validate login curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/loginStatus?token=${TOKEN}" | jq . # example to get info on the current user curl -sk -X GET -b "/tmp/omada-cookies.txt" -H "Content-Type: application/json" -H "Csrf-Token: ${TOKEN}" "${OMADA_URL}/${CONTROLLER_ID}/api/v2/users/current?token=${TOKEN}¤tPage=1¤tPageSize=1000"
- Copy Link
- Report Inappropriate Content
- Copy Link
- Report Inappropriate Content
@mbentley
Unrelated, but thank you for all your work keeping the docker containers up to date. My homelab thanks you as well
- Copy Link
- Report Inappropriate Content
- Copy Link
- Report Inappropriate Content
@Enigma22 It's all there in my post. Not sure what else you might need.
- Copy Link
- Report Inappropriate Content
@mbentley I'am still not able to get the token, i am using php curl, i tryed a lot of port, 8088, 8043, 433, 443, 8843, and in everytime the answer is the same : connection timedout
- Copy Link
- Report Inappropriate Content
Also wanted to echo my thanks for your Docker image of the Controller...now running on my (old) Synology NAS ~550MB footprint! Much better than I managed!
- Copy Link
- Report Inappropriate Content
- Copy Link
- Report Inappropriate Content
We successfully used the Omada APIs V2 to integrate Omada with Cusna.io
Cusna helps to deliver easy and securt managed WiFi in MDU scenario. We use the APIs to manage automatically the PPSK lifecycle, assigning to each resident an individual PPSK on a dedicated VLAN in order to have them connected to all their home smart devices.
The operator only has to activate the resident without worrying at all about the IT configuration.
Residents, via their portal, can also change the PPSK at any time for increase security, in case the susbpect someone guess their PSK and entered in their network.
https://cusna.io
Looking forward to havign your feedbacks!
- Copy Link
- Report Inappropriate Content
@mbentley @fae I have tried to reproduce a simple API usage with node but I don't get beyond the login. I am able to login and get the token but then all subsequent requests just get an empty webpage as body result, no API response. Any idea what's going on?
I am unclear if the cookies are needed, I would not expect this for a REST API.
Example of the login:
var form = {
"username": "",
"password": ""
};
var formData = JSON.stringify(form);
request({
headers: {
'Content-Type': 'application/json'
},
uri: OMADA_URL+OMADA_CONTROLLER+'/api/v2/login',
body: formData,
method: 'POST'
}, function (err, res, body) {
if (err) {
log(err);
} else {
token = JSON.parse(body).result.token;
}
});
Example of a failed request:
request({
headers: {
'Csrf-Token': token,
'Content-Type': 'application/json'
},
uri: OMADA_URL+OMADA_CONTROLLER+'/api/v2/sites/Default/clients/'+mac,
method: 'GET'
}, function (err, res, body) {
if (err) {
log(err);
} else {
log(body);
}
});
- Copy Link
- Report Inappropriate Content
Information
Helpful: 0
Views: 34021
Replies: 50
Voters 0
No one has voted for it yet.