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 KeyYOUR_API_KEYto "x-access-token"header for each request.

* By signing in you agree with Terms of Service

Daily Protection Time

Get protection time by location, UV "from" and UV "to" values with 10 minutes accuracy. Optional altitude and ozone level could be provided.

GET

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

Request

curl -X GET \
'https://api.openuv.io/api/v1/protection?lat=-33.34&lng=115.342&from=3.5&to=3.7' \
-H 'x-access-token: YOUR_API_KEY'
function getUVIndex() {
 var lat = $('#lat').val();
 var lng = $('#lng').val();
 var from = $('#from').val();
 var to = $('#to').val();
 var alt = $('#alt').val();
 var ozone = $('#ozone').val();

 $.ajax({
   type: 'GET',
   dataType: 'json',
   beforeSend: function(request) {
     request.setRequestHeader('x-access-token', 'YOUR_API_KEY');
   },
   url: 'https://api.openuv.io/api/v1/protection?lat=' + lat + '&lng=' + lng + '&from=' + from + '&to=' + to,
   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/protection',
 qs: { lat: '-33.34', lng: '115.342', from: '3.5', to: '3.7' },
 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/protection?lat=-33.34&lng=115.342&from=3.5&to=3.7")
 
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/protection?lat=-33.34&lng=115.342&from=3.5&to=3.7")
 .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/protection?lat=-33.34&lng=115.34&from=3.5&to=3.7")! 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 to 90.00
  • lng: [req] - longitude, from -180.00 to 180.00
  • from: [opt] - UV Index 'from' value for protection datetime lookup. 3.5 by default.
  • to: [opt] - UV Index 'to' value for protection datetime lookup. 3.5 by default.
  • alt: [opt] - altitude in meters, from 0 to 10000m, 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), from 100 to 550du, the latest forecast from OMI dataset is used by default.

Response

  • from_time:"protection from" datetime, UTC, yyyy-MM-ddTHH:mm:ss.SSSZ. Null if no datetime found, [ISO-8601]
  • from_uv:estimated UV Index at "protection from" datetime, [Float]
  • to_time:"protection to" datetime, UTC, yyyy-MM-ddTHH:mm:ss.SSSZ. Null if no datetime found,[ISO-8601]
  • to_uv:estimated UV Index at "protection to" datetime, [Float]

Error

403
422
500
  • error:error description, [String]

FAQ

JSON Response

SIGN IN FOR REAL DATA