Getting Started with Java
In a production setup, do not store API Keys in the host's environment variables or in the source code.
Overview
The Opportify Insights API provides access to a powerful and up-to-date platform. With advanced data warehousing, real-time validation, enrichment, and risk scoring capabilities, this API is designed to empower your business to make informed, data-driven decisions and effectively assess potential risks.
Base URLs
| Product | Base URL |
|---|---|
| Email & IP Insights | https://api.opportify.ai/insights/v1 |
| Fraud Protection | https://api.opportify.ai/intel/v1 |
Requirements
Building the API client library requires:
- Java 1.8+
- Maven (3.8.3+)/Gradle (7.2+)
Installation
- Maven
- Gradle
Add this dependency to your project's POM:
<dependency>
<groupId>ai.opportify</groupId>
<artifactId>opportify-sdk-java</artifactId>
<version>0.6.1</version>
<scope>compile</scope>
</dependency>
Add this dependency to your project's build file:
repositories {
mavenCentral() // Needed if the 'opportify-sdk-java' jar has been published to maven central.
mavenLocal() // Needed if the 'opportify-sdk-java' jar has been published to the local maven repo.
}
dependencies {
implementation "ai.opportify:opportify-sdk-java:0.6.1"
}
Install Using Maven as Package Manager
To install the SDK to your local Maven repository, execute:
mvn clean install
Getting Started
After installing the library, create a client instance and interface with it:
// Import classes:
import ai.opportify.client.ApiClient;
import ai.opportify.client.ApiException;
import ai.opportify.client.Configuration;
import ai.opportify.client.auth.*;
import ai.opportify.client.model.*;
import ai.opportify.client.api.EmailInsightsApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.opportify.ai/insights/v1");
// Configure API key authorization: opportifyToken
ApiKeyAuth opportifyToken = (ApiKeyAuth) defaultClient.getAuthentication("opportifyToken");
opportifyToken.setApiKey("YOUR API KEY");
EmailInsightsApi apiInstance = new EmailInsightsApi(defaultClient);
AnalyzeEmailRequest analyzeEmailRequest = new AnalyzeEmailRequest();
analyzeEmailRequest.setEmail("email_to_validate@domain.com");
analyzeEmailRequest.setEnableAutoCorrection(true);
analyzeEmailRequest.setEnableAi(true);
try {
AnalyzeEmail200Response result = apiInstance.analyzeEmail(analyzeEmailRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling EmailInsightsApi#analyzeEmail");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
API Endpoints (Email & IP Insights)
All URIs are relative to https://api.opportify.ai/insights/v1
| Class | Method | HTTP Request | Description |
|---|---|---|---|
EmailInsightsApi | analyzeEmail | POST /email/analyze | Analyze Email |
EmailInsightsApi | batchAnalyzeEmails | POST /email/batch | Batch Analyze Emails |
EmailInsightsApi | createEmailBatchExport | POST /email/batch/{jobId}/exports | Create Email Batch Export |
EmailInsightsApi | getEmailBatchExportStatus | GET /email/batch/{jobId}/exports/{exportId} | Get Email Batch Export Status |
EmailInsightsApi | getEmailBatchStatus | GET /email/batch/{jobId} | Get Email Batch Status |
IpInsightsApi | analyzeIp | POST /ip/analyze | Analyze IP |
IpInsightsApi | batchAnalyzeIps | POST /ip/batch | Batch Analyze IPs |
IpInsightsApi | createIpBatchExport | POST /ip/batch/{jobId}/exports | Create IP Batch Export |
IpInsightsApi | getIpBatchExportStatus | GET /ip/batch/{jobId}/exports/{exportId} | Get IP Batch Export Status |
IpInsightsApi | getIpBatchStatus | GET /ip/batch/{jobId} | Get IP Batch Status |
Authentication
- Type: API key
- API key parameter name:
x-opportify-token - Location: HTTP header
Recommendation
It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.
GitHub Repository
View the source code, report issues, or contribute on GitHub:
opportify/opportify-sdk-java →