Skip to content

Instantly share code, notes, and snippets.

@cl4u2
Created May 7, 2017 15:29
Show Gist options
  • Save cl4u2/de6ed34cb948fbcdba0c71257d33fee5 to your computer and use it in GitHub Desktop.
Save cl4u2/de6ed34cb948fbcdba0c71257d33fee5 to your computer and use it in GitHub Desktop.
PHPIPAM API usage basic example in Python
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
@danielmacuare
Copy link

Thanks for this one. It saved me some time!

Copy link

ghost commented Jan 1, 2022

"appid" means??

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