API Filtering by device_type model #13287
Replies: 3 comments 9 replies
-
Which API - REST API? Which model are you querying - Device? What query are you currently using? What version of Netbox? This works for me with Netbox v3.5.6: Note that this matches on the slug of the device type, not the name. It returns all devices whose type is There are no regular expression filters in the REST API: see filtering doc. |
Beta Was this translation helpful? Give feedback.
-
You are correct, I probably should have mentioned the API, it was late :-) /api/dcim/devices/?limit=1000&device_type_model="c9500-40x" (matches slug) When I use that - I get back all devices in netbox. if I use device_type_id=8, I get just that platform as expected. In the doc, there are some operators for strings, such as __ic which I could use for every that starts with c9, if that works. |
Beta Was this translation helpful? Give feedback.
-
I don't think device_type_model is the param you are looking for, it's device_type. One thing that bites me from time to time is that if you input a parameter that doesn't exist it is just silently ignored and it can take a while to notice a typo or thinko. I don't know if it'd be more disruptive if there was an error return {"error": "Parameter 'device_type_model' doesn't exist, check /api/docs for list of available parameters"}
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: travisjohnsonga ***@***.***>
Sent: Friday, July 28, 2023 9:24 AM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [netbox-community/netbox] API Filtering by device_type model (Discussion #13287)
You are correct, I probably should have mentioned the API, it was late :-)
/api/dcim/devices/?limit=1000&device_type_model="c9500-40x" (matches slug)
When I use that - I get back all devices in netbox. if I use device_type_id=8, I get just that platform as expected.
In the doc, there are some operators for strings, such as __ic which I could use for every that starts with c9, if that works.
—
Reply to this email directly, view it on GitHub<#13287 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM5NZRGMD4YFCQIG23TXSPDRNANCNFSM6AAAAAA227JLDI>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all -
Is there a way to filter the API based on the model name rather than the model ID?
In my environment, I have switches model 9200, 9300, 9500. I'd like to grab all of these (with varying submodels) by filtering with a regex if possible.
Beta Was this translation helpful? Give feedback.
All reactions