Skip to content

Repository files navigation

Foxentry API JavaScript SDK

Introduction

The Foxentry API SDK enables seamless integration of various data validation features into your applications. Whether you require validation for phone numbers, addresses, emails, or other data types, this library offers a user-friendly interface to interact with the Foxentry API. For more comprehensive information about Foxentry, please visit foxentry.com

If you have questions or need further assistance, reach out to us at info@foxentry.cz

Requirements

To use the Foxentry API client, you need the following:

  • A Foxentry account
  • An Application project created with a generated API key
  • A JavaScript environment compatible with modern web standards.

Installation

To begin using the Foxentry API SDK, run the following command:

npm install @foxentry/js-sdk

Getting started

To initiate the usage of the Foxentry API SDK, create an instance of the API client with your API key. This instance allows you to access various resources (e.g., phone, location, email, etc.) and call their methods to access the Foxentry API's functionalities.

Example of e-mail validation

import{ApiClient,Response}from"@foxentry/js-sdk";/*Create a new instance of the ApiClient class and provide your API key.The API key can be generated in the Foxentry administration under Settings > API Keys section.*/constapi: ApiClient=newApiClient();api.setAuth("[YOUR_API_KEY]");// Request queryconstquery={email:"info@foxentry.cz"}// Request optionsconstoptions={acceptDisposableEmails: false// Disables acceptance of disposable emails.}// Set custom parameters for the email validation request.api.email().setCustomId("CustomRequestID")// Sets a custom request ID..setClientIP("127.0.0.1")// Sets the client IP address..setClientCountry("CZ")// Sets the client country code..includeRequestDetails(true)// Returns the request in API response.setOptions(options).validate(query)// Sends request to Foxentry API and performs email validation..then((res: Response): void=>{constresult=res.getResult()constisValid: boolean=result?.isValid;// Displays the result of email validation.console.log(isValid ? "E-mail is valid" : "E-mail is invalid");}).catch(error=>{console.error(error);//Catches an error});

APIClient class

The APIClient class is the main class responsible for communication with the API.

It offers the following methods:

MethodParametersDescription
setAuthAPI keySets API key, that will be used in requests
setApiVersionversion numberSets specific API version, that will be used

To access various resources from this class, simply provide the resource name, and you will be able to access the resource's methods, e.g., api.email().search(query), api.company().get(query), etc.

Resources

The API client provides various resources, each with its own related methods listed below. You can click on the methods to navigate to the API documentation, where you can explore all request inputs, options, and more.

ResourceMethods
Companyvalidate
search
get
Emailvalidate
search
Locationvalidate
search
get
localization
Namevalidate
Phonevalidate

In each method, you must specify query parameters according to the specific endpoint in the API documentation.

To specify options, use the method setOptions({})

To specify the client, use the methods setClientIP(ip), setClientCountry(country) or setClientLocation(lat, lon).

Response class

Response class is returned with every request providing methods below:

MethodParametersDescription
getStatusNoneReturns status code of the response
getResponseNoneReturns full response from the API
getRequestNoneReturns informations about the sent request
getResultNoneReturns result object from the response
getResultCorrectedNoneReturns corrected results from the response
getSuggestionsNoneReturns suggestions from the response
getErrorsNoneReturns errors from the response
getHeadersNoneReturns request headers from the response
getRateLimitNoneReturns request rate limit for the API
getRateLimitPeriodNoneReturns reset period of request rate limit
getRateLimitRemainingNoneReturns remaining rate of requests
getDailyCreditsLeftNoneReturns remaining daily credits
getDailyCreditsLimitNoneReturns daily credits limit
getApiVersionNoneReturns API version used in the request

Testing

The library includes unit tests to ensure its functionality and provide examples of how the library can be used. You can run the tests using Jest. Don't forget to set your API key for these tests using .env.local file.

About

Foxentry SDK for Javascript/Typescript

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages