<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dmitry Ivanov on Medium]]></title>
        <description><![CDATA[Stories by Dmitry Ivanov on Medium]]></description>
        <link>https://medium.com/@dmitry.g.ivanov?source=rss-1febd737ae0f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ofmR5ubwQqtyunf5nlA3Zg.jpeg</url>
            <title>Stories by Dmitry Ivanov on Medium</title>
            <link>https://medium.com/@dmitry.g.ivanov?source=rss-1febd737ae0f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 13:50:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dmitry.g.ivanov/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Weather Forecast in PHP]]></title>
            <link>https://medium.com/@dmitry.g.ivanov/weather-forecast-in-php-95bca6b0ed18?source=rss-1febd737ae0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/95bca6b0ed18</guid>
            <category><![CDATA[weather]]></category>
            <category><![CDATA[forecast]]></category>
            <category><![CDATA[dark-sky-api]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Dmitry Ivanov]]></dc:creator>
            <pubDate>Tue, 11 Dec 2018 12:17:21 GMT</pubDate>
            <atom:updated>2018-12-11T12:17:21.569Z</atom:updated>
            <content:encoded><![CDATA[<p>PHP Library for the Dark Sky API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Ckr0WOUPRyLpp7FE-P-1Sg.png" /></figure><p>One of the projects I was working with recently, required the weather forecast functionality. There is a bunch of the <a href="https://blog.rapidapi.com/access-global-weather-data-with-these-weather-apis/">weather</a> <a href="https://superdevresources.com/weather-forecast-api-for-developing-apps/">forecast</a> <a href="https://programmableweb.com/news/top-10-weather-apis/analysis/2014/11/13">providers</a>, so that you may choose from many options. I’ve chosen the <a href="https://darksky.net/dev">Dark Sky API</a> for myself and created the <a href="https://github.com/dmitry-ivanov/dark-sky-api">PHP Library</a> for it. This article would give you some extra tips and tricks about the usage of the Dark Sky API and the PHP Library itself.</p><h3>Dark Sky Account</h3><p>First of all, you have to <a href="https://darksky.net/dev/register">register</a> and get your <a href="https://darksky.net/dev/account">secret key</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-nXZxZey8ErSR48eFbWrg.png" /><figcaption>Your “Secret Key” to access the Dark Sky API.</figcaption></figure><p>Dark Sky provides 1,000 free API requests every day. You can use those free requests right after registering, with your brand new secret key.</p><p>If you need more, you have to provide your <a href="https://darksky.net/dev/account/edit">Billing Information</a>. Each API request over the free daily limit costs $0.0001. In other words, every extra 10,000 API requests would cost you $1.00. For example, 51,000 requests per day would cost $5.00 per day: 1,000 free requests + 50,000 paid requests.</p><p>You may set the <a href="https://darksky.net/dev/account/edit">Daily Usage Limit</a> to make your payments more predictable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvKSIvKMU2JSrRgX9fOD6g.png" /><figcaption>Set the “Daily Usage Limit” to make your payments more predictable.</figcaption></figure><h3>Installation</h3><p><a href="https://github.com/dmitry-ivanov/dark-sky-api">PHP Library</a> is a stand-alone PHP package, which means that you can use it in any PHP application, no matter which framework do you use (if using any).</p><p>It requires at least <a href="https://secure.php.net/releases/#5.5.9">PHP 5.5.9 (6 Feb 2014)</a> which covers the vast majority of the existing and new PHP applications.</p><p>You may use <a href="https://getcomposer.org/">Composer</a> to install it into your project:</p><pre>composer require dmitry-ivanov/dark-sky-api</pre><h3>Usage</h3><p>The Dark Sky API provides two types of requests: <a href="https://darksky.net/dev/docs#forecast-request">Forecast Request</a> and <a href="https://darksky.net/dev/docs#time-machine-request">Time Machine Request</a>. Forecast Request provides the weather data related to the current moment, and Time Machine Request allows <em>you</em> to specify the time.</p><p>Each request utilizes HTTP compression, as <a href="https://darksky.net/dev/docs#response-notes">API suggests</a>. Multiple Time Machine Requests are sent concurrently, which is <em>much more performant</em>.</p><h4>Forecast Request</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30c0a6c518cc38321519f778779e4984/href">https://medium.com/media/30c0a6c518cc38321519f778779e4984/href</a></iframe><p>Required parameters are the secret-key and location (which is <a href="https://en.wikipedia.org/wiki/Odessa">my hometown</a> in this example). You may omit the <a href="https://darksky.net/dev/docs#request-parameters">units</a> and the <a href="https://darksky.net/dev/docs#request-parameters">language</a> parameters. The Dark Sky API would use the default values in that case.</p><p>The response is represented by the data blocks, such as currently, minutely, hourly, daily, etc. Request obtains all of the data blocks by default, which is unnecessary in many situations and may be optimized.</p><p>Dark Sky API provides the <a href="https://darksky.net/dev/docs#request-parameters">exclude</a> parameter to manage the response data. Let’s imagine you need only the currently block. API suggests using the exclude=minutely,hourly,daily,alerts,flags parameter in that case.</p><p>You have to specify everything you want to <em>exclude </em>from the response.</p><p>But I think it’s more natural to specify what do you want to <em>include, </em>actually:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebb6a2a4cc877457efc728b7dc3a73ab/href">https://medium.com/media/ebb6a2a4cc877457efc728b7dc3a73ab/href</a></iframe><p>You may use an array if you want to <em>include</em> several blocks:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c24d568a862a60daacdf03e257af486/href">https://medium.com/media/0c24d568a862a60daacdf03e257af486/href</a></iframe><p>Check the <a href="https://darksky.net/dev/docs#response-format">Response Format</a> to see all of the available properties.</p><h4>Time Machine Request</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/838bbef59f641aedb579bbeb286ca55e/href">https://medium.com/media/838bbef59f641aedb579bbeb286ca55e/href</a></iframe><p>Time Machine Requests provide an ability to specify the date, for which you want to get the weather data. The “date” also may have the time part, and any “<a href="https://secure.php.net/manual/en/function.strtotime.php">strtotime</a>” string is acceptable, e.g. 1 Dec 2018, 2018-12-01 15:30:00, etc.</p><p>Of course, you can manage the response data, as well:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b97c5e5d59be020239aa3c54b8cc920d/href">https://medium.com/media/b97c5e5d59be020239aa3c54b8cc920d/href</a></iframe><p>You may use an array of dates for multiple requests:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c9091bea7620582dbe3eb422282b579/href">https://medium.com/media/9c9091bea7620582dbe3eb422282b579/href</a></iframe><p>Multiple Time Machine Requests are sent concurrently, and it’s <em>much faster</em> than sending them one after another. Note that an array is returned in that case, and the requested dates are used as its keys.</p><h4>Headers, Alerts, and Flags</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/473de77eb08f2b3d0b4c7ce3efb7ae02/href">https://medium.com/media/473de77eb08f2b3d0b4c7ce3efb7ae02/href</a></iframe><p>The package also provides object-level access to the <a href="https://darksky.net/dev/docs#response-headers">Response Headers</a>, <a href="https://darksky.net/dev/docs#alerts">Weather Alerts</a>, and <a href="https://darksky.net/dev/docs#flags">Flags</a>. Check the documentation to see available props.</p><h3>Laravel Support</h3><p>The last, but not the least is the Laravel support.</p><p>The package utilizes <a href="https://laravel.com/docs/master/packages#package-discovery">Laravel Package Discovery</a>. If you’re using Laravel 5.5+, you will get the registered service provider and alias out-of-the-box.</p><h4>Usage</h4><p>Set your Secret Key in .env file:</p><pre>DARK_SKY_KEY=&quot;Your Secret Key&quot;</pre><p>You may use the configured <a href="https://laravel.com/docs/master/facades">facade</a> now:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4249c18de9e8d1f063a222bcb8a7edd/href">https://medium.com/media/b4249c18de9e8d1f063a222bcb8a7edd/href</a></iframe><p>Publish the config file to override request parameters (optionally):</p><pre>php artisan vendor:publish --provider=&quot;DmitryIvanov\DarkSkyApi\Adapters\Laravel\DarkSkyApiServiceProvider&quot;</pre><p>I hope that this package and this article would be useful for you. It was exciting for me to create it, and I enjoyed to use the Dark Sky API overall.</p><p>And, of course, I am the first <a href="https://skygetty.com/">user of my package</a>.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95bca6b0ed18" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>