{"id":4291,"date":"2022-11-12T16:23:05","date_gmt":"2022-11-12T16:23:05","guid":{"rendered":"https:\/\/serviceobjects.wpaladdin.com\/?page_id=4291"},"modified":"2025-09-26T22:57:38","modified_gmt":"2025-09-27T05:57:38","slug":"gp-rest","status":"publish","type":"page","link":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/","title":{"rendered":"GP &#8211; REST"},"content":{"rendered":"\n<div class=\"wp-block-create-block-tabs\"><ul class=\"tab-labels\" role=\"tablist\" aria-label=\"tabbed content\"><li class=\"tab-label active\" role=\"tab\" aria-selected=\"true\" aria-controls=\"C#\" tabindex=\"0\">C#<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"Python\" tabindex=\"0\">Python<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"NodeJS\" tabindex=\"0\">NodeJS<\/li><\/ul><div class=\"tab-content\">\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>GeoPhone C# Rest Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\ufeffusing System.Web;\n\nnamespace geophone_dot_net.REST\n{\n    \/\/\/ &lt;summary>\n    \/\/\/ Provides functionality to call the ServiceObjects GeoPhone REST API's GetPhoneInfo_V2 endpoint,\n    \/\/\/ retrieving phone-related information (e.g., provider and contact details) with fallback to a backup endpoint\n    \/\/\/ for reliability in live mode.\n    \/\/\/ &lt;\/summary>\n    public class GetPhoneInfoClient\n    {\n\n        private const string LiveBaseUrl = \"https:\/\/sws.serviceobjects.com\/GP\/api.svc\/\";\n        private const string BackupBaseUrl = \"https:\/\/swsbackup.serviceobjects.com\/GP\/api.svc\/\";\n        private const string TrailBaseUrl = \"https:\/\/trial.serviceobjects.com\/GP\/api.svc\/\";\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Synchronously calls the GetPhoneInfo_V2 REST endpoint to retrieve phone information,\n        \/\/\/ attempting the primary endpoint first and falling back to the backup if the response is invalid\n        \/\/\/ (Error.Number == \"4\") in live mode.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"input\">The input parameters including phone number, license key, is live and timeout.&lt;\/param>\n        \/\/\/ &lt;returns>Deserialized &lt;see cref=\"GPResponse\"\/>.&lt;\/returns>\n        public static GPResponse Invoke(GetPhoneInfoInput input)\n        {\n            \/\/Use query string parameters so missing\/options fields don't break\n            \/\/the URL as path parameters would.\n            string url = BuildUrl(input, input.IsLive ? LiveBaseUrl : TrailBaseUrl);\n            GPResponse response = Helper.HttpGet&lt;GPResponse>(url, input.TimeoutSeconds);\n\n            \/\/ Fallback on error payload in live mode\n            if (input.IsLive &amp;&amp; !IsValid(response))\n            {\n                var fallbackUrl = BuildUrl(input, BackupBaseUrl);\n                GPResponse fallbackResponse = Helper.HttpGet&lt;GPResponse>(fallbackUrl, input.TimeoutSeconds);\n                return fallbackResponse;\n            }\n\n            return response;\n        }\n        \/\/\/ &lt;summary>\n        \/\/\/ Asynchronously calls the GetPhoneInfo_V2 REST endpoint to retrieve phone information,\n        \/\/\/ attempting the primary endpoint first and falling back to the backup if the response is invalid\n        \/\/\/ (Error.Number == \"4\") in live mode.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"input\">The input parameters including phone number, license key, is live and timeout.&lt;\/param>\n        \/\/\/ &lt;returns>Deserialized &lt;see cref=\"GPResponse\"\/>.&lt;\/returns>\n        public static async Task&lt;GPResponse> InvokeAsync(GetPhoneInfoInput input)\n        {\n            \/\/Use query string parameters so missing\/options fields don't break\n            \/\/the URL as path parameters would.\n            string url = BuildUrl(input, input.IsLive ? LiveBaseUrl : TrailBaseUrl);\n            GPResponse response = await Helper.HttpGetAsync&lt;GPResponse>(url, input.TimeoutSeconds).ConfigureAwait(false);\n            if (input.IsLive &amp;&amp; !IsValid(response))\n            {\n                var fallbackUrl = BuildUrl(input, BackupBaseUrl);\n                GPResponse fallbackResponse = await Helper.HttpGetAsync&lt;GPResponse>(fallbackUrl, input.TimeoutSeconds).ConfigureAwait(false);\n                return fallbackResponse;\n            }\n\n            return response;\n        }\n\n        \/\/ Build the full request URL, including URL-encoded query string\n        public static string BuildUrl(GetPhoneInfoInput input,string baseUrl)\n        {\n            var qs = $\"json\/GetPhoneInfo_V2?PhoneNumber={HttpUtility.UrlEncode(input.PhoneNumber)}\" +\n                     $\"&amp;LicenseKey={HttpUtility.UrlEncode(input.LicenseKey)}\";\n            return baseUrl + qs;\n        }\n\n        private static bool IsValid(GPResponse response) => response?.Error == null || response.Error.Number != \"4\";\n\n        \/\/\/ &lt;summary>\n        \/\/\/ Defines the input parameters for the GetPhoneInfo_V2 REST operation.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"PhoneNumber\">The phone number to look up (e.g., \"805-963-1700\") - Required.&lt;\/param>\n        \/\/\/ &lt;param name=\"LicenseKey\">Service Objects GeoPhone license key. - Required&lt;\/param>\n        \/\/\/ &lt;param name=\"IsLive\">True for live (production+backup) endpoints; false for trial only. - Required.&lt;\/param>\n        \/\/\/ &lt;param name=\"TimeoutSeconds\">The timeout duration in seconds for the request (default: 15).&lt;\/param>\n        public record GetPhoneInfoInput(\n            string PhoneNumber = \"\",\n            string LicenseKey = \"\",\n            bool IsLive = true,\n            int TimeoutSeconds = 15\n        );\n    }\n}\n\n\n\ufeffusing System.Runtime.Serialization;\n\nnamespace geophone_dot_net.REST\n{\n    \/\/\/ &lt;summary>\n    \/\/\/ Response object for the GeoPhone REST API, containing provider and contact information,\n    \/\/\/ &lt;\/summary>\n    [DataContract]\n    public class GPResponse \n    {\n        public Provider[] Providers { get; set; }\n        public Contact[] Contacts { get; set; }\n        public Error Error { get; set; }\n        public override string ToString()\n        {\n            string providers = Providers != null ? string.Join(\", \", Providers.Select(p => p.ToString())) : \"null\";\n            string contacts = Contacts != null ? string.Join(\", \", Contacts.Select(c => c.ToString())) : \"null\";\n            string error = Error != null ? Error.ToString() : \"null\";\n\n            return $\"GP GPResponse: Providers = {providers}, Contacts = {contacts}, Error = {error}\";\n        }\n    }\n    \/\/\/ &lt;summary>\n    \/\/\/ Represents a provider's information in the GeoPhone REST API response.\n    \/\/\/ &lt;\/summary>  \n    public class Provider\n    {\n        public string Name { get; set; }\n        public string City { get; set; }\n        public string State { get; set; }\n        public string LineType { get; set; }\n        public string Latitude { get; set; }\n        public string Longitude { get; set; }\n        public string Quality { get; set; }\n        public override string ToString()\n        {\n            return $\"ProviderOutput: Name = {Name}, City = {City}, State = {State}, LineType = {LineType}, Latitude = {Latitude}, Longitude = {Longitude}, Quality = {Quality}\";\n        }\n    }\n\n    \/\/\/ &lt;summary>\n    \/\/\/ Represents a contact's information in the GeoPhone REST API response.\n    \/\/\/ &lt;\/summary>\n    public class Contact\n    {\n        public string Name { get; set; }\n        public string Address { get; set; }\n        public string City { get; set; }\n        public string State { get; set; }\n        public string Zip { get; set; }\n        public string Type { get; set; }\n        public override string ToString()\n        {\n            return $\"ContactOutput: Name = {Name}, Address = {Address}, City = {City}, State = {State}, Zip = {Zip}, Type = {Type}\";\n        }\n    }\n\n    public class Error\n    {\n        public string Desc { get; set; }\n        public string Number { get; set; }\n        public string Location { get; set; }\n        public override string ToString()\n        {\n            return $\"Desc: {Desc} \" +\n                $\"Number: {Number} \" +\n                $\"Location: {Location} \";\n        }\n    }\n\n    public class LF_Provider\n    {\n        public string Name { get; set; }\n        public string City { get; set; }\n        public string State { get; set; }\n        public string LineType { get; set; }\n\n        public override string ToString()\n        {\n            return $\"Name: {Name}, City: {City}, State: {State}, LineType: {LineType}\";\n        }\n    }\n\n    public class LF_Contact\n    {\n        public string Name { get; set; }\n        public string Address { get; set; }\n        public string City { get; set; }\n        public string State { get; set; }\n        public string Zip { get; set; }\n        public string Type { get; set; }\n\n        public override string ToString()\n        {\n            return $\"Name: {Name}, Address: {Address}, City: {City}, State: {State}, Zip: {Zip}, Type: {Type}\";\n        }\n    }\n\n    public class LF_ResponseObject \n    {\n        public Provider[] Providers { get; set; }\n        public Contact[] Contacts { get; set; }\n        public Error Error { get; set; }\n\n        public override string ToString()\n        {\n            string providers = Providers?.Any() == true\n                ? string.Join(\", \", Providers.Select(p => p.ToString()))\n                : \"None\";\n\n            string contacts = Contacts?.Any() == true\n                ? string.Join(\", \", Contacts.Select(c => c.ToString()))\n                : \"None\";\n\n            return $\"GP LF_Response: Providers: [{providers}], Contacts: [{contacts}], Error: {Error}\";\n        }\n    }\n\n}\n\n\n\ufeffusing System.Text.Json;\nusing System.Web;\n\nnamespace geophone_dot_net.REST\n{\n    public class Helper\n    {\n        public static T HttpGet&lt;T>(string url, int timeoutSeconds)\n        {\n            using var httpClient = new HttpClient\n            {\n                Timeout = TimeSpan.FromSeconds(timeoutSeconds)\n            };\n            using var request = new HttpRequestMessage(HttpMethod.Get, url);\n            using HttpResponseMessage response = httpClient\n                .SendAsync(request)\n                .GetAwaiter()\n                .GetResult();\n            response.EnsureSuccessStatusCode();\n            using Stream responseStream = response.Content\n                .ReadAsStreamAsync()\n                .GetAwaiter()\n                .GetResult();\n            var options = new JsonSerializerOptions\n            {\n                PropertyNameCaseInsensitive = true\n            };\n            object? obj = JsonSerializer.Deserialize(responseStream, typeof(T), options);\n            T result = (T)obj!;\n            return result;\n        }\n\n        \/\/ Asynchronous HTTP GET and JSON deserialize\n        public static async Task&lt;T> HttpGetAsync&lt;T>(string url, int timeoutSeconds)\n        {\n            HttpClient HttpClient = new HttpClient();\n            HttpClient.Timeout = TimeSpan.FromSeconds(timeoutSeconds);\n            using var httpResponse = await HttpClient.GetAsync(url).ConfigureAwait(false);\n            httpResponse.EnsureSuccessStatusCode();\n            var stream = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false);\n            return JsonSerializer.Deserialize&lt;T>(stream)!;\n        }\n\n        public static string UrlEncode(string value) => HttpUtility.UrlEncode(value ?? string.Empty);\n    }\n}<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong><strong>GeoPhone Python Rest Code Snippet<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\nimport requests  # HTTP client for RESTful API calls\nfrom gp_response import GPResponse, Provider, Contact, Error\n\n# Endpoint URLs for GP GetPhoneInfoLastFirst service\nprimary_url = 'https:\/\/sws.serviceobjects.com\/GP\/api.svc\/json\/GetPhoneInfoLastFirst?'\nbackup_url = 'https:\/\/swsbackup.serviceobjects.com\/GP\/api.svc\/json\/GetPhoneInfoLastFirst?'\ntrial_url = 'https:\/\/trial.serviceobjects.com\/GP\/api.svc\/json\/GetPhoneInfoLastFirst?'\n\ndef get_phone_info(phone_number: str, license_key: str, is_live: bool = True) -> GPResponse:\n    \"\"\"\n    Call GP GetPhoneInfo_V2 API to retrieve phone number information.\n\n    Parameters:\n        phone_number (str): Phone number to look up (e.g., '805-963-1700'). Required.\n        license_key (str): Service Objects license key. Required.\n        is_live (bool): True for production endpoints, False for trial URL. Defaults to True.\n        timeout_seconds (int): Timeout for API calls in seconds. Defaults to 15.\n\n    Returns:\n        dict: Parsed JSON response with phone information or error details.\n    \"\"\"\n\n    # Prepare query parameters for GP API\n    params = {\n        'PhoneNumber': phone_number,\n        'LicenseKey': license_key\n    }\n\n    # Select the base URL: production vs trial\n    url = primary_url if is_live else trial_url\n\n    # Attempt primary (or trial) endpoint first\n    try:\n        response = requests.get(url, params=params, timeout=10)\n        response.raise_for_status()\n        data = response.json()\n\n        # If API returned an error in JSON payload, trigger fallback\n        error = getattr(response, 'Error', None)\n        if not (error is None or getattr(error, 'Number', None) != \"4\"):\n            if is_live:\n                # Try backup URL when live\n                response = requests.get(backup_url, params=params, timeout=10)\n                response.raise_for_status()\n                data = response.json()\n                # If still error, propagate exception\n                if 'Error' in data:\n                    raise RuntimeError(f\"GP service error: {data['Error']}\")\n            else:\n                # Trial mode should not fallback; error is terminal\n                raise RuntimeError(f\"GP trial error: {data['Error']}\")\n\n        # Convert JSON response to GPResponse for structured access\n        error = Error(**data.get('Error', {})) if data.get('Error') else None\n        providers = [Provider(**prov) for prov in data.get('Providers', [])] if data.get('Providers') else None\n        contacts = [Contact(**cont) for cont in data.get('Contacts', [])] if data.get('Contacts') else None\n        response = GPResponse(providers=providers, contacts=contacts, error=error)\n\n        return response\n        \n    except requests.RequestException as req_exc:\n        # Network or HTTP-level error occurred\n        if is_live:\n            try:\n                # Fallback to backup URL on network failure\n                response = requests.get(backup_url, params=params, timeout=10)\n                response.raise_for_status()\n                data = response.json()\n                if 'Error' in data:\n                    raise RuntimeError(f\"GP backup error: {data['Error']}\") from req_exc\n                \n                # Convert JSON response to GPResponse for structured access\n                error = Error(**data.get('Error', {})) if data.get('Error') else None\n                providers = [Provider(**prov) for prov in data.get('Providers', [])] if data.get('Providers') else None\n                contacts = [Contact(**cont) for cont in data.get('Contacts', [])] if data.get('Contacts') else None\n                response = GPResponse(providers=providers, contacts=contacts, error=error)\n                return response\n            except Exception as backup_exc:\n                # Both primary and backup failed; escalate\n                raise RuntimeError(\"GP service unreachable on both endpoints\") from backup_exc\n        else:\n            # In trial mode, propagate the network exception\n            raise RuntimeError(f\"GP trial error: {str(req_exc)}\") from req_exc\n\n\n\nfrom dataclasses import dataclass\nfrom typing import Optional, List\n\n@dataclass\nclass Provider:\n    \"\"\"Represents provider information returned by the GP API.\"\"\"\n    Name: Optional[str] = None\n    City: Optional[str] = None\n    State: Optional[str] = None\n    LineType: Optional[str] = None\n    Latitude: Optional[str] = None\n    Longitude: Optional[str] = None\n    Quality: Optional[str] = None\n\n    def __str__(self) -> str:\n        return (f\"ProviderOutput: Name = {self.Name}, City = {self.City}, State = {self.State}, \"\n                f\"LineType = {self.LineType}, Latitude = {self.Latitude}, Longitude = {self.Longitude}, \"\n                f\"Quality = {self.Quality}\")\n\n@dataclass\nclass Contact:\n    \"\"\"Represents contact information returned by the GP API.\"\"\"\n    Name: Optional[str] = None\n    Address: Optional[str] = None\n    City: Optional[str] = None\n    State: Optional[str] = None\n    Zip: Optional[str] = None\n    Type: Optional[str] = None\n\n    def __str__(self) -> str:\n        return (f\"ContactOutput: Name = {self.Name}, Address = {self.Address}, City = {self.City}, \"\n                f\"State = {self.State}, Zip = {self.Zip}, Type = {self.Type}\")\n\n@dataclass\nclass Error:\n    \"\"\"Represents error information returned by the GP API.\"\"\"\n    Desc: Optional[str] = None\n    Number: Optional[str] = None\n    Location: Optional[str] = None\n\n    def __str__(self) -> str:\n        return f\"Desc: {self.Desc} Number: {self.Number} Location: {self.Location}\"\n\n@dataclass\nclass GPResponse:\n    \"\"\"Represents the full response from the GP API.\"\"\"\n    providers: Optional[List[Provider]] = None\n    contacts: Optional[List[Contact]] = None\n    error: Optional[Error] = None\n\n    def __str__(self) -> str:\n        providers_str = \", \".join(str(p) for p in self.providers) if self.providers else \"null\"\n        contacts_str = \", \".join(str(c) for c in self.contacts) if self.contacts else \"null\"\n        error_str = str(self.error) if self.error else \"null\"\n        return f\"GP GPResponse: Providers = {providers_str}, Contacts = {contacts_str}, Error = {error_str}\"<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong><strong>GeoPhone NodeJS<\/strong><\/strong> <strong><strong>Rest Code Snippet<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import axios from 'axios';\nimport querystring from 'querystring';\nimport { GPResponse } from '.\/gp-response.js';\n\n\/**\n* @constant\n* @type {string}\n* @description The base URL for the live ServiceObjects GeoPhone API service.\n*\/\nconst LiveBaseUrl = 'https:\/\/sws.serviceobjects.com\/GP\/api.svc\/';\n\n\/**\n* @constant\n* @type {string}\n* @description The base URL for the backup ServiceObjects GeoPhone API service.\n*\/\nconst BackupBaseUrl = 'https:\/\/swsbackup.serviceobjects.com\/GP\/api.svc\/';\n\n\/**\n* @constant\n* @type {string}\n* @description The base URL for the trial ServiceObjects GeoPhone API service.\n*\/\nconst TrialBaseUrl = 'https:\/\/trial.serviceobjects.com\/GP\/api.svc\/';\n\n\/**\n* &lt;summary>\n* Checks if a response from the API is valid by verifying that it either has no Error object\n* or the Error.Number is not equal to '4'.\n* &lt;\/summary>\n* &lt;param name=\"response\" type=\"Object\">The API response object to validate.&lt;\/param>\n* &lt;returns type=\"boolean\">True if the response is valid, false otherwise.&lt;\/returns>\n*\/\nconst isValid = (response) => !response?.Error || response.Error.Number !== '4';\n\n\/**\n* &lt;summary>\n* Constructs a full URL for the GetPhoneInfo_V2 API endpoint by combining the base URL\n* with query parameters derived from the input object.\n* &lt;\/summary>\n* &lt;param name=\"phoneNumber\" type=\"string\">The phone number to query.&lt;\/param>\n* &lt;param name=\"licenseKey\" type=\"string\">The license key for the API.&lt;\/param>\n* &lt;param name=\"baseUrl\" type=\"string\">The base URL for the API service (live, backup, or trial).&lt;\/param>\n* &lt;returns type=\"string\">The constructed URL with query parameters.&lt;\/returns>\n*\/\nconst buildUrl = (phoneNumber, licenseKey, baseUrl) =>\n    `${baseUrl}json\/GetPhoneInfo_V2?${querystring.stringify({ PhoneNumber: phoneNumber, LicenseKey: licenseKey })}`;\n\n\/**\n* &lt;summary>\n* Performs an HTTP GET request to the specified URL with a given timeout.\n* &lt;\/summary>\n* &lt;param name=\"url\" type=\"string\">The URL to send the GET request to.&lt;\/param>\n* &lt;param name=\"timeoutSeconds\" type=\"number\">The timeout duration in seconds for the request.&lt;\/param>\n* &lt;returns type=\"Promise&lt;GPResponse>\">A promise that resolves to a GPResponse object containing the API response data.&lt;\/returns>\n* &lt;exception cref=\"Error\">Thrown if the HTTP request fails, with a message detailing the error.&lt;\/exception>\n*\/\nconst httpGet = async (url, timeoutSeconds) => {\n    try {\n        const response = await axios.get(url, { timeout: timeoutSeconds * 1000 });\n        return new GPResponse(response.data);\n    } catch (error) {\n        throw new Error(`HTTP request failed: ${error.message}`);\n    }\n};\n\n\/**\n* &lt;summary>\n* Provides functionality to call the ServiceObjects GeoPhone API's GetPhoneInfo_V2 endpoint,\n* retrieving phone-related information with fallback to a backup endpoint for reliability in live mode.\n* &lt;\/summary>\n*\/\nconst GetPhoneInfoClient = {\n    \/**\n    * &lt;summary>\n    * Asynchronously invokes the GetPhoneInfo_V2 API endpoint, attempting the primary endpoint\n    * first and falling back to the backup if the response is invalid (Error.Number == \"4\") in live mode.\n    * &lt;\/summary>\n    * &lt;param name=\"phoneNumber\" type=\"string\">The phone number to query.&lt;\/param>\n    * &lt;param name=\"licenseKey\" type=\"string\">The license key for the API.&lt;\/param>\n    * &lt;param name=\"isLive\" type=\"boolean\">Whether to use live or trial endpoints.&lt;\/param>\n    * &lt;param name=\"timeoutSeconds\" type=\"number\">The timeout duration in seconds for the request.&lt;\/param>\n    * &lt;returns type=\"Promise&lt;GPResponse>\">A promise that resolves to a GPResponse object with provider and contact details or an error.&lt;\/returns>\n    * &lt;exception cref=\"Error\">Thrown if both primary and backup endpoints fail, with details of the failure.&lt;\/exception>\n    *\/\n    async invokeAsync(phoneNumber, licenseKey, isLive, timeoutSeconds) {\n        const url = buildUrl(phoneNumber, licenseKey, isLive ? LiveBaseUrl : TrialBaseUrl);\n        let response = await httpGet(url, timeoutSeconds || 15);\n        if (isLive &amp;&amp; !isValid(response)) {\n            const fallbackUrl = buildUrl(phoneNumber, licenseKey, BackupBaseUrl);\n            const fallbackResponse = await httpGet(fallbackUrl, timeoutSeconds || 15);\n            return fallbackResponse;\n        }\n        return response;\n    },\n\n    \/**\n    * &lt;summary>\n    * Synchronously invokes the GetPhoneInfo_V2 API endpoint by wrapping the async call\n    * and awaiting its result immediately.\n    * &lt;\/summary>\n    * &lt;param name=\"phoneNumber\" type=\"string\">The phone number to query.&lt;\/param>\n    * &lt;param name=\"licenseKey\" type=\"string\">The license key for the API.&lt;\/param>\n    * &lt;param name=\"isLive\" type=\"boolean\">Whether to use live or trial endpoints.&lt;\/param>\n    * &lt;param name=\"timeoutSeconds\" type=\"number\">The timeout duration in seconds for the request.&lt;\/param>\n    * &lt;returns type=\"GPResponse\">A GPResponse object with provider and contact details or an error.&lt;\/returns>\n    * &lt;exception cref=\"Error\">Thrown if both primary and backup endpoints fail, with details of the failure.&lt;\/exception>\n    *\/\n    invoke(phoneNumber, licenseKey, isLive, timeoutSeconds) {\n        return (async () => await this.invokeAsync(phoneNumber, licenseKey, isLive, timeoutSeconds))();\n    },\n};\n\nexport { GetPhoneInfoClient, GPResponse };\n\n\nexport class Provider {\n    constructor(data) {\n        this.Name = data.Name;\n        this.City = data.City;\n        this.State = data.State;\n        this.LineType = data.LineType;\n        this.Latitude = data.Latitude;\n        this.Longitude = data.Longitude;\n        this.Quality = data.Quality;\n    }\n    toString() {\n        return `ProviderOutput: Name = ${this.Name}, City = ${this.City}, State = ${this.State}, LineType = ${this.LineType}, Latitude = ${this.Latitude}, Longitude = ${this.Longitude}, Quality = ${this.Quality}`;\n    }\n}\n\nexport class Contact {\n    constructor(data) {\n        this.Name = data.Name;\n        this.Address = data.Address;\n        this.City = data.City;\n        this.State = data.State;\n        this.Zip = data.Zip;\n        this.Type = data.Type;\n    }\n    toString() {\n        return `ContactOutput: Name = ${this.Name}, Address = ${this.Address}, City = ${this.City}, State = ${this.State}, Zip = ${this.Zip}, Type = ${this.Type}`;\n    }\n}\n\nexport class Error {\n    constructor(data) {\n        this.Desc = data.Desc;\n        this.Number = data.Number;\n        this.Location = data.Location;\n    }\n    toString() {\n        return `Desc: ${this.Desc} Number: ${this.Number} Location: ${this.Location}`;\n    }\n}\n\nexport class GPResponse {\n    constructor(data) {\n        this.Providers = (data.Providers || []).map(p => new Provider(p));\n        this.Contacts = (data.Contacts || []).map(c => new Contact(c));\n        this.Error = data.Error ? new Error(data.Error) : null;\n    }\n    toString() {\n        const providers = this.Providers.length ? this.Providers.map(p => p.toString()).join(', ') : 'null';\n        const contacts = this.Contacts.length ? this.Contacts.map(c => c.toString()).join(', ') : 'null';\n        const error = this.Error ? this.Error.toString() : 'null';\n        return `GPResponse: Providers = ${providers}, Contacts = ${contacts}, Error = ${error}`;\n    }\n}\nexport default GPResponse;<\/pre>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"parent":4289,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4291","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>GP - REST<\/title>\n<meta name=\"description\" content=\"C#PythonNodeJS GeoPhone C# Rest Code Snippet \ufeffusing System.Web; namespace geophone_dot_net.REST { \/\/\/ &lt;summary&gt; \/\/\/ Provides functionality to call the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"GP - REST\" \/>\n<meta property=\"og:description\" content=\"C#PythonNodeJS GeoPhone C# Rest Code Snippet \ufeffusing System.Web; namespace geophone_dot_net.REST { \/\/\/ &lt;summary&gt; \/\/\/ Provides functionality to call the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/\" \/>\n<meta property=\"og:site_name\" content=\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-27T05:57:38+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/\",\"name\":\"GP - REST\",\"isPartOf\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#website\"},\"datePublished\":\"2022-11-12T16:23:05+00:00\",\"dateModified\":\"2025-09-27T05:57:38+00:00\",\"description\":\"C#PythonNodeJS GeoPhone C# Rest Code Snippet \ufeffusing System.Web; namespace geophone_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides functionality to call the\",\"breadcrumb\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.serviceobjects.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DOTS GeoPhone\",\"item\":\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"GP &#8211; Code Snippets and Sample Code\",\"item\":\"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"GP &#8211; REST\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#website\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.serviceobjects.com\/docs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#organization\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"contentUrl\":\"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"width\":2560,\"height\":1440,\"caption\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\"},\"image\":{\"@id\":\"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"GP - REST","description":"C#PythonNodeJS GeoPhone C# Rest Code Snippet \ufeffusing System.Web; namespace geophone_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides functionality to call the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/","og_locale":"en_US","og_type":"article","og_title":"GP - REST","og_description":"C#PythonNodeJS GeoPhone C# Rest Code Snippet \ufeffusing System.Web; namespace geophone_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides functionality to call the","og_url":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/","og_site_name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","article_modified_time":"2025-09-27T05:57:38+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/","url":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/","name":"GP - REST","isPartOf":{"@id":"https:\/\/www.serviceobjects.com\/docs\/#website"},"datePublished":"2022-11-12T16:23:05+00:00","dateModified":"2025-09-27T05:57:38+00:00","description":"C#PythonNodeJS GeoPhone C# Rest Code Snippet \ufeffusing System.Web; namespace geophone_dot_net.REST { \/\/\/ &lt;summary> \/\/\/ Provides functionality to call the","breadcrumb":{"@id":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/gp-rest\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.serviceobjects.com\/docs\/"},{"@type":"ListItem","position":2,"name":"DOTS GeoPhone","item":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/"},{"@type":"ListItem","position":3,"name":"GP &#8211; Code Snippets and Sample Code","item":"https:\/\/www.serviceobjects.com\/docs\/dots-geophone\/gp-code-snippets-and-sample-code\/"},{"@type":"ListItem","position":4,"name":"GP &#8211; REST"}]},{"@type":"WebSite","@id":"https:\/\/www.serviceobjects.com\/docs\/#website","url":"https:\/\/www.serviceobjects.com\/docs\/","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","description":"","publisher":{"@id":"https:\/\/www.serviceobjects.com\/docs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.serviceobjects.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.serviceobjects.com\/docs\/#organization","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","url":"https:\/\/www.serviceobjects.com\/docs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/","url":"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","contentUrl":"https:\/\/www.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","width":2560,"height":1440,"caption":"Service Objects | Contact, Phone, Email Verification | Data Quality Services"},"image":{"@id":"https:\/\/www.serviceobjects.com\/docs\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/4291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/comments?post=4291"}],"version-history":[{"count":12,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/4291\/revisions"}],"predecessor-version":[{"id":12354,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/4291\/revisions\/12354"}],"up":[{"embeddable":true,"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/4289"}],"wp:attachment":[{"href":"https:\/\/www.serviceobjects.com\/docs\/wp-json\/wp\/v2\/media?parent=4291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}