User Tools

Site Tools


infoblox:api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
infoblox:api [2025/08/19 12:18] – [GetMemberData] bstaffordinfoblox:api [2026/03/07 00:25] (current) bstafford
Line 1: Line 1:
 ====== BloxOne API ====== ====== BloxOne API ======
 ([[infoblox:api#nios|NIOS further down the page]]) ([[infoblox:api#nios|NIOS further down the page]])
 +
 +
 +REMEMBER, in Linux you can pipe output into "jq" which will format the output as a response to JSON query.
 ===== Swagger ===== ===== Swagger =====
  
Line 6: Line 9:
     * [[https://github.com/infobloxopen/nios-swagger|NIOS Swagger GitHub]]     * [[https://github.com/infobloxopen/nios-swagger|NIOS Swagger GitHub]]
     * [[https://docs.infoblox.com/space/NIOS/35400616/NIOS|Official Doc Page]] linking to both of the links above.     * [[https://docs.infoblox.com/space/NIOS/35400616/NIOS|Official Doc Page]] linking to both of the links above.
 +
 +===== Convert JSON =====
 +The "jq" command is excellent for parsing JSON. 
 +
 +Page on transforming JSON with jq [[www.digitalocean.com/community/tutorials/how-to-transform-json-data-with-jq|here]].
 ===== Quick CURL===== ===== Quick CURL=====
 <code>curl -X GET -H "Authorization: Token token=<API_KEY>" "https://csp.infoblox.com/tide/api/data/threats?type=host&class=bot"</code> <code>curl -X GET -H "Authorization: Token token=<API_KEY>" "https://csp.infoblox.com/tide/api/data/threats?type=host&class=bot"</code>
  
 ===== Simple CURL ===== ===== Simple CURL =====
 +==== Quick Sample =====
 +<code>PORTAL="csp.eu.infoblox.com"
 +BASE_URL="https://$PORTAL"
 +API_TOKEN="INSERT_API_KEY_HERE"
 +curl -s -X GET \
 +-H "Content-Type: application/json" \
 +-H "Authorization: Token token=$API_TOKEN" \
 +"$BASE_URL/api/atcfw/v1/network_lists" | jq
 +CONTENT_TYPE="Content-Type: application/json"
 +AUTHORIZATION="Authorization: Token token=$API_TOKEN"</code>
 +Then you can just run
 +<code>curl -s -X GET -H "$CONTENT_TYPE" -H "$AUTHORIZATION" \
 +"$BASE_URL/api/atcfw/v1/network_lists" | jq</code>
 +
 +What you can do is insert the following lines into .bashrc to have them auto populate when you log in. Be careful about this as it exposes your API key. Nice in a lab but risky in production.
 +<code>PORTAL="csp.eu.infoblox.com"
 +BASE_URL="https://$PORTAL"
 +API_TOKEN="INSERT_API_KEY_HERE"</code>
 +
 +
 +or even
 +<code>API="/api/atcfw/v1/network_lists"
 +curl -s -X GET -H "$CONTENT_TYPE" -H "$AUTHORIZATION" "$BASE_URL$API" | jq</code>
 ==== External Networks ==== ==== External Networks ====
 API documentation [[https://csp.infoblox.com/apidoc/?url=https://csp.infoblox.com/apidoc/docs/Atcfw#/network_lists/network_listsListNetworkLists|here]]. Look for 'network_lists'. API documentation [[https://csp.infoblox.com/apidoc/?url=https://csp.infoblox.com/apidoc/docs/Atcfw#/network_lists/network_listsListNetworkLists|here]]. Look for 'network_lists'.
Line 255: Line 286:
 sys.exit(1)</code> sys.exit(1)</code>
 ===== Reference ===== ===== Reference =====
 +API Docs [[https://csp.infoblox.com/apidoc?url=https%3A%2F%2Fcsp.infoblox.com%2Fapidoc%2Fdocs%2FAtcfw#/|here]].
 +
 +===== Subnet Filter =====
 +
 +
 +<code>curl -s --location 'https://csp.eu.infoblox.com/api/ddi/v1/ipam/subnet?_offset=0&_tfilter=Type%3DHo*&_limit=5&_is_total_size_needed=true' \
 +--header 'Accept: application/json' \
 +--header 'Authorization: Token YOUR_API_KEY_HERE' \
 +| jq -r '.results[] | "\(.address)/\(.cidr)"' </code>
 +
 +This command will find all subnets that have the tag "Type" with value "Home" and return JSON data.
 +
 +You can then use the jq command to filter the subnet address value and the subnet CIDR value and display in format address/cidr
 +==== AWS IPAM ====
 +To get the Infoblox ID needed by AWS IPAM for management:
 +<code>curl -s -H "Authorization: Token <YOUR_API_KEY>" https://csp.infoblox.com/v2/current_user | jq '.result.account_infoblox_id'</code>
 +==== Get Internal Domain List ====
 +The following gets the full list of Internal Domain lists (Security) as well as their contents. You can use this to get the ID of each list.
 +<code>curl -X GET -H "Authorization: Token token=<APIKEY>" "https://csp.eu.infoblox.com/api/atcfw/v1/internal_domain_lists"</code>
 +
 +The code below is for when you want to filter the query to show just the contents of a specific list (in this case, the ID is 1234)
 +<code>curl -X GET -H "Authorization: Token token=<APIKEY>" "https://csp.eu.infoblox.com/api/atcfw/v1/internal_domain_lists/1234"</code>
 +
 ==== Get Data of Threat Feed ==== ==== Get Data of Threat Feed ====
 <code>curl -s -X GET "https://csp.infoblox.com/api/atcfw/v1/threat_feeds?_filter=((name=='AntiMalware')or(name=='FarSightNOD'))" -H "Authorization: Token token=ADD_API_KEY" -H "Content-Type: application/json"</code> <code>curl -s -X GET "https://csp.infoblox.com/api/atcfw/v1/threat_feeds?_filter=((name=='AntiMalware')or(name=='FarSightNOD'))" -H "Authorization: Token token=ADD_API_KEY" -H "Content-Type: application/json"</code>
Line 308: Line 362:
 CURL version CURL version
 <code>curl -X GET -H "Authorization: Token token=MYTOKEN" "https://csp.infoblox.com/api/atclad/v1/lookalikes?_limit=101&_offset=0&_filter=detected_at%3E=%222025-01-1T17:52:22Z%22%20and%20%28suspicious==%22true%22%20or%20phishing==%22true%22%20or%20malware==%22true%22%29%20and%20target_domain:=%22infoblox.com%22&_order_by=registration_date%20desc"</code> <code>curl -X GET -H "Authorization: Token token=MYTOKEN" "https://csp.infoblox.com/api/atclad/v1/lookalikes?_limit=101&_offset=0&_filter=detected_at%3E=%222025-01-1T17:52:22Z%22%20and%20%28suspicious==%22true%22%20or%20phishing==%22true%22%20or%20malware==%22true%22%29%20and%20target_domain:=%22infoblox.com%22&_order_by=registration_date%20desc"</code>
 +===== NIOS-X Host Monitoring =====
 +This is JSON to use in Postman Test to filter results of monitoring NIOS-X service 
 +[[https://docs.infoblox.com/space/BloxOneInfrastructure/216137801/Viewing+Server+Metrics+in+Supported+Formats|Documentation Page for Metrics]]
 +<code>curl -k "https://<Server IP address>/api/hostmonitoring/v1/metrics" --header 'Accept: application/json' | jq</code>
 +[[https://docs.infoblox.com/space/BloxOneInfrastructure/282853467/Querying+Server+Statuses+Using+the+API|Documentation Page for Statuses]]
 +<code>curl -k "https://<Server IP address>/api/hostmonitoring/v1/statuses" --header 'Accept: application/json' | jq</code>
 +<code>// ALT+CTLR+C to view Postman Console for this output
 +let jsonData = pm.response.json();
 +
 +let jsonObject = jsonData.find(item => item.name === "onprem_host_cpu_percentage_combined");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("Host CPU:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_host_memory_usage_total");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    let gb = objValue / (1024 ** 3);
 +    console.log("Host Memory Total:", gb.toFixed(1));
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_host_memory_usage_used");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    let gb = objValue / (1024 ** 3);
 +    console.log("Host Memory Used:", gb.toFixed(1));
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_host_last_disconnected_timestamp");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("Host Disconnected Time Stamp:", objValue);
 +}
 +
 +
 +jsonObject = jsonData.find(item => item.name === "onprem_named_qps");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    let answer = objValue * 1;
 +    console.log("BIND QPS:", answer.toFixed(2));
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_named_recursion_queries_total");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("Recursive Queries Total:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_named_success_queries_total");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("Success Queries Total:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_named_failure_queries_total");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("Failure Queries Total:", objValue);
 +}
 +
 +
 +jsonObject = jsonData.find(item => item.name === "onprem_coreDNS_qps");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    let answer = objValue * 1;
 +    console.log("DFP QPS:", answer.toFixed(2));
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_coredns_health");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DFP Health:", objValue);
 +}
 +
 +
 +jsonObject = jsonData.find(item => item.name === "onprem_kea_pkt4_request_received");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DHCP REQUEST Received:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_kea_pkt4_sent");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DHCP Sent Total:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_kea_pkt4_discover_received");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DHCP DISCOVER Received:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_kea_pkt4_offer_sent");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DHCP OFFER Sent:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_kea_pkt4_received");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DHCP Recieved Total:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_kea_pkt4_ack_sent");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("DHCP ACK Sent:", objValue);
 +}
 +
 +
 +jsonObject = jsonData.find(item => item.name === "onprem_ntp_stratum");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("NTP Stratum:", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_ntp_offset_milliseconds");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("NTP Offset (ms):", objValue);
 +}
 +jsonObject = jsonData.find(item => item.name === "onprem_ntp_reach_octal");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    console.log("NTP Reach Octal:", objValue);
 +}
 +
 +
 +jsonObject = jsonData.find(item => item.name === "onprem_cdc_volume_used_MB");
 +if (jsonObject && jsonObject.metrics.length > 0) {
 +    let objValue = jsonObject.metrics[0].value;
 +    let answer = objValue * 1;
 +    console.log("Total CDC Volume in MB:", answer.toFixed(1));
 +}
 +</code>
 +
 +Printing state is much easier
 +<code>// ALT+CTLR+C to view Postman Console for this output
 +let jsonData = pm.response.json();
 +
 +jsonData.forEach(item => {
 +    console.log("Object: " + item.object + ", State: " + item.state);
 +});</code>
 ====== NIOS ====== ====== NIOS ======
 Calls to create network objects are blocking, within a network space. Essentially single threaded. If there are enough calls queued up, waiting for service, those calls will hit a timeout within the product. Calls to create network objects are blocking, within a network space. Essentially single threaded. If there are enough calls queued up, waiting for service, those calls will hit a timeout within the product.
Line 327: Line 514:
  
 More specific searches are always going to be better than broad searches.  Similarly, search keys that reduce the result set faster coming first will always be better. More specific searches are always going to be better than broad searches.  Similarly, search keys that reduce the result set faster coming first will always be better.
 +
 +===== GetGridData =====
 +How to download a Grid backup via API
 +  * BACKUP
 +  * BACKUP_DTC
 +  * NTP_KEY_FILE
 +  * SNMP_MIBS_FILE
 +  * HF_MANIFEST_FILE
 +
 +Get download URL and token
 +<code>curl -k1 -u apiuser:apiuser -X POST 'https://192.168.11.11/wapi/v2.13.7/fileop?_function=getgriddata'  -H "Content-Type: application/json"  -d '{"type": "BACKUP"}'</code>
 +
 +<code>curl -k1 -u apiuser:apiuser -H "Content-type:application/force-download" -O "https://192.168.11.11/http_direct_file_io/req_id-DOWNLOAD-1103213338881444/database.bak"</code>
 +
 +
 +<code>curl -k1 -u apiuser:apiuser -X POST 'https://192.168.11.11/wapi/v2.13.7/fileop?_function=downloadcomplete' -H "Content-Type: application/json" -d '{ "token": "eJytjk0LwiAYx79KeG7ao8tst8UKgiiIoKO4tCVtuZxBEX335qGuXTr+357n90RWo2yAvLlGq5Niofe6+vNnmRAIwYBTYBwQVMaYqGA2TurfUPGWxj+glMOKWjacoE5oKlHNK+cvN1vHYKoe0yQvolBi4w\nAIYxI9GW2npzCPJoayOtI78eE62CKlVncKnOkSJq2TgdGVCR73K5nS++gbkcnLaXKoaz5frjR0m6\n4LyqDAlN+weU1xs5+lzD\n" }'</code>
 +
  
 ===== GetMemberData ===== ===== GetMemberData =====
Line 482: Line 686:
 <code>curl -k1 -u apiuser:apiuser -H "Content-Type: application/json" -X POST 'https://192.168.1.53/wapi/v2.13.6/dtc?_function=dtc_object_enable' \ <code>curl -k1 -u apiuser:apiuser -H "Content-Type: application/json" -X POST 'https://192.168.1.53/wapi/v2.13.6/dtc?_function=dtc_object_enable' \
 -d '{"dtc_object": "dtc:pool/ZG5zLmlkbnNfcG9vbCRib29rLXRlc3QucG9vbDE:webtest-pool-object1","enable_on": ["gridmanager.example.corp"]}'</code> -d '{"dtc_object": "dtc:pool/ZG5zLmlkbnNfcG9vbCRib29rLXRlc3QucG9vbDE:webtest-pool-object1","enable_on": ["gridmanager.example.corp"]}'</code>
 +
 +**Create LBDN**
 +<code>curl -k -u apiuser:apiuser -H "Content-Type: application/json" -X POST \
 +"https://192.168.1.53/wapi/v2.13.6/dtc:lbdn" \
 +-d '{
 +  "name": "web.internal.bank",
 +  "pattern": "web.internal.bank",
 +  "dns_view": "internal",
 +  "zone": "internal.bank",
 +  "network_view": "Zulu",
 +  "lb_method": "ROUND_ROBIN",
 +  "persistence": 0,
 +  "priority": 1,
 +  "pools": [
 +    {
 +      "name": "web.internal.bank-pool-1"
 +    }
 +  ],
 +  "record_types": ["A", "CNAME", "AAAA"],
 +  "ttl": 5,
 +  "override_ttl": true
 +}'
 +</code>
  
 ===== Network ===== ===== Network =====
Line 525: Line 752:
 zone=company.com& zone=company.com&
 view=EXTERNAL_VIEW</code> view=EXTERNAL_VIEW</code>
 +
 +**Get ALL Network Data **
 +
 +  * /wapi/v2.13/network
 +  * /wapi/v2.13/networkcontainer
 +  * /wapi/v2.13/ipv6network
 +  * /wapi/v2.13/ipv6networkcontainer
 + 
 +Should you require IPs, you'd need to add ipv4address and ipv6address and when fetching those you have to pass view and network. 
 +
 ===== NIOS Add Record ===== ===== NIOS Add Record =====
 # Create a record # Create a record
Line 670: Line 907:
 For very large results, you may need to add ''&_paging=1&_return_as_object=1&_max_results=1000''. For very large results, you may need to add ''&_paging=1&_return_as_object=1&_max_results=1000''.
 The return object will contain a next_page_id field, which you call in the following call with the same query but adding ''&_page_id={id_string_from_next_page_id}''. The return object will contain a next_page_id field, which you call in the following call with the same query but adding ''&_page_id={id_string_from_next_page_id}''.
 +===== NIOS Perl API =====
 +The Perl API (PAPI) has been officially deprecated since NIOS version 8.4.
 +
 +Starting from NIOS version 9.0.6, Perl module access is disabled by default.
 +
 +All future enhancements and fixes are now provided through the RESTful API (WAPI).
 +
 +To enable PAPI, the following CLI command must be executed: <code>set perl_mod_access</code>
 +
 +When you enable or disable the perl_mod_access, there will be no impact but the Grid interface (GUI) will be restarted. It doesn’t cause any service impact or appliance restart.
  
infoblox/api.1755605924.txt.gz · Last modified: by bstafford