<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to enter time query on Wireless usage API in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434540#M5564</link>
    <description>&lt;P&gt;You have...  &lt;SPAN&gt;ssid&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'3'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Should be an integer, try...    ssid=3&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Apr 2023 13:25:08 GMT</pubDate>
    <dc:creator>sungod</dc:creator>
    <dc:date>2023-04-11T13:25:08Z</dc:date>
    <item>
      <title>how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434537#M5561</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I know that I can run this Wireless usage API in Python but how do I query the last day or week?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And how do I add the SSID that I want to pull in the print(Response)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The results that I want to see is how many GB per day a particular SSID on an MR network is being used.  I am new to Python but want to learn quickly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;dashboard &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; meraki&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;DashboardAPI&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;API_KEY&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN&gt; network_id &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;'L_xxxxxxxxxxxxxxxxxxx'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;response &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; dashboard&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;wireless&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getNetworkWirelessUsageHistory&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN&gt; network_id &lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;SPAN class=""&gt;print&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Below is the Full API&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;A href="https://developer.cisco.com/meraki/api-v1/#!get-network-wireless-usage-history" target="_blank" rel="noopener nofollow noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/#!get-network-wireless-usage-history&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 02:05:47 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434537#M5561</guid>
      <dc:creator>tjh188</dc:creator>
      <dc:date>2023-04-11T02:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434538#M5562</link>
      <description>&lt;P class=""&gt;&lt;SPAN&gt;The usage would be...&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;response &lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; dashboard&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;wireless&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getNetworkWirelessUsageHistory&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN&gt; network_id &lt;/SPAN&gt;, t0=starttime, t1=endtime, ssid=netssid)   &lt;STRONG&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;edit: this won't work, the call also needs a specific client/device given, see post further down for alternatives&lt;/STRONG&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;Note that the call defaults to a resolution of 86400 seconds (one day), the return is an array of time slices, if you choose a resolution smaller than the time period you request data for, you'll get multiple time slices returned, each for a different part of the overall period.&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;EM&gt;t0&lt;/EM&gt; and &lt;EM&gt;t1&lt;/EM&gt; are strings, giving respectively the start and end of the period you want data for, they can be ISO format timestamps, or simple epoch timestamps (see... &lt;A href="https://www.epochconverter.com/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://www.epochconverter.com/&lt;/A&gt; for a way to manually make these), if you want scripts to automatically step through a range of dates, using epoch timestamps can be simpler.&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;If you just want some simple way to get a specific day, such as 31st March you could hardcode them...&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;starttime = "2023-03-31&lt;SPAN class=""&gt;T00:00:00Z"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;endtime = "2023-04-01&lt;SPAN class=""&gt;T00:00:00Z"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;...this is an ISO format datetime with the Z specifying this is UTC, if you're not working in UTC you'd need to adjust things.&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Doing the same with epoch timestamps would be...&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;starttime = str(&lt;SPAN&gt;1680217200)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;endtime = &lt;SPAN&gt;str(1680217200 + 86400)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;...note that you need to turn the integer into a string for the API call, and to get the end time I simply added 86400 seconds to the start time, much easier than creating the human readable format.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;If you want to automatically generate timestamps, there're &lt;STRONG&gt;many&lt;/STRONG&gt; ways Python can handle datetimes, best way to learn is make some simple script to get familiar, see...   &lt;A href="https://docs.python.org/3/library/datetime.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.python.org/3/library/datetime.html&lt;/A&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;EM&gt;netssid&lt;/EM&gt; is an integer identifying the SSID&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;To find the SSIDs on a network, use the getNetworkWirelessSsids call...&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;A href="https://developer.cisco.com/meraki/api-v1/#!get-network-wireless-ssids" target="_blank" rel="noopener nofollow noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/#!get-network-wireless-ssids&lt;/A&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;...it returns an array of all your SSIDs.&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;Or you can find the SSID number manually in Dashboard, go to the wireless SSID page, display all SSIDs, the leftmost one is 0, the next is 1, then 2, etc., it's just a simple integer.&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 11:10:55 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434538#M5562</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2023-04-11T11:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434539#M5563</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;meraki&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;json&lt;BR /&gt;&lt;BR /&gt;API_KEY = os.environ.get(&lt;SPAN&gt;"Meraki_API_KEY"&lt;/SPAN&gt;)&lt;BR /&gt;dashboard = meraki.DashboardAPI(API_KEY&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;suppress_logging&lt;/SPAN&gt;=&lt;SPAN&gt;True&lt;/SPAN&gt;)&lt;BR /&gt;organization_id = &lt;SPAN&gt;'xxxxxx'&lt;BR /&gt;&lt;/SPAN&gt;network_id = &lt;SPAN&gt;'L_xxxxxxxxxxxxxxxx'&lt;BR /&gt;&lt;/SPAN&gt;starttime = &lt;SPAN&gt;"2023-03-31T00:00:00Z"&lt;BR /&gt;&lt;/SPAN&gt;endtime = &lt;SPAN&gt;"2023-04-11T00:00:00Z"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;response = dashboard.wireless.getNetworkWirelessUsageHistory(network_id&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;t0&lt;/SPAN&gt;=starttime&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;t1&lt;/SPAN&gt;=endtime&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;ssid&lt;/SPAN&gt;=&lt;SPAN&gt;'3'&lt;/SPAN&gt;)&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;I don't get anything.  What am I doing wrong?  I get the error on line 12 (the response line).  Everything before that is good.&lt;/DIV&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:22:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434539#M5563</guid>
      <dc:creator>tjh188</dc:creator>
      <dc:date>2023-04-11T13:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434540#M5564</link>
      <description>&lt;P&gt;You have...  &lt;SPAN&gt;ssid&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'3'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Should be an integer, try...    ssid=3&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:25:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434540#M5564</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2023-04-11T13:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434541#M5565</link>
      <description>&lt;P&gt;meraki.exceptions.APIError: wireless, getNetworkWirelessUsageHistory - 400 Bad Request, {'errors': ['Must specify a device or network client']}&lt;/P&gt;&lt;P&gt;when I take the ''  off the 3, it gives me the above error.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 13:48:02 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434541#M5565</guid>
      <dc:creator>tjh188</dc:creator>
      <dc:date>2023-04-11T13:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434542#M5566</link>
      <description>&lt;P&gt;Ahh, just noticed in the overview for the API it says "&lt;SPAN&gt;Return AP usage over time for a device or network client&lt;/SPAN&gt;", so it's quite a selective call.&lt;/P&gt;&lt;P&gt;If you want data for all usage, a different API call would be better, for usage info on SSIDs across all networks, I suggest have a look at...&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;A href="https://developer.cisco.com/meraki/api-v1/#!get-organization-summary-top-ssids-by-usage" target="_blank" rel="noopener nofollow noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/#!get-organization-summary-top-ssids-by-usage&lt;/A&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;Call it like...&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;dashboard.&lt;/SPAN&gt;organizations.&lt;SPAN&gt;getOrganizationSummaryTopSsidsByUsage(t0=starttime, t1=endtime)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Otherwise if you need to be network-specific, look at using this...&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;&lt;A href="https://developer.cisco.com/meraki/api-v1/#!get-network-clients" target="_blank" rel="noopener nofollow noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/#!get-network-clients&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;t=86400&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;dashboard.networks.getNetworkClients(netid, timespan=t, perPage=&lt;SPAN class=""&gt;1000&lt;/SPAN&gt;, total_pages=&lt;SPAN class=""&gt;"all"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;...it will be more fiddly as you get a lot of data back and it'll be more complex to parse. Basically you need to iterate through return items, choose only those have an 'ssid' parameter present, then check if that ssid is the one you are interested in, if it is you look at the 'usage' element and add the sent and recv bytes to a running total.&lt;/P&gt;&lt;P class=""&gt; &lt;/P&gt;&lt;P class=""&gt;Also, the call only allows specifying either a t0/start time (but NOT a t1/end time), or a 'timespan' which is the number of seconds to look back before 'now', I call it every 24 hours to get the previous 86400 seconds of data.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 14:21:03 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434542#M5566</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2023-04-11T14:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to enter time query on Wireless usage API</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434543#M5567</link>
      <description>&lt;P&gt;I really need to find the answer to my original question.  Different API calls will not accomplish what I am wanting.  I need the total GB or MB from a week's time flowing only from one SSID.  I don't need to drill down to a client to get client data.  &lt;/P&gt;&lt;P&gt;I don't need the top devices.  I need all devices.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 01:03:40 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-enter-time-query-on-wireless-usage-api/m-p/5434543#M5567</guid>
      <dc:creator>tjh188</dc:creator>
      <dc:date>2023-04-12T01:03:40Z</dc:date>
    </item>
  </channel>
</rss>

