Official JavaScript/TypeScript SDK for ipc.artsnoa.com API - Get your IP address and location information.
- Full TypeScript support with type definitions
- Simple and intuitive API
- Comprehensive error handling
- Works in Node.js environments
- Minimal dependencies
- ESM and CommonJS support
npm install @artsnoa/ipc-sdkOr with pnpm:
pnpm add @artsnoa/ipc-sdkOr with yarn:
yarn add @artsnoa/ipc-sdkimport { IPCClient } from '@artsnoa/ipc-sdk';
// Initialize client (API key is optional)
const client = new IPCClient({ apiKey: 'YOUR_API_KEY' });
// Get detailed IP information
const details = await client.getIPDetails();
console.log(`Your IP: ${details.ip}, Country: ${details.country}`);import { IPCClient } from '@artsnoa/ipc-sdk';
// Create client with API key
const client = new IPCClient({ apiKey: 'YOUR_API_KEY' });
// Get IP details
const data = await client.getIPDetails();
console.log(`IP: ${data.ip}`);
console.log(`Country: ${data.country}`);
// Without API key
const publicClient = new IPCClient();
const publicData = await publicClient.getIPDetails();
console.log(`Your IP: ${publicData.ip}`);import { IPCClient, IPDetailsResponse } from '@artsnoa/ipc-sdk';
const client = new IPCClient({ apiKey: 'YOUR_API_KEY' });
// Type-safe IP details
const details: IPDetailsResponse = await client.getIPDetails();
console.log(`IP: ${details.ip}`);
console.log(`User Agent: ${details.userAgent}`);
console.log(`ASN: ${details.asn}`);
console.log(`Country: ${details.country}`);
console.log(`Currency: ${details.currency}`);
console.log(`Languages: ${details.languages.join(', ')}`);
console.log(`Timestamp: ${details.timestamp}`);import { IPCClient } from '@artsnoa/ipc-sdk';
const client = new IPCClient();
// Get available SDK versions
const versions = await client.getSDKVersions();
console.log(`JavaScript SDK: ${versions.javascript}`);
console.log(`Python SDK: ${versions.python}`);import { IPCClient } from '@artsnoa/ipc-sdk';
// Custom timeout and base URL
const client = new IPCClient({
apiKey: 'YOUR_API_KEY',
timeout: 15000, // 15 seconds in milliseconds
baseUrl: 'https://custom-domain.com'
});
const data = await client.getIPDetails();const { IPCClient } = require('@artsnoa/ipc-sdk');
const client = new IPCClient({ apiKey: 'YOUR_API_KEY' });
client.getIPDetails().then(data => {
console.log(`IP: ${data.ip}, Country: ${data.country}`);
});The SDK provides a custom error class for handling API errors:
import { IPCClient, IPCError } from '@artsnoa/ipc-sdk';
const client = new IPCClient({ apiKey: 'YOUR_API_KEY' });
try {
const data = await client.getIPDetails();
console.log(`Your IP: ${data.ip}`);
} catch (error) {
if (error instanceof IPCError) {
console.error(`IPC Error: ${error.message}`);
if (error.statusCode) {
console.error(`Status code: ${error.statusCode}`);
}
if (error.code) {
console.error(`Error code: ${error.code}`);
}
} else {
console.error(`Unexpected error: ${error}`);
}
}import { IPCClient, IPCError } from '@artsnoa/ipc-sdk';
const client = new IPCClient({ apiKey: 'YOUR_API_KEY' });
async function getIPSafely() {
try {
const data = await client.getIPDetails();
return data;
} catch (error) {
if (error instanceof IPCError) {
console.error(`API error: ${error.message}`);
console.error(`Status: ${error.statusCode ?? 'unknown'}`);
} else if (error instanceof Error) {
console.error(`Error: ${error.message}`);
}
throw error;
}
}new IPCClient(options?: IPCClientOptions)Parameters:
options(IPCClientOptions): Configuration optionsapiKey(string, optional): API key for authenticationbaseUrl(string, optional): Base URL for the API. Defaults tohttps://ipc.artsnoa.comtimeout(number, optional): Request timeout in milliseconds. Defaults to 10000 (10 seconds)
Example:
const client = new IPCClient({
apiKey: 'YOUR_API_KEY',
timeout: 15000,
baseUrl: 'https://ipc.artsnoa.com'
});Get detailed IP address and location information.
Returns:
- Promise that resolves to an object containing:
ip(string): Your IP addressuserAgent(string): Browser user agent stringasn(string): Autonomous System Numbercountry(string): Country code (ISO 3166-1 alpha-2)currency(string): Country currency code (ISO 4217)languages(string[]): Array of supported language codestimestamp(string): Request timestamp (ISO 8601 format)version(string): API version
Throws:
IPCError: When the API request fails or returns an invalid response
Example:
const details = await client.getIPDetails();
console.log(`IP: ${details.ip}, Country: ${details.country}`);
console.log(`ASN: ${details.asn}, Currency: ${details.currency}`);Get available SDK versions for different platforms.
Returns:
- Promise that resolves to an object containing:
javascript(string): JavaScript/TypeScript SDK versionpython(string): Python SDK version
Throws:
IPCError: When the API request fails or returns an invalid response
Example:
const versions = await client.getSDKVersions();
console.log(`JavaScript SDK: ${versions.javascript}`);
console.log(`Python SDK: ${versions.python}`);Configuration options for the IPCClient constructor.
interface IPCClientOptions {
apiKey?: string;
baseUrl?: string;
timeout?: number;
}Response structure from the getIPDetails() method.
interface IPDetailsResponse {
ip: string;
userAgent: string;
asn: string;
country: string;
currency: string;
languages: string[];
timestamp: string;
version: string;
}Response structure from the getSDKVersions() method.
interface SDKVersionsResponse {
javascript: string;
python: string;
}Custom error class for IPC SDK errors.
class IPCError extends Error {
statusCode?: number;
code?: string;
}# Clone repository
git clone https://github.com/artsnoa/ipc-javascript-sdk.git
cd ipc-javascript-sdk
# Install dependencies
pnpm install
# Build package
pnpm run build- Node.js 18.0.0 or higher
- No external runtime dependencies
MIT License
- Documentation: https://github.com/artsnoa/ipc-javascript-sdk
- Issues: https://github.com/artsnoa/ipc-javascript-sdk/issues
- Email: aurora@artsnoa.com