Skip to main content

A tool for fetching location, weather, and map link based on IP address.

Project description

locaspy

locaspy is a Python package to fetch and display IP location information, weather details, ISP information, and more using ipinfo.io and OpenWeatherMap API.

Installation

You can install locaspy via pip:

pip install locaspy

Usage

import locaspy

# Get the user's IP address
ip_address = locaspy.get_ip()

# Get all information based on the IP address
info = locaspy.get_data(ip_address)

# Print all information
print("IP Address:", info["ip_address"])
print("Location:")
print(f"  City: {info['city']}")
print(f"  Region: {info['region']}")
print(f"  Country: {info['country']}")
print(f"  Country Code: {info['country_code']}")
print(f"  ISP: {info['isp']}")
print(f"  Languages: {info['languages']}")
print(f"  Postal Code: {info['postal_code']}")
print(f"  Latitude: {info['latitude']}")
print(f"  Longitude: {info['longitude']}")
print(f"  Open URL: {info['url']}")
print(f"  Currency: {info['currency']}")
print(f"  Temperature: {info['temperature']}°C")
print(f"  Weather: {info['weather']}")

Fetching IP Address

import locaspy

# Get the user's IP address
ip_address = locaspy.get_ip()
print("Your IP Address:", ip_address)

Fetching Information

You can fetch various types of information based on an IP address:

Fetch Weather Information
import locaspy

ip_address = input("Enter your IP: ")
weather_info = locaspy.get_data(ip_address, "weather")
print("Weather Information:", weather_info)

Fetch Location Details

import locaspy

ip_address = input("Enter your IP: ")
location_info = locaspy.get_data(ip_address, "location")
print("Location Details:\n", location_info)

Fetch ISP Information

import locaspy

ip_address = input("Enter your IP: ")
isp_info = locaspy.get_data(ip_address, "isp")
print("ISP Information:", isp_info)

Available Information

  • The get_data function returns a dictionary with the following keys:

  • ip_address: IP address of the user

  • city: City name

  • region: Region or state

  • country: Country name

  • country_code: Country code

  • isp: Internet Service Provider

  • languages: Languages spoken

  • postal_code: Postal code

  • latitude: Latitude coordinate

  • longitude: Longitude coordinate

  • url: URL link to OpenStreetMap

  • currency: Currency used

  • temperature: Temperature in Celsius

  • weather: Weather condition

Example Output

  • Here's an example of the output structure:
{
    "ip_address": "192.168.1.1",
    "city": "City",
    "region": "Region",
    "country": "Country",
    "country_code": "CC",
    "isp": "Internet Provider",
    "languages": "English",
    "postal_code": "12345",
    "latitude": "40.7128",
    "longitude": "-74.0060",
    "url": "https://www.openstreetmap.org/?mlat=40.7128&mlon=-74.0060#map=15/40.7128/-74.0060",
    "currency": "USD",
    "temperature": "25°C",
    "weather": "Sunny"
}

Thanks

Thank you for using locaspy! We appreciate your interest in our tool and hope it meets your needs.

Additional Information

For any issues, suggestions, or contributions, please visit our GitHub repository

We welcome and encourage contributions from the community. Whether it's reporting a bug, suggesting a feature, or improving the documentation, your feedback is valuable and helps us improve the project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

We would like to acknowledge the following libraries and resources that made this project possible:

Thank you again for your support!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

locaspy-1.0.4.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

locaspy-1.0.4-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page