Created
May 7, 2017 15:29
-
-
Save cl4u2/de6ed34cb948fbcdba0c71257d33fee5 to your computer and use it in GitHub Desktop.
PHPIPAM API usage basic example in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
server = "https://ipam.ninux.org" | |
appid = "appid" | |
username = "username" | |
password = "password" | |
baseurl = server + "/api/" + appid | |
res = requests.post(baseurl + '/user/', auth=(username, password)) | |
print res.status_code | |
print res.content | |
token = json.loads(res.content)['data']['token'] | |
res = requests.get(baseurl + '/sections/', headers={'token': token}) | |
print res.status_code | |
print res.content | |
res = requests.get(baseurl + '/sections/3/subnets/', headers={'token': token}) | |
print res.status_code | |
print res.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this one. It saved me some time!