8000 GitHub - fgcoelho/ipquery-js: 🌐 ipquery sdk for javascript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fgcoelho/ipquery-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
< CDD1 div class="Skeleton Skeleton--text"> 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌐 ipquery-js

What is IPQuery?

A very cool service for fetching information about IP addresses.

Disclaimer

This package is not affiliated, associated neither endorsed by IPQuery.

Install

# npm
npm install ipquery

# pnpm
pnpm add ipquery

# yarn
yarn add ipquery

Usage

Fetching your own ip

import { ip } from 'ipquery'

const myself = async () => await ip.query("self")

Fetching an specific ip

import { ip } from 'ipquery'

const processPayment = async (customer: Customer) => {
    
    const ipAddress = await ip.query(customer.ip)

    const timezone = ip.location.timezone

    ...
}

Bulk requesting ips (up to 10k)

import { ip } from 'ipquery'

const getUsersTimezones = async (users: User[]) => {
    const ips = await ip.query(users.map(u => u.ip))

    const timezones = ips.map(ip => ip.location.timezone)

    return timezones
}

Response formatting

import { ip } from 'ipquery'

const getYamlIp = async (ipAddress: string) => {
    const yamlText = await ip.query(ipAddress, { format: "yaml" })

    return yamlText
}

Caching

By default, ip.query will cache no more than 100 items, and it will clear after 5 minutes.

You can config or opt out the caching by using ip.config({ cache }) somewhere in your app.

About

🌐 ipquery sdk for javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0