diff --git a/components/ip2location_io/actions/lookup-hosted-domain/lookup-hosted-domain.mjs b/components/ip2location_io/actions/lookup-hosted-domain/lookup-hosted-domain.mjs new file mode 100644 index 0000000000000..138cef901b496 --- /dev/null +++ b/components/ip2location_io/actions/lookup-hosted-domain/lookup-hosted-domain.mjs @@ -0,0 +1,49 @@ +import ip2location from "../../ip2location_io.app.mjs"; + +export default { + key: "ip2location_io-lookup-hosted-domain", + name: "Lookup Hosted Domain", + description: "Retrieve the list of hosted domains on an IP Address. [See the docs here](https://www.ip2location.io/ip2whois-domains-documentation)", + version: "0.0.1", + type: "action", + props: { + ip2location, + ip: { + type: "string", + label: "IP Address", + description: "IP address (IPv4 or IPv6) to lookup", + }, + format: { + propDefinition: [ + ip2location, + "format", + ], + }, + page: { + type: "integer", + label: "Page", + description: "Pagination result returns of the hosted domains. If unspecified, 1st page will be used.", + optional: true, + }, + }, + async run({ $ }) { + try { + const response = await this.ip2location.lookupHostedDomain({ + params: { + ip: this.ip, + format: this.format, + page: this.page, + }, + }); + if (response && response.total_domains) { + $.export( + "$summary", + `Successfully retrieved hosted domain information about IP ${this.ip}.`, + ); + } + return response; + } catch (error) { + throw new Error(`Error retrieving hosted domains: ${error.message}`); + } + }, +}; diff --git a/components/ip2location_io/actions/lookup-ip-address/lookup-ip-address.mjs b/components/ip2location_io/actions/lookup-ip-address/lookup-ip-address.mjs index cbeab5ced670a..75497ba625c86 100644 --- a/components/ip2location_io/actions/lookup-ip-address/lookup-ip-address.mjs +++ b/components/ip2location_io/actions/lookup-ip-address/lookup-ip-address.mjs @@ -4,7 +4,7 @@ export default { key: "ip2location_io-lookup-ip-address", name: "Lookup IP Address", description: "Retrieve geolocation data about an IP Address. [See the docs here](https://www.ip2location.io/ip2location-documentation)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { ip2location, diff --git a/components/ip2location_io/ip2location_io.app.mjs b/components/ip2location_io/ip2location_io.app.mjs index 55b02ab40c499..cf1130c945c92 100644 --- a/components/ip2location_io/ip2location_io.app.mjs +++ b/components/ip2location_io/ip2location_io.app.mjs @@ -1,5 +1,8 @@ import { axios } from "@pipedream/platform"; +const BASE_URL = "https://api.ip2location.io"; +const DOMAINS_URL = "https://domains.ip2whois.com/domains"; + export default { type: "app", app: "ip2location_io", @@ -34,9 +37,35 @@ export default { ...args, }); }, + /** + * Lookup geolocation information for an IP address + * @param {Object} args - The arguments for the request + * @param {Object} [args.params] - The query parameters + * @param {string} [args.params.ip] - The IP address to lookup (IPv4 or IPv6) + * @param {string} [args.params.format] - Response format (json or xml) + * @param {string} [args.params.lang] - Translation information(ISO639-1) for + * continent, country, + * region and city name + * @returns {Promise} The hosted domain information + */ lookupIpAddress(args = {}) { return this._makeRequest({ - url: "https://api.ip2location.io", + url: BASE_URL, + ...args, + }); + }, + /** + * Lookup hosted domains for an IP address + * @param {Object} args - The arguments for the request + * @param {Object} [args.params] - The query parameters + * @param {string} [args.params.ip] - The IP address to lookup (IPv4 or IPv6) + * @param {string} [args.params.format] - Response format (json or xml) + * @param {number} [args.params.page] - Page number for pagination + * @returns {Promise} The hosted domain information + */ + lookupHostedDomain(args = {}) { + return this._makeRequest({ + url: DOMAINS_URL, ...args, }); }, diff --git a/components/ip2location_io/package.json b/components/ip2location_io/package.json index 951e3566a2d2d..813ff1cc494a2 100644 --- a/components/ip2location_io/package.json +++ b/components/ip2location_io/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/ip2location_io", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream IP2Location.io Components", "main": "ip2location_io.app.mjs", "keywords": [