Skip to content

Add new action to ip2location_io #16347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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}`);
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
31 changes: 30 additions & 1 deletion components/ip2location_io/ip2location_io.app.mjs
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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<Object>} 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<Object>} The hosted domain information
*/
lookupHostedDomain(args = {}) {
return this._makeRequest({
url: DOMAINS_URL,
...args,
});
},
Expand Down
2 changes: 1 addition & 1 deletion components/ip2location_io/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
Loading