The main client for interacting with the Ipregistry API. This class provides methods for looking up IP information, ASN details, parsing user agents, and more.

Constructors

  • Constructs an IpregistryClient instance for API operations.

    Parameters

    • keyOrConfig: string | IpregistryConfig

      The API key as a string or an IpregistryConfig instance for custom configurations.

    • Optionalcache: IpregistryCache

      Optional. An instance implementing the IpregistryCache interface for caching responses.

    • OptionalrequestHandler: IpregistryRequestHandler

      Optional. A custom handler for API requests.

    Returns IpregistryClient

Methods

  • Performs a batch lookup of Autonomous System Numbers (ASNs) and returns their information or errors. This method can leverage caching to avoid unnecessary API requests.

    Parameters

    • asns: number[]

      An array of ASNs (Autonomous System Numbers) to lookup.

    • Rest...options: IpregistryOption[]

      Optional. Additional options for the lookup operation.

    Returns Promise<ApiResponse<(AutonomousSystem | LookupError)[]>>

    A Promise resolving to an ApiResponse containing an array of AutonomousSystem or LookupError objects.

  • Performs a batch lookup of IP addresses and returns their information or errors. Similar to batchLookupAsns, this method also supports caching.

    Parameters

    • ips: string[]

      An array of IP addresses to lookup.

    • Rest...options: IpregistryOption[]

      Optional. Additional options for the lookup operation.

    Returns Promise<ApiResponse<(IpInfo | LookupError)[]>>

    A Promise resolving to an ApiResponse containing an array of IpInfo or LookupError objects.

  • Looks up information for a single IP address.

    Parameters

    • ip: string

      The IP address to lookup.

    • Rest...options: IpregistryOption[]

      Optional. Additional options for the lookup operation.

    Returns Promise<ApiResponse<IpInfo>>

    A Promise resolving to an ApiResponse containing the IpInfo.

  • Performs a lookup for the ASN information of the originating request's IP address. This is particularly useful for understanding the ASN of the caller itself. Note: Caching is incompatible with this method. Every call will incur a remote request to the Ipregistry API, which may consume credits or incur costs depending on your plan.

    Parameters

    • Rest...options: IpregistryOption[]

      Optional. Additional options for the lookup operation.

    Returns Promise<ApiResponse<RequesterAutonomousSystem>>

    A Promise resolving to an ApiResponse containing the RequesterAutonomousSystem information.

  • Performs a lookup for the IP information of the originating request's IP address. Useful for obtaining the caller's own IP information. Similar to originLookupAsn, this method does not support caching, and each invocation results in a remote API request to Ipregistry. This ensures that the most current information is retrieved but also means that each call will consume credits.

    Parameters

    • Rest...options: IpregistryOption[]

      Optional. Additional options for the lookup operation.

    Returns Promise<ApiResponse<RequesterIpInfo>>

    A Promise resolving to an ApiResponse containing the RequesterIpInfo.

  • Parses user agent strings and returns detailed information about them.

    Parameters

    • Rest...userAgents: string[]

      An array of user agent strings to parse.

    Returns Promise<ApiResponse<UserAgent[]>>

    A Promise resolving to an ApiResponse containing an array of UserAgent information.