Skip to content

Instantly share code, notes, and snippets.

@mbentley
Last active January 28, 2023 05:11
Embed
What would you like to do?
Example API Calls for Omada Controller (validated on 5.0.30)
# 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}&currentPage=1&currentPageSize=1000"
@FurbyX92
Copy link

Do you have one example with the new api V3 or the documentation link?

@mbentley
Copy link
Author

There's a new v3 API? I hadn't seen anything about that and it doesn't look like the app itself uses anything that's listed as a v3 API. Here is where the API documentation came from:

Post 27 has the API from version 5 of the controller:
https://static-community.tp-link.com/attach/8/2/2022/78d3f067ac0c491d931426e040188632.zip

That thread has the most info I've seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment