SNAPI API
Servers
- https://snapi-test.stanford.edu/snapi
- https://snapi-uat.stanford.edu/snapi
- https://snapi.stanford.edu/snapi
Access
APIKey is used to control access to the APIs. Keys "username" and "x_api_key" need to be set in the request header.
- Get all possible makes and models in NetDB given the user agent:
GET /makemodel
Get a list of locations associated with a node/user
Request Parameters
- sunetid
- MAC
- IP
- primaryOrgid
- affiliation (a list of affilications)
- suGwAffilCode1
Sample Request Body
{
"MAC": "1.2.3.4",
"affiliation": "staff,student",
"ip": "192.168.0.1",
"primaryOrgId": "CHYR",
"suGwAffilCode1": "staff",
"sunetid": "jlucker"
}
Response Type
Content-Type: application/json
Response Data
200
{
"status": "success",
"data": {
"sunetid": "jlucker",
"primaryOrgId": "CHYR",
"deptLoc": [
{
"snsr-baca-04-org": "University Information Technology@RWC B3 - University Hall"
},
{
"snsr-baca-03-org": "University Information Technology@Polya Hall, 255 Panama St"
},
{
"snsr-baca-01-org": "University Information Technology@RWC B4 - Cardinal Hall"
},
{
"snsr-baca-05-org": "University Information Technology@RWC B1 - Academy Hall"
},
{
"snsr-baca-02-org": "University Information Technology@Pine Hall, 241 Panama St"
}
]
}
}
400
Invalid input
401
Unauthorized
Get all makes and models in NetDB
Request Parameters
None
Response Type
Content-Type: application/json
Response Data
200
{
"status:": "success",
"data": {
"model": [
"pc any",
"pc laptop",
"Apple any",
"Apple laptop",
"unknown any"
],
"pcModel": [
"pc any",
"pc laptop",
"unknown any"
],
"appleModel": [
"Apple MacBook",
"Apple MacBook Pro",
"Apple MacBook Air",
"Apple iMac",
"Apple Mac Mini",
"Apple laptop",
"Apple any",
"unknown any"
],
"chromeModel": [
"Google Chromebook",
"Acer Chromebook",
"Asus Chromebook",
"Dell Chromebook",
"HP Chromebook",
"Lenovo Chromebook",
"Samsung Chromebook",
"unknown any"
],
"deviceModel": [
"Apple iPad",
"Apple iPod",
"Apple iPhone",
"Microsoft Surface",
"tablet any",
"phone any",
"unknown any"
]
}
}
401
Unauthorized
Get all possible makes and models in NetDB given the user agent
Sample Request
URL: https://snapi-test/snapi/makemodel
{
"ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"
}
Response Type
Content-Type: application/json
Response Data
200
{
"status:": "success",
"data": {
"mmList": [
"Apple MacBook",
"Apple MacBook Pro",
"Apple MacBook Air",
"Apple iMac",
"Apple Mac Mini",
"Apple laptop",
"Apple any",
"unknown any"
]
}
}
401
Unauthorized
Get all OSes in NetDB
Request Parameters
None
Response Type
Content-Type: application/json
Response Data
200
{
"status:": "success",
"data": {
"os": [
"Builtin",
"Android",
"Linux",
"Mac OS X",
"other",
"Windows",
"Unix",
"Unknown"
],
"winOs": [
"Windows 10",
"Windows 7",
"Windows 8",
"Windows 8.1",
"Windows Vista",
"Windows XP",
"Windows MacOS"
],
"macOs": [
"Mac OS X"
],
"deviceOs": [
"Builtin",
"Apple iOS",
"Android",
"Unknown"
]
}
}
401
Unauthorized
Create a NetDB node
Request Content Type
Content-Type: application/json
Request JSON Attributes
templateName (required, format:text)
The name of the template for the device.
os (required, format:text)
The operating system of the device.
makeModel (required, format:text)
The make and model of the device.
location (required, format:text)
The location of the device.
isResident (required, format: boolean)
Wheather the device belongs to a dorm resident.
room (optional, format:text)
The location of the device.
mac (optional, format:text)
The MAC address of the device.
ip (optional, format:text)
The IP address of the device.
deptLocation (optional, format:text)
The location of the department.
department (optional, format:text)
The department of the device.
primaryOrgId (optional, format:text)
The primary organization ID of the device user.
sunetId (optional, format:text)
The primary SUnetID of the device user.
email (optional, format:text)
The email address of the device user.
offCampusRegistration (optional, format: boolean)
Indicates off-campus registration.
Sample Request
URL: https://snapi-test/snapi/node/10dd.b1d1.2ada
Data: {
"ip": "172.64.86.44",
"templateName": "snsr-aa00-org",
"mac": "10dd.b1d1.2adb",
"makeModel": "Apple MacBook",
"location" : "RWC B3 - University Hall",
"deptLocation": "IT Services@On Campus WirelessIT Services/On Campus Wireless",
"department":"University Information Technology",
"email": "jlucker@stanford.edu",
"os": "mac os x",
"room": "200",
"isResident": false,
"offCampusRegistration" : true
}
Sample Response
201
{
"status: ": "success",
"data: ": {
"names": [
{
"name": "sr24-79f0a7a278.stanford.edu"
}
],
"state": "Good",
"department": "University Information Technology",
"location": {
"name": "RWC B3 - University Hall"
},
"room": "200",
"make and model": "Apple MacBook",
"oses": [
"Mac OS X"
],
"groups": [
"Stanford"
],
"administrators": {
"admin teams": [
{
"name": "snsr-default",
"email": "snsr-defaultreg-log@lists.stanford.edu",
"phone": "5-HELP"
}
]
},
"custom fields": [
{
"label": "template-name",
"value": "snsr-aa00-org"
}
],
"interfaces": [
{
"hardware address": "10dd.b1d1.2adb",
"dhcp flag": true,
"roaming flag": true
}
],
"id": "147650640"
}
}
409
{
"status: ": "fail",
"message: ": "Creation failed:The Interface \"10dd.b1d1.2adb\" already exists."
}
400
{
"status": 400,
"message": "Incorrect request"
}
Update an existing node
Request Content Type
Content-Type: application/json
Request JSON Attributes
macs (optional, format:array of strings)
An array of MAC addresses associated with the device.
make (optional, format:text)
The make of the device.
model (optional, format:text)
The model of the device.
serial (optional, format:text)
The serial number of the device.
type (optional, format:text)
The model number of the device.
wired (optional, format:string)
MAC address of the wired interface of the device
wireless (optional, format:string)
MAC address of the wireless interface of the device
ip (optional, format:string)
THe IP address of the device.
Sample Request
URL: https://snapi-test.stanford.edu/snapi/node/40:30:04:1c:dc:11
Data: {
"make": "MacBook Pro",
"serial": "XL7J25WX9G",
"type": "Z15H00106LL/A",
"model": "MacBookPro18",
"macs": ["40:30:04:1c:dc:11", "0026.b08c.8d98"],
"wired": "40:30:04:1c:dc:11",
"wireless": "0026.b08c.8d98",
"ip": "1.2.3.4"
}
Response Data
200
{
"status": 200,
"message": "Node updated"
"data": {
"name": "Jane Doe's Macbook",
"mac": "40:30:04:1c:dc:11",
"state": "good"
}
}
400
{
"status": 400,
"message": "Update failed."
}