Module ip2locationio
shammi/ip2locationio
2.0.0
Overview
IP2Location.io REST API allowing users to check IP address location in real time. The REST API supports both IPv4 and IPv6 address lookup. More about the IP2Location.io API can be find at IP2Location.io
Prerequisites
Before using this package in your Ballerina application, complete the following:
- Create IP2Location.io account
- Obtain tokens - Navigate to the IP2Location.io Dashboard, your API key will be listed there, simply copy it.
Quickstart
To use the IP2Location.io package in your Ballerina application, update the .bal file as follows:
Step 1: Import package
First, import the ip2locationio/ip2locationio module into the Ballerina project.
import ip2locationio/ip2locationio;
Step 2: Create a new package instance
In your main
function, intantiate the client as the following
public function main() returns error? { ip2locationio:Client ip2locationioClient = check new ip2locationio:Client(); // Your logic here }
Step 3: Invoke an operation
- Now you can use the operations available within the package. Following code demonstrate how to get geolocation information for the IP
8.8.8.8
.
public function main() returns error? { ip2locationio:Client ip2locationioClient = check new ip2locationio:Client(); json|error response = ip2locationioClient->getGeolocationInfo("<YOUR_API_Key>", "8.8.8.8"); io:println(response); // Your logic here }
- Use
bal run
command to compile and run the Ballerina program.