Skip to main content

Official Python SDK for ipc.artsnoa.com API - IP geolocation and information service

Project description

IPC Artsnoa Python SDK

Official Python SDK for ipc.artsnoa.com API - Get your IP address and location information.

Features

  • Simple and intuitive API
  • Type hints for better IDE support
  • Comprehensive error handling
  • Context manager support
  • Minimal dependencies

Installation

pip install ipc-artsnoa

Or with uv:

uv add ipc-artsnoa

Quick Start

from ipc_artsnoa import IPCClient

# Initialize client (API key is optional)
client = IPCClient(api_key='YOUR_API_KEY')

# Get basic IP information
data = client.get_ip()
print(f'Your IP: {data["ip"]}, Country: {data["country"]}')

# Get detailed IP information
details = client.get_ip_details()
print(f'IP: {details["ip"]}, ASN: {details["asn"]}, Currency: {details["currency"]}')

Usage Examples

Basic Usage

from ipc_artsnoa import IPCClient

# Create client with API key
client = IPCClient(api_key='YOUR_API_KEY')

# Get basic IP information
data = client.get_ip()
print(f"IP: {data['ip']}")
print(f"Country: {data['country']}")

# Without API key
client = IPCClient()
data = client.get_ip()
print(f"Your IP: {data['ip']}")

Detailed IP Information

from ipc_artsnoa import IPCClient

client = IPCClient(api_key='YOUR_API_KEY')

# Get detailed information including ASN, currency, languages
details = client.get_ip_details()
print(f"IP: {details['ip']}")
print(f"User Agent: {details['userAgent']}")
print(f"ASN: {details['asn']}")
print(f"Country: {details['country']}")
print(f"Currency: {details['currency']}")
print(f"Languages: {details['languages']}")
print(f"Timestamp: {details['timestamp']}")

SDK Version Information

from ipc_artsnoa import IPCClient

client = IPCClient()

# Get available SDK versions
versions = client.get_sdk_versions()
print(f"Python SDK: {versions['python']}")
print(f"JavaScript SDK: {versions['javascript']}")

Custom Configuration

from ipc_artsnoa import IPCClient

# Custom timeout
client = IPCClient(
    api_key='YOUR_API_KEY',
    timeout=15.0
)

data = client.get_ip()

Using Context Manager

from ipc_artsnoa import IPCClient

# Automatically closes session when done
with IPCClient(api_key='YOUR_API_KEY') as client:
    data = client.get_ip()
    print(f"IP: {data['ip']}")

Error Handling

The SDK provides specific exception types for different error scenarios:

from ipc_artsnoa import (
    IPCClient,
    IPCError,
    IPCAPIError,
    IPCConnectionError,
    IPCTimeoutError
)

client = IPCClient(api_key='YOUR_API_KEY')

try:
    data = client.get_ip()
    print(f"Your IP: {data['ip']}")
except IPCAPIError as e:
    print(f"API error: {e}")
    if hasattr(e, 'status_code'):
        print(f"Status code: {e.status_code}")
except IPCConnectionError as e:
    print(f"Connection error: {e}")
except IPCTimeoutError as e:
    print(f"Request timeout: {e}")
except IPCError as e:
    print(f"IPC error: {e}")

API Reference

IPCClient

Constructor

IPCClient(
    api_key: str | None = None,
    timeout: float = 10.0
)

Parameters:

  • api_key (str | None): API key for authentication. Optional.
  • timeout (float): Request timeout in seconds. Defaults to 10.0

Methods

get_ip() -> dict

Get basic IP address and location information.

Returns:

  • Dictionary containing basic IP information including:
    • ip: Your IP address
    • country: Country code

Raises:

  • IPCAPIError: When API returns an error response
  • IPCConnectionError: When connection fails
  • IPCTimeoutError: When request times out

Example:

data = client.get_ip()
print(f"IP: {data['ip']}, Country: {data['country']}")
get_ip_details() -> dict

Get detailed IP address information.

Returns:

  • Dictionary containing detailed IP information including:
    • ip: Your IP address
    • userAgent: Browser user agent string
    • asn: Autonomous System Number
    • country: Country code
    • currency: Country currency code
    • languages: Supported languages
    • timestamp: Request timestamp
    • version: API version

Raises:

  • IPCAPIError: When API returns an error response
  • IPCConnectionError: When connection fails
  • IPCTimeoutError: When request times out

Example:

details = client.get_ip_details()
print(f"IP: {details['ip']}, ASN: {details['asn']}")
get_sdk_versions() -> dict

Get available SDK versions.

Returns:

  • Dictionary containing SDK versions for different platforms:
    • python: Python SDK version
    • javascript: JavaScript SDK version

Raises:

  • IPCAPIError: When API returns an error response
  • IPCConnectionError: When connection fails
  • IPCTimeoutError: When request times out

Example:

versions = client.get_sdk_versions()
print(f"Python SDK: {versions['python']}")
close()

Close the underlying HTTP session.

Example:

client.close()

Context Manager Support

The client supports context manager protocol for automatic resource cleanup:

with IPCClient(api_key='YOUR_API_KEY') as client:
    data = client.get_ip()

Development

# Clone repository
git clone https://github.com/artsnoa/ipc-python-sdk.git
cd ipc-python-sdk

# Install dependencies with uv
uv sync

# Build package
uv build

Requirements

  • Python 3.10 or higher
  • requests >= 2.31.0

License

MIT License

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

ipc_artsnoa-1.0.1.tar.gz (48.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipc_artsnoa-1.0.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file ipc_artsnoa-1.0.1.tar.gz.

File metadata

  • Download URL: ipc_artsnoa-1.0.1.tar.gz
  • Upload date:
  • Size: 48.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for ipc_artsnoa-1.0.1.tar.gz
Algorithm Hash digest
SHA256 4328f030e63fef0498e1c65d180c4e6cc8677382b3c50b046ab06b0f24cb5bc6
MD5 6af26b5c7565b67e6c03f38169cf95b6
BLAKE2b-256 e71c7d9b9cb4e7eee35cad4326314b50a8f164a7bae240fc25bd566197456447

See more details on using hashes here.

File details

Details for the file ipc_artsnoa-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ipc_artsnoa-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for ipc_artsnoa-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b46d3cfb26e56e46d145b6370baf133bf1001f6c082b1498700de71970cd6d2
MD5 fbbba2374183f2ca19a480620798d95a
BLAKE2b-256 34d0d047209a2bca7929c9cd1a8897c19c91bdc89eeef7a326fa7157715b0ecc

See more details on using hashes here.

Supported by

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