# 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:

```sh
pip install locaspy
```

## Usage

```python
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

```python
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

```python
import locaspy

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

#### Fetch Location Details

```python
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

```python
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:

```JSON
{
    "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](https://github.com/ByteBreach/locaspy) 

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](https://github.com/ByteBreach/locaspy/LICENSE) file for details.

### Acknowledgements

We would like to acknowledge the following libraries and resources that made this project possible:
- [requests](https://pypi.org/project/requests/)
- [ipinfo.io](https://ipinfo.io)
- [open-meteo](https://open-meteo.com/)
- [openstreetmap.org](https://openstreetmap.org)

Thank you again for your support!
