<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[API - Shodan Blog]]></title><description><![CDATA[The latest news and developments for Shodan.]]></description><link>https://blog.shodan.io/</link><generator>Ghost 0.7</generator><lastBuildDate>Sun, 12 Apr 2026 02:08:36 GMT</lastBuildDate><atom:link href="https://blog.shodan.io/tag/api/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[How To:  Download Data using the API]]></title><description><![CDATA[<h6 id="howmuchdatacanidownload">How much data can I download?</h6>

<p>If you have an API plan then you get a certain number of <strong>query credits</strong> that you can spend each month. For people with the <a href="https://www.shodan.io/store/member">Shodan Membership</a> that means you get <strong>100 query credits</strong> per month while for the <a href="https://developer.shodan.io/pricing">API plans</a> it can range</p>]]></description><link>https://blog.shodan.io/how-to-download-data/</link><guid isPermaLink="false">8f18544c-91be-4ce3-93ea-a6fd4abc982c</guid><category><![CDATA[API]]></category><category><![CDATA[howto]]></category><dc:creator><![CDATA[John Matherly]]></dc:creator><pubDate>Thu, 14 Jul 2016 01:22:00 GMT</pubDate><media:content url="http://blog.shodan.io/content/images/2016/09/pingmap-4k.png" medium="image"/><content:encoded><![CDATA[<h6 id="howmuchdatacanidownload">How much data can I download?</h6>

<img src="http://blog.shodan.io/content/images/2016/09/pingmap-4k.png" alt="How To:  Download Data using the API"><p>If you have an API plan then you get a certain number of <strong>query credits</strong> that you can spend each month. For people with the <a href="https://www.shodan.io/store/member">Shodan Membership</a> that means you get <strong>100 query credits</strong> per month while for the <a href="https://developer.shodan.io/pricing">API plans</a> it can range from <strong>10,000</strong> up to <strong>unlimited</strong>.</p>

<blockquote>
  <p>1 query credit = 100 results</p>
</blockquote>

<p>Every query credit gets you up to 100 results, which means that you can download at least <strong>10,000</strong> results every month - regardless of the type of search you're performing.</p>

<h6 id="usingthecommandlinetool">Using the Command-Line Tool</h6>

<p>The <a href="https://cli.shodan.io">Shodan CLI</a> provides a command to easily download data using the query credits from your API. Here's a quick video that shows how it works in action:</p>

<script type="text/javascript" src="https://asciinema.org/a/85007.js" id="asciicast-85007" async></script>

<p>The basics of it are:</p>

<pre><code>shodan download --limit &lt;number of results&gt; &lt;filename&gt; &lt;search query&gt;
</code></pre>

<p>For example, this is the command to download 500 results for the search query "product:mongodb" which returns Internet-facing MongoDB services:</p>

<pre><code>shodan download --limit 500 mongodb-results product:mongodb
</code></pre>

<p>The results of the above command will be saved in a file called <strong>mongodb-results.json.gz</strong>. At this point, you can easily convert the file into CSV, KML or simply output a list of IP:port pairs by using the <strong>shodan parse</strong> command:</p>

<pre><code>shodan parse --fields ip_str,port --separator , mongodb.json.gz
</code></pre>

<h6 id="programmingwiththeshodanapi">Programming with the Shodan API</h6>

<p>The <a href="https://cli.shodan.io">CLI</a> should work for most people but sometimes you want to perform custom transformations on the banners as you're downloading them. Or you don't want to store the information in a local file. In those cases, you can use a convenient helper method provided by the Python library for Shodan called <strong>search_cursor()</strong> to iterate over the results:</p>

<pre><code>import shodan

api = shodan.Shodan('Your API key')

limit = 500
counter = 0
for banner in api.search_cursor('product:mongodb'):
    # Perform some custom manipulations or stream the results to a database
    # For this example, I'll just print out the "data" property
    print(banner['data'])

    # Keep track of how many results have been downloaded so we don't use up all our query credits
    counter += 1
    if counter &gt;= limit:
        break
