.NET

using System.Net;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;

namespace ValidationAPISample
{
    [DataContract]
    class APIRequest
    {
        [DataMember(Name = "apiKey")]
        public string ApiKey;        

        [DataMember(Name = "payload")]
        public string Payload;
    }

    [DataContract]
    class APIError
    {
        [DataMember(Name = "code")]
        public int Code;

        [DataMember(Name = "detail")]
        public string Detail;
    }

    [DataContract]
    class APIResponsePayload
    {
        [DataMember(Name = "disposable")]
        public double Disposable;

        [DataMember(Name = "free")]
        public double Free;

        [DataMember(Name = "spam")]
        public double Spam;

        [DataMember(Name = "scam")]
        public double Scam;
    }

    [DataContract]
    class APIResponse
    {
        [DataMember(Name = "errors")]
        public APIError[] Errors;

        [DataMember(Name = "payload")]
        public APIResponsePayload Payload;
    }

    class Program
    {
        static void Main(string[] args)
        {           
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.inboxhit.com/v1/validate-email");
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                using (var ms = new MemoryStream())
                {
                    APIRequest apiRequest = new APIRequest() { ApiKey = "YOUR API KEY", Payload = "someone@disposableemail.com" };
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(APIRequest));
                    ser.WriteObject(ms, apiRequest);
                    byte[] json = ms.ToArray();
                    ms.Close();

                    streamWriter.Write(Encoding.UTF8.GetString(json, 0, json.Length));
                    streamWriter.Flush();
                    streamWriter.Close();
                }
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var stream = httpResponse.GetResponseStream())
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(APIResponse));
                var result = (APIResponse)ser.ReadObject(stream);
                if (result.Payload != null && result.Payload.Disposable > 0.9)
                {
                    // email is disposable
                }
            }
        }
    }
}

PHP Go

Get Started Now

Use InboxHit online solution to boost your email deliverability. Get 1000 welcome credits.

Click your favorite button below for a one-click sign-up.

Google Twitter Facebook LinkedIn

InboxHit provides solutions and services to boost email deliverability, increase email marketing efficiency and achieve 100% innox hit rate. Use InboxHit API to detect disposable emails, block disposable emails, detect and block DEAs, validate email addresses, check if a mailbox exists, reduce bounces, boost deliverability, increase email marketing efficiency, reduce email delivery costs. InboxHit API is also available on RapidAPI.