Socket
Book a DemoInstallSign in
Socket

worldtimeapi-lib

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

worldtimeapi-lib

Basic library for calling http://worldtimeapi.com programatically.

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

world time API lib

This simple library exposes one function getTimezone, which will take care of everything the underlying API allows.

Preconditions

  • have Node.js LTS with npm installed. Library enforces using Node.js version 20.x or higher, due to internal usage of fetch function.

Usage

Get all timezones' areas

import { getTimezone } from "worldtimeapi-lib";

const [data, status] = await getTimezone();

if (status) {
  console.log(JSON.stringify(data));
}

Get specific area with its locations

const [data, status] = await getTimezone({ timezone: "Europe" });

Get specific location data of the area timezone

const [data, status] = await getTimezone({ timezone: "Europe/Prague" });

Get data for IP address

IP address is not provided

import { getIpAddress } from "worldtimeapi-lib";

const [data, status] = await getIpAddress();

if (status) {
  console.log(JSON.stringify(data));
}

IP address explicitly provided

const [data, status] = await getIpAddress({ ip: "8.8.8.8" });

Keywords

worldtimeapi

FAQs

Package last updated on 20 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts