Currents
Global currents data for the next 10 days, including currents speed and direction.
Interface code | Interface | Class |
---|---|---|
oceanCurrents | Currents data | OceanCurrentsResponse |
Parameters
OceanParameter
-
location
(required)The currents station to be queried, need LocationID and LocationID can be obtained by POI Lookup. For example:location=P66981
-
date
(required)Set the date, up to 10 days in the future (including today). The date format is yyyyMMdd. Eexample:date=20200531
Sample code
Swift
Task{
do {
let sevenDaysAfter = Calendar.current.date(byAdding: .day, value: 7, to: Date())!
let formatter = DateFormatter()
formatter.dateFormat = "yyyMMdd"
let date = formatter.string(from: sevenDaysAfter)
let parameter = OceanParameter(location: "P66981", date: date)
let response = try await QWeather.instance
.oceanCurrents(parameter)
print(response)
} catch QWeatherError.errorResponse(let error) {
print(error)
} catch {
print(error)
}
}
Objective-C
NSDate * sevenDaysAfter = [[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitDay value:7 toDate:[NSDate date] options:0];
NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyyMMdd"];
NSString * date = [formatter stringFromDate:sevenDaysAfter];
OceanParameter *parameter = [OceanParameter instanceWithLocation:@"P66981" date:date];
[QWeatherObjc oceanCurrents:parameter completionHandler:^(OceanCurrentsResponse * _Nullable response, NSError * _Nullable error) {
if (response) {
NSLog(@"%@", response.description);
}
if (error) {
NSLog(@"%@", error.localizedDescription);
}
}];
Response
OceanCurrentsResponse
-
code
See Status Code -
updateTime
API last update time -
fxLink
Responsive web page of this data, for embedded in website or APP -
currentsTable.fxTime
Maximum speed time -
currentsTable.speedMax
Maximum speed, cm/sec -
currentsTable.dir360
Currents direction in azimuth degree -
currentsHourly.fxTime
Hourly forecast time -
currentsHourly.speed
Currents speed, cm/sec -
currentsHourly.dir360
Currents direction in azimuth degree -
refer.sources
Data source and other statements, may be null -
refer.license
Data license, may be null