### Install BigDataCloud Node.js SDK Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Install the SDK using npm. This command adds the necessary package to your project. ```bash npm install bigdatacloud ``` -------------------------------- ### Quick Start: BigDataCloud SDK Usage Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Demonstrates basic usage of the BigDataCloud SDK for IP Geolocation, Reverse Geocoding, Phone Validation, and Email Verification. Reads API key from environment. ```typescript import { BigDataCloudClient } from 'bigdatacloud'; // Reads BIGDATACLOUD_API_KEY from environment const client = BigDataCloudClient.fromEnvironment(); // IP Geolocation const geo = await client.ipGeolocation.get('1.1.1.1'); console.log(`${geo.location.city}, ${geo.country.name}`); // Reverse Geocoding const place = await client.reverseGeocoding.reverseGeocode(-33.87, 151.21); console.log(`${place.city}, ${place.countryName}`); // Phone Validation — countryCode is required const phone = await client.verification.validatePhone('+61412345678', 'AU'); console.log(`Valid: ${phone.isValid}, Type: ${phone.lineType}`); // Email Verification const email = await client.verification.verifyEmail('user@example.com'); console.log(`Valid: ${email.isValid}, Disposable: ${email.isDisposable}`); ``` -------------------------------- ### Run SDK Samples Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Instructions to set the API key, build the project, and run various sample applications using Node.js. ```bash export BIGDATACLOUD_API_KEY=your-key-here npm run build node samples/ipGeolocation.mjs node samples/reverseGeocoding.mjs node samples/verification.mjs node samples/networkEngineering.mjs ``` -------------------------------- ### Set BigDataCloud API Key Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Set your BigDataCloud API key as an environment variable. This is required for authentication. ```bash export BIGDATACLOUD_API_KEY=your-key-here ``` -------------------------------- ### Phone Validation with Country Context Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Demonstrates two methods for phone validation, both requiring explicit country context. The first uses a known country code, and the second uses the end-user's IP address. ```typescript // You know the country const phone = await client.verification.validatePhone('+61412345678', 'AU'); // You know the end user's IP (pass their IP, not your server's) const phone = await client.verification.validatePhoneByIp('0412345678', userIp); ``` -------------------------------- ### Handle BigDataCloud API Errors Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Implements error handling for API calls using a try-catch block. It specifically checks for `BigDataCloudError` instances to log detailed error information. ```typescript import { BigDataCloudError } from 'bigdatacloud'; try { const geo = await client.ipGeolocation.get('1.1.1.1'); } catch (e) { if (e instanceof BigDataCloudError) { console.error(`API error ${e.statusCode}: ${e.message}`); } } ``` -------------------------------- ### Process Confidence Area Polygons Source: https://github.com/bigdatacloudapi/bigdatacloud-node/blob/main/README.md Utilizes the `splitIntoPolygons` helper function to process the `confidenceArea` field from IP Geolocation results. This is useful when the confidence area encodes multiple polygons. ```typescript import { splitIntoPolygons } from 'bigdatacloud'; const geo = await client.ipGeolocation.getWithConfidenceArea('1.1.1.1'); const polygons = splitIntoPolygons(geo.confidenceArea); polygons.forEach((ring, i) => console.log(`Ring ${i + 1}: ${ring.length} points`)); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.