Coder Social home page Coder Social logo

ipregistry / ipregistry-javascript Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 3.0 701 KB

Official Javascript Client for Ipregistry: a Non-Intrusive Solution for IP Geolocation and Threat Data.

Home Page: https://ipregistry.co

License: Apache License 2.0

TypeScript 99.10% JavaScript 0.90%
ipregistry javascript ipinfo ip2location ipdata geolocation api threats maxmind ip

ipregistry-javascript's Introduction

Iregistry

This repository is used to keep track of issues with all managed Ipregistry data and services (API, Data, Docker images, Website, etc.). Feel free to create a new issue to request a new feature or report any issues.

ipregistry-javascript's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar lpellegr avatar matiaslopezd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ipregistry-javascript's Issues

404 Not Found - GET https://registry.npmjs.org/@ipregistry%2fclient - Not found

Hello, it seems there's an issue with the npm install of this package?

sa@mbp: ~/0/edm  |master {1} S:2 U:3 ?:1 ✗| npm install --save-dev @ipregistry/client
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@ipregistry%2fclient - Not found
npm ERR! 404
npm ERR! 404  '@ipregistry/client@^3.0.0' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sa/.npm/_logs/2020-08-06T10_56_42_311Z-debug.log
sa@mbp: ~/0/edm

Return Remaining Credit and Rate Limit from http response headers

Hi, I'm really happy with the library, however from my testing I see that the API returns the following headers:
'Ipregistry-Credits',
'X-Rate-Limit-Limit',
'X-Rate-Limit-Remaining',

It would be great if the response from client.lookup(ipAddress)
could return these values so our application can notify us when we are approaching our limits.

I've put together a simple PR for my use-case here:
#4

thanks :)

import issues with Svelte / Sapper Project

I'm using Sapper which does server side rendering. There I have code calling the IPRegistry API using the javascript library of yours:

import { IpregistryClient, DefaultCache, IpregistryOptions } from '@ipregistry/client'

export default async ( ipAddress, filters ) => {
  try {
    const IPRClient = new IpregistryClient( `ROLLUP_IPREGISTRY_KEY`, new DefaultCache(16384) )

        return await IPRClient.lookup( ipAddress, IpregistryOptions.hostname(true), IpregistryOptions.filter(filters) )

  } catch ( error ) {
    console.log('error from call-to-ipregistry-api.js')
  }
}

Because with sapper you do SSR, then ship the page down to the client, den hydrate it you've to basically take care of server and client when importing. Other ES6 imports work fine, but using /@ipregistry/client I get this error in the console

src/node_modules/utils/ipregistry/call-to-ipregistry-api.js changed. rebuilding...
✗ client
'IpregistryClient' is not exported by node_modules/@ipregistry/client/dist/browser/index.js
1: import { IpregistryClient, DefaultCache, IpregistryOptions } from '@ipregistry/client'
            ^
2:
3: export default async ( ipAddress, filters ) => {
✗ server
'DefaultCache' is not exported by node_modules/@ipregistry/client/dist/esm/index.js
1: import { IpregistryClient, DefaultCache, IpregistryOptions } from '@ipregistry/client'
                              ^
2:
3: export default async ( ipAddress, filters ) => {
✔ service worker (29ms)

Note that a native axios version works just fine. This is what I had before:

import axios from 'axios'

export default async ( ipAddress, filters ) => {
  try {
    const ipRegistryResponse = await axios.get( `ROLLUP_IPREGISTRY_URL${ ipAddress }?key=ROLLUP_IPREGISTRY_KEY&hostname=true&fields=${ filters }` )
    return ipRegistryResponse.data
  } catch ( error ) {
    console.log('error from call-to-ipregistry-api.js')
  }
}

TypeScript Typing for Language Section Contains Mismatch

Hello there!

Thank you very much for this great project and your solid product!

However it seems the Language model's native_name: string | null; should've been native: string | null; instead, I'm wondering if you could double check?

Thank you and hope you have a great day!

Regards,
Hansheng

Send API Key in headers

How I can send the API key in headers with this library?

Also, I believe is too necessary to suggest using the "Authorization" header to maintain safe the API Key, instead of the param in the URL.

Thanks!

Access to remaining credits returns `null`

I've about 800k credits in my ipregistry account but since a while now I noticed from the logs I'm always getting null in my response. That wasn't the case a few months back iirc because back then i got the remaining credits logged correctly and I could use if (request.session.IPRegistryAPI.response.credits.remaining >= 1) { do stuff if there's credits left} which now breaks...

Screen Shot 2020-10-02 at 21 44 45

Above is the log from my firebase SSR function running the below code

// this is the callToIPRegistryAPI function which is used below

import ipregistry from '@ipregistry/client'

export default async ( ipAddress, filters ) => {
  try {
    // cache 16384 client entries for 24 hours
    const client = new ipregistry.IpregistryClient( 'my ipr key here', new ipregistry.DefaultCache( 16384, 3600 * 24 * 1000 ) )
    return await client.lookup( ipAddress, ipregistry.IpregistryOptions.hostname( true ), ipregistry.IpregistryOptions.filter( filters ) )

  } catch ( error ) {

    console.error('🔴 IPRegistry error code: ' + error.code)
    console.error('🔴 IPRegistry error message: ' + error.message)
    console.error('🔴 IPRegistry error resolution: ' + error.resolution)

  }
}

which is then used and console.logged which in turn gives null as shown in the screenshot above.

        request.session.IPRegistryAPI.response = await callToIPRegistryAPI( request.session.clientIPAddress.ip, 'hostname,location[in_eu,country.name,country.flag.emoji,region.name],security[is_threat,is_anonymous,is_tor_exit,is_bogon]' )
        console.log('request.session.IPRegistryAPI.response is: ', request.session.IPRegistryAPI.response)

What could cause the return value of null even though there are 800k credits left? I can't see an issue with my code and also it worked in the past and nothing changed with my code since then 🤔

make number of lookups which are cached configurable

I reckon it would make sense to maybe keep a default of 16 resp. 2048 lookups which are cached but make it configurable so that one could set the cache on his server to e.g. 16384 lookups which are cached.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.