</code></pre>]]></content:encoded></item><item><title><![CDATA[Introducing the Shodan Real-Time Stream]]></title><description><![CDATA[<p>Do you want to keep an eye on the latest results coming into Shodan? Want to create your own custom data feeds? Or want to grab a few thousand random web servers for your research? Using the Streaming API from Shodan you can directly subscribe to the raw data feed</p>]]></description><link>https://blog.shodan.io/shodan-real-time-stream/</link><guid isPermaLink="false">05c71efa-c8a3-4183-8c9d-7ef1aa84e136</guid><category><![CDATA[API]]></category><category><![CDATA[Shodan]]></category><category><![CDATA[Firehose]]></category><category><![CDATA[Stream]]></category><category><![CDATA[Developers]]></category><dc:creator><![CDATA[John Matherly]]></dc:creator><pubDate>Thu, 23 Jul 2015 03:12:59 GMT</pubDate><media:content url="http://blog.shodan.io/content/images/2015/07/DsHZk.png" medium="image"/><content:encoded><![CDATA[<img src="http://blog.shodan.io/content/images/2015/07/DsHZk.png" alt="Introducing the Shodan Real-Time Stream"><p>Do you want to keep an eye on the latest results coming into Shodan? Want to create your own custom data feeds? Or want to grab a few thousand random web servers for your research? Using the Streaming API from Shodan you can directly subscribe to the raw data feed from the crawlers! The feed streams between 400-500 banners every second and depending on your API plan you have access to all or a fraction of it. And to get started with the stream you don't need any programming knowledge, just install the <a href="https://cli.shodan.io">Shodan command-line tool</a> and you're good to go. I've created a video that highlights some of the basic usage using the <strong>shodan</strong> command. Note that unless you use <strong>--limit</strong> or hit CTRL + C the stream will continue going forever:</p>

<script type="text/javascript" src="https://asciinema.org/a/23809.js" id="asciicast-23809" async></script>

<h4 id="shodanstream">shodan stream</h4>

<p>At the heart is the <strong>stream</strong> command that when run by itself will simply stream all data you have access to and print it to your terminal. It won't store the data anywhere or perform any operations on it. Use this command if you'd like to explore random IPs on the Internet.</p>

<h6 id="ports">--ports</h6>

<p>Often you're only interested in a certain type of service, and for those instances you can narrow down the stream using the <strong>--ports</strong> option. You can provide one port:</p>

<pre><code>shodan stream --ports 23
</code></pre>

<p>Or many ports:</p>

<pre><code>shodan stream --ports 23,1023
</code></pre>

<p>And without any other arguments it will once again just print the results to the terminal.</p>

<h6 id="datadir">--datadir</h6>

<p>Most of the time you also want to store the results so you're not throwing away information. To do so, simply create a directory and supply the <strong>--datadir</strong> option to the streaming command. This will result in the shodan tool storing the results from the stream in a file in the data folder, where the file name is the current date in YYYY-MM-DD.json.gz format:</p>

<pre><code>mkdir shodan-data
shodan stream --datadir shodan-data
</code></pre>

<p>This is useful so you can keep the streaming command running and every day a new file will automatically be created for you. And then you can use the <strong>shodan parse</strong> command to extract the information you care about.</p>

<h6 id="limit">--limit</h6>

<p>Sometimes you want to get a random sample of results. Lets say you'd like to see how many of the most recent 10,000 results are Nginx vs Apache vs Lighttpd etc. You can take periodic samplings to see how those trends change over time using your own computer. To get 10,000 web server results use the <strong>--limit</strong> option to make the stream command exit after it has received the provided number of results:</p>

<pre><code>shodan stream --limit 10000 --ports 80
</code></pre>

<p>The above command would filter the stream for web servers running on port 80 (<strong>--port 80</strong>) and it would exit after 10,000 results were received (<strong>--limit</strong>).</p>

