UNPKG

duck-duck-scrape

Version:

Search from DuckDuckGo and use it's spice APIs.

105 lines (104 loc) 2.6 kB
import { NeedleOptions } from 'needle'; export interface TimeDateTime { year: number; month: number; day: number; hour: number; minute: number; second: number; } export interface TimeChanges { newdst: number; newzone: null; newoffset: number; /** ISO date string */ utctime: string; /** ISO date string */ oldlocaltime: string; /** ISO date string */ newlocaltime: string; verbose: { utctime: { datetime: TimeDateTime; }; oldlocaltime: { datetime: TimeDateTime; }; newlocaltime: { datetime: TimeDateTime; }; }; } export interface TimeLocation { id: string; geo: { name: string; state: string; country: { id: string; name: string; }; latitude: number; longitude: number; }; matches: string; score: number; time: { iso: string; datetime: { year: number; month: number; day: number; hour: number; minute: number; second: number; }; timezone: { offset: string; zoneabb: string; zonename: string; zoneoffset: number; zonedst: number; zonetotaloffset: number; }; }; timechanges: TimeChanges[]; astronomy: { objects: [ { name: 'sun'; events: [ { type: 'rise'; hour: number; minute: number; }, { type: 'set'; hour: number; minute: number; } ]; } ]; }; } /** * The result from the time spice. * @see https://services.timeanddate.com/api/doc/current/srv-timeservice.html */ export interface TimeResult { version: 1; info: string; locations?: TimeLocation[]; } /** * Search the time of locations with a query. * Data provided by TimeAndDate.com. * @category Spice * @see https://www.timeanddate.com/ * @param query The query to search with * @param needleOptions The options of the HTTP request * @returns The time result */ export declare function time(query: string, needleOptions?: NeedleOptions): Promise<TimeResult>;