OpenUV Playground
Support
OpenUV API Docs
Authorisation
To authorise your client just add your API KeyYOUR_API_KEY
to"x-access-token"
header for each request.
Hourly UV Index Forecast
Get hourly UV Index Forecast by location and date. Optional altitude, ozone level and datetime could be provided.
GET
https://api.openuv.io/api/v1/forecast
Request
curl -X GET \
'https://api.openuv.io/api/v1/forecast?lat=-33.34&lng=115.342&dt=2018-01-24T10:50:52.283Z' \
-H 'x-access-token: YOUR_API_KEY'
function getUVIndex() {
var lat = $('#lat').val();
var lng = $('#lng').val();
var alt = $('#alt').val();
var ozone = $('#ozone').val();
var dt = $('#dt').val();
$.ajax({
type: 'GET',
dataType: 'json',
beforeSend: function(request) {
request.setRequestHeader('x-access-token', 'YOUR_API_KEY');
},
url: 'https://api.openuv.io/api/v1/forecast?lat=' + lat + '&lng=' + lng + '&alt=' + alt + '&ozone=' + ozone + '&dt=' + dt,
success: function(response) {
//handle successful response
},
error: function(response) {
// handle error response
}
});
}
var request = require("request");
var options = { method: 'GET',
url: 'https://api.openuv.io/api/v1/forecast',
qs: { lat: '-33.34', lng: '115.342', dt: '2018-01-24T10:50:52.283Z' },
headers:
{ 'content-type': 'application/json',
'x-access-token': 'YOUR_API_KEY' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
require 'uri'
require 'net/http'
url = URI("https://api.openuv.io/api/v1/forecast?lat=-33.34&lng=115.342&dt=2018-01-24T10%3A50%3A52.283Z")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(url)
request["x-access-token"] = 'YOUR_API_KEY'
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.openuv.io/api/v1/forecast?lat=-33.34&lng=115.342&dt=2018-01-24T10%3A50%3A52.283Z")
.get()
.addHeader("x-access-token", "YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
import Foundation
let headers = [
"x-access-token": "YOUR_API_KEY"
]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.openuv.io/api/v1/forecast?lat=-33.34&lng=115.342&dt=2018-01-24T10%3A50%3A52.283Z")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
Parameters
* Drag marker or set values for testing
lat:
[req] - latitude, from-90.00
to90.00
lng:
[req] - longitude, from-180.00
to180.00
alt:
[opt] - altitude in meters, from0
to10000m
,0m
by default. If provided the altitude correction factor will be applied to clear sky sea level UV Index value.ozone:
[opt] - ozone in du (Dobson Units), from100
to550du
, the latest forecast from OMI dataset is used by default.dt:
[opt] - UTC datetime in[ISO-8601]
format (yyyy-MM-ddTHH:mm:ss.SSSZ
). Note just date part is important,today
by default.
Response
Success
200
result: [Array]
uv:
forecasted UV Index,[Float]
uv_time:
forecasted UV Index datetime in UTC,yyyy-MM-ddTHH:mm:ss.SSSZ
,[ISO-8601]
sun_position:
azimuth:
sun azimuth in radians (direction along the horizon, measured from south to west), e.g.0
is south andMath.PI * 3/4
is northwest ,[Double]
altitude:
sun altitude above the horizon in radians, e.g.0 at the horizon and
PI/2
at the zenith (straight over your head) ,[Double]
Error
403
422
500
error:
error description,[String]
FAQ
Will UV Index Forecast array in response vary in size from day to day?
Yep. It will vary from day to day, season to season and could even be empty for polar nights.
How to get UV Index Forecast for any date?
Just provide the desired datetime (with any time component) asdt
parameter.
JSON Response
SIGN IN FOR REAL DATA