<p>I use the real-time stream for a lot of my own research and I hope you'll find it useful as well! If you have any thoughts, questions or suggestions please let me know <a href="https://twitter.com/achillean">@achillean</a></p>]]></content:encoded></item><item><title><![CDATA[Keeping Up with SSL]]></title><description><![CDATA[<p>SSL is becoming an evermore important aspect of serving and consuming content on the Internet, so it's only fit that Shodan extends the information that it gathers for every SSL-capable service. The banners for SSL services, such as HTTPS, have included the certificate in PEM format for a long time</p>]]></description><link>https://blog.shodan.io/ssl-update/</link><guid isPermaLink="false">2b4901ed-1657-4979-a6a5-a4c82a7051c0</guid><category><![CDATA[SSL]]></category><category><![CDATA[Filters]]></category><category><![CDATA[Facets]]></category><category><![CDATA[API]]></category><category><![CDATA[Reports]]></category><dc:creator><![CDATA[John Matherly]]></dc:creator><pubDate>Mon, 16 Feb 2015 23:55:00 GMT</pubDate><content:encoded><![CDATA[<p>SSL is becoming an evermore important aspect of serving and consuming content on the Internet, so it's only fit that Shodan extends the information that it gathers for every SSL-capable service. The banners for SSL services, such as HTTPS, have included the certificate in PEM format for a long time and you've been able to access that data through the <a href="https://developer.shodan.io/api">REST API</a> or <a href="http://shodan.readthedocs.org/en/latest/examples/cert-stream.html">real-time stream</a>.</p>

<p>After spending some time fixing bugs and making sure it scales, I'm happy to say that Shodan is now also collecting the following information:</p>

<ul>
<li>Parsed certificate</li>
<li>Certificate chain</li>
<li>Supported SSL versions</li>
<li>Preferred cipher</li>
</ul>

<p><img src="https://blog.shodan.io/content/images/2015/02/SSL-Survey---Shodan.png" alt="Distribution of supported SSL versions on the Internet"></p>

<p>All the SSL information has been put into property on the top-level called <strong>ssl</strong> instead of being dug into the <strong>opts</strong> field. This is how it looks like right now:</p>

<pre><code>"ssl": {
    "cert": {
        "sig_alg": "sha1WithRSAEncryption",
        "issued": "20110325103212Z",
        "expires": "20120324103212Z",
        "expired": true,
        "version": 2,
        "extensions": [{
            "data": "\u0003\u0002\u0006@",
            "name": "nsCertType"
        }],
        "serial": 10104044343792293356,
        "issuer": {
            "C": "TW",
            "L": "TAIPEI",
            "O": "CAMEO",
            "ST": "TAIWAN"
        },
        "pubkey": {
            "bits": 1024,
            "type": "rsa"
        },
        "subject": {
            "C": "TW",
            "L": "TAIPEI",
            "O": "CAMEO",
            "ST": "TAIWAN"
        }
    },
    "cipher": {
        "version": "TLSv1/SSLv3",
        "bits": 256,
        "name": "AES256-SHA"
    },
    "chain": ["-----BEGIN CERTIFICATE-----  \nMIICETCCAXqgAwIBAgIJAIw4xswSiNXsMA0GCSqGSIb3DQEBBQUAMD8xCzAJBgNV\nBAYTAlRXMQ8wDQYDVQQIEwZUQUlXQU4xDzANBgNVBAcTBlRBSVBFSTEOMAwGA1UE\nChMFQ0FNRU8wHhcNMTEwMzI1MTAzMjEyWhcNMTIwMzI0MTAzMjEyWjA/MQswCQYD\nVQQGEwJUVzEPMA0GA1UECBMGVEFJV0FOMQ8wDQYDVQQHEwZUQUlQRUkxDjAMBgNV\nBAoTBUNBTUVPMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCj8HWSuWUHYWLD\nASV1KCWd9+9U19tINKgY8CTw/gKeVoF6bjgQ3tuXliScLAsU8nNGiZibaXq9KR67\nnLjjHzFiJDr6s8M3qimLdhcA7kf71v806Mls4KctdrMUiX3Bc7WvYtbClke0QDlC\nFGgK7HksEWpQ026E3pI0T/2mTvbeXQIDAQABoxUwEzARBglghkgBhvhCAQEEBAMC\nBkAwDQYJKoZIhvcNAQEFBQADgYEANbiCHCROX0X9ZbBaOsijkGh6+7WLaLUDEUpp\nrw+bHFKhOvtQgEyQ01U0V9ZYtdPyVLnNVmJu6Q8MPuqBCkpcv0/gH31YSSRyOhid\nvc+qCUCA7UBqt5f7QVOOYPqhzieoUO+pmQ3zidcwUGYh19gQv/fl7SnG00cDgxg3\nm89S7ao=\n-----END CERTIFICATE-----\n"],
    "versions": ["TLSv1", "SSLv3", "-SSLv2", "-TLSv1.1", "-TLSv1.2"]
}
</code></pre>

<p>The <strong>ssl.versions</strong> field is a list of SSL versions that the device permits and denies. If the version has a <strong>-</strong> (dash) in front of the version, then the device <strong>does not</strong> support that SSL version. If the version doesn't begin with a <strong>-</strong>, then the service supports the given SSL version. For example, the above server supports:</p>

<ul>
<li>TLSv1</li>
<li>SSLv3</li>
</ul>

<p>And it denies versions:</p>

<ul>
<li>SSLv2</li>
<li>TLSv1.1</li>
<li>TLSv1.2</li>
</ul>

<p>The information that used to be stored in the <strong>opts.pem</strong> field is now available in the <strong>ssl.chain</strong> field, which is basically an array of PEM-serialized certificates. If you'd like to access the parsed information of the service's main certificate then you can get that directly from the <strong>ssl.cert</strong> property. It's the parsed SSL certificate made accessible in a programmer-friendly way (parsing certificates can be a pain...).</p>

<h4 id="newsslfiltersandfacets">New SSL Filters and Facets</h4>

<p>Alongside these new properties, I'm also re-introducing revamped SSL filters and facets. The following <strong>new filters and facets</strong> are available in Shodan to search the SSL data:</p>

<ul>
<li>ssl.chain_count</li>
<li>ssl.version</li>
<li>ssl.cert.alg</li>
<li>ssl.cert.expired</li>
<li>ssl.cert.extension</li>
<li>ssl.cert.serial</li>
<li>ssl.cert.pubkey.bits</li>
<li>ssl.cert.pubkey.type</li>
<li>ssl.cipher.version</li>
<li>ssl.cipher.bits</li>
<li>ssl.cipher.name</li>
</ul>

<p>Using these filters, you can for example keep track of devices that <strong>only allow SSLv2</strong> - a deprecated version of SSL that nothing should exclusively support:</p>

<p><a href="https://www.shodan.io/search?query=ssl.version%3Asslv2">ssl.version:sslv2</a></p>

<p>Or you can generate a distribution of certificate chain lengths by faceting on <strong>ssl.chain_count</strong>:</p>

<p><img src="https://blog.shodan.io/content/images/2015/02/ssl-chain-length.png" alt=""></p>

<p>The above chart shows that the majority of SSL certificates are self-signed and don't trace back to a root.</p>

<p>The reports that Shodan generates also take advantage of this new SSL information, so keep an eye out for those charts in your new reports. For example, here's a general report on the state of SSL usage on the Internet:</p>

<p><a href="https://www.shodan.io/report/EvoSNCVF">https://www.shodan.io/report/EvoSNCVF</a></p>

<p>I'm excited to be collecting this new data and I'd love to hear your thoughts (<a href="https://twitter.com/achillean">@achillean</a>). As always, if there's something you'd like to see me add just <a href="mailto:jmath@shodan.io">send me an email</a></p>]]></content:encoded></item></channel></rss>