OpenUV API Docs

device_hub

event_note

Support

account_balance
help_outline
headset_mic
Buy Me A Coffee

OpenUV API Docs


Authorisation

To authorise your client just add your API Key YOUR_API_KEY to "x-access-token" header for each request.

* By signing in you agree with Terms of Service

Real-time UV Index

Get real-time UV Index by location. Optional altitude, ozone level and datetime could be provided as query parameters.

GET

https://api.openuv.io/api/v1/uv

Request

curl -X GET \
'https://api.openuv.io/api/v1/uv?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/uv?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/uv',
 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/uv?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/uv?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/uv?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 map marker and set values for testing

  • lat: [req] - latitude, from -90.00 to 90.00
  • lng: [req] - longitude, from -180.00 to 180.00
  • alt: [opt] - altitude in meters, from 0 to 10000m, 0 by default. If provided, the altitude correction factor will be applied to a clear sky sea level UV Index.
  • ozone: [opt] - ozone in du (Dobson Units), from 100 to 550du, latest value from OMI dataset by default.
  • dt: [opt] - UTC datetime in [ISO-8601] format (yyyy-MM-ddTHH:mm:ss.SSSZ), now by default.

Response

Success

200
  • result:
    • uv:UV Index (real-time or forecasted depending on dtparameter) ,[Double]
    • uv_time:UV Index datetime in UTC, yyyy-MM-ddTHH:mm:ss.SSSZ,[ISO-8601]
    • uv_max:max UV Index for the day (at solar noon)
    • uv_max_time:max UV Index datetime (solar noon) in UTC, yyyy-MM-ddTHH:mm:ss.SSSZ,[ISO-8601]
    • ozone:ozone level in du (Dobson Units) from OMI data or request (if provided) ,[Double]
    • ozone_time:Latest OMI ozone update datetime in UTC, yyyy-MM-ddTHH:mm:ss.SSSZ,[ISO-8601]
    • safe_exposure_time:safe exposure time for Fitzpatrick Skin Types
      • st1:safe exposure time (mins) till burn for Skin Type 1,[Number]
      • st2:safe exposure time (mins) till burn for Skin Type 2,[Number]
      • st3:safe exposure time (mins) till burn for Skin Type 3,[Number]
      • st4:safe exposure time (mins) till burn for Skin Type 4,[Number]
      • st5:safe exposure time (mins) till burn for Skin Type 5,[Number]
      • st6:safe exposure time (mins) till burn for Skin Type 6,[Number]
    • sun_info: (*courtesy of suncalc.js)
      • sun_times:
        • sunrise:sunrise (top edge of the sun appears on the horizon) ,
        • sunriseEnd:sunrise ends (bottom edge of the sun touches the horizon) ,[ISO-8601]
        • goldenHourEnd:morning golden hour (soft light, best time for photography) ends ,[ISO-8601]
        • solarNoon:solar noon (sun is in the highest position) ,[ISO-8601]
        • goldenHour:evening golden hour starts ,[ISO-8601]
        • sunsetStart:sunset starts (bottom edge of the sun touches the horizon) ,[ISO-8601]
        • sunset:sunset starts (bottom edge of the sun touches the horizon) ,[ISO-8601]
        • dusk:dusk (evening nautical twilight starts) ,[ISO-8601]
        • nauticalDusk:nautical dusk (evening astronomical twilight starts) ,[ISO-8601]
        • night:night starts (dark enough for astronomical observations) ,[ISO-8601]
        • nadir:nadir (darkest moment of the night, sun is in the lowest position) ,[ISO-8601]
        • nightEnd:night ends (morning astronomical twilight starts) ,[ISO-8601]
        • nauticalDawn:nautical dawn (morning nautical twilight starts) ,[ISO-8601]
        • dawn:dawn (morning nautical twilight ends, morning civil twilight starts) ,[ISO-8601]
      • sun_position:
        • azimuth:sun azimuth in radians (direction along the horizon, measured from south to west), e.g. 0 is south and Math.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

JSON Response

SIGN IN FOR REAL DATA