Skip to main content

Opportify-SDK-Python

Table of Contents

Overview

The Opportify Insights API provides access to a powerful and up-to-date platform. With advanced data warehousing and AI-driven capabilities, this API is designed to empower your business to make informed, data-driven decisions and effectively assess potential risks.

Sign Up Free

Base URL

Use the following base URL for all API requests:

https://api.opportify.ai/insights/v1/<service>/<endpoint>

Requirements

Requires Python v3.8 or later

Getting Started

First, install Opportify via the pip package manager:

pip install opportify-sdk

Calling Email Insights

from opportify_sdk import EmailInsights

email_insights = EmailInsights("YOUR-API-KEY-HERE")

params = {
    "email": "test@gmial.com",  # *gmial* - just an example to be auto-corrected
    "enableAi": True,
    "enableAutoCorrection": True,
    "enableDomainEnrichment": True  # Optional: include domain enrichment block
}

result = email_insights.analyze(params)

Calling IP Insights

from opportify_sdk import IpInsights

ip_insights = IpInsights("<YOUR-KEY-HERE>")

params = {
    "ip": "3.1.122.82",
    "enableAi": True
}

result = ip_insights.analyze(params)

Calling Fraud Protection

from opportify_sdk import FraudProtection

fraud_protection = FraudProtection("<YOUR-KEY-HERE>")

params = {
    "email": "user@example.com",        # At least one of email or userIp is required
    "userIp": "1.2.3.4",
    "firstName": "John",
    "lastName": "Doe",
    "origin": "example.com",            # Hostname of the page the form was submitted on
    "submissionType": "registration",   # E.g. registration, contactForm, checkout
    "formData": {                        # Optional: any additional form fields
        "custom_field": "value"
    }
}

result = fraud_protection.analyze_fraud(params)

Batch Analysis (Email & IP)

You can submit multiple emails or IPs in a single request. Batch jobs are processed asynchronously; the response returns a job identifier (job_id) you can poll for status.

1. Batch Email Analysis (JSON)

from opportify_sdk import EmailInsights

email_insights = EmailInsights("<YOUR-KEY-HERE>")

params = {
    'emails': [
        'one@example.com',
        'two@example.org'
    ],
    'name': 'Customer Email Validation',  # Optional: descriptive name for the job
    'enableAi': True,
    'enableAutoCorrection': True
}

# Default content type is application/json
batch = email_insights.batch_analyze(params)

# Optional: poll status later
status = email_insights.get_batch_status(batch['job_id'])

2. Batch Email Analysis (Plain Text)

Provide one email per line and set the content type to text/plain.

content = "one@example.com\nTwo.User@example.org"  # newline-delimited emails
batch = email_insights.batch_analyze({'text': content}, 'text/plain')
status = email_insights.get_batch_status(batch['job_id'])

3. Batch Email Analysis (File Upload)

Supply a .csv (one email per row; header optional) via batch_analyze_file(). A .csv triggers multipart/form-data; other extensions fall back to text/plain (newline-delimited body).

batch = email_insights.batch_analyze_file('emails.csv', {
    'name': 'Monthly Email Cleanup',  # Optional: descriptive name for the job
    'enableAi': True,
    'enableAutoCorrection': True
})
status = email_insights.get_batch_status(batch['job_id'])

4. Batch IP Analysis (JSON)

from opportify_sdk import IpInsights

ip_insights = IpInsights("<YOUR-KEY-HERE>")

params = {
    'ips': [
        '1.1.1.1',
        '8.8.8.8'
    ],
    'name': 'Network Security Scan',  # Optional: descriptive name for the job
    'enableAi': True
}

batch = ip_insights.batch_analyze(params)  # application/json
status = ip_insights.get_batch_status(batch['job_id'])

5. Batch IP Analysis (Plain Text)

content = "1.1.1.1\n8.8.8.8"  # newline-delimited IPs
batch = ip_insights.batch_analyze({'text': content}, 'text/plain')
status = ip_insights.get_batch_status(batch['job_id'])

6. Batch IP Analysis (File Upload)

batch = ip_insights.batch_analyze_file('ips.csv', {
    'name': 'Firewall IP Assessment',  # Optional: descriptive name for the job
    'enableAi': True
})
status = ip_insights.get_batch_status(batch['job_id'])

Convenience & Notes

  • batch_analyze_file() auto-selects content type: .csv -> multipart/form-data; otherwise text/plain.
  • For text/plain, pass newline-delimited values via the text key.
  • For multipart/form-data, pass a readable file path via the file key (handled internally by batch_analyze_file()).
  • The name parameter is optional for all batch operations and helps with job identification and tracking.
  • enableAutoCorrection applies only to Email Insights.
  • Always wrap calls in a try-except (see Error Handling) to capture API errors.
  • Polling cadence depends on payload size; a short delay (1–3s) between status checks is recommended.

Batch Export Jobs

Use batch exports to materialize filtered results from completed jobs. Exports run asynchronously and expose polling helpers similar to batch status checks.

Email Batch Exports

email_insights = EmailInsights('<YOUR-KEY-HERE>')

# Trigger a new export for a completed batch job
export = email_insights.create_batch_export('job-uuid-here', {
    'exportType': 'csv',
    'columns': [
        'emailAddress',
        'emailProvider',
        'riskReport.score',
        'isDeliverable'
    ],
    'filters': {
        'isDeliverable': 'true',
        'riskReport.score': {'min': 400}
    }
})

# Poll until the export is ready
status = email_insights.get_batch_export_status('job-uuid-here', export['export_id'])

if status['status'] == 'COMPLETED':
    # Use status['download_url'] for the pre-signed file link
    print(f"Download: {status['download_url']}")

IP Batch Exports

ip_insights = IpInsights('<YOUR-KEY-HERE>')

export = ip_insights.create_batch_export('job-uuid-here', {
    'exportType': 'json',
    'columns': [
        'result.ipAddress',
        'result.connectionType',
        'result.riskReport.score'
    ],
    'filters': {
        'result.riskReport.level': ['low', 'medium']
    }
})

status = ip_insights.get_batch_export_status('job-uuid-here', export['export_id'])

if status['status'] == 'COMPLETED':
    # Use status['download_url'] to retrieve the generated export
    print(f"Download: {status['download_url']}")
elif status['status'] == 'FAILED':
    # Review status['error_code'] and status['error_message'] for remediation guidance
    print(f"Error: {status['error_code']} - {status['error_message']}")

Enabling Debug Mode

client_insights.set_debug_mode(True)

Handling Errors

We strongly recommend that any usage of this SDK happens within a try-except to properly handle any exceptions or errors.

from openapi_client.exceptions import ApiException

try:
    # Email or IP Insights usage...
    result = email_insights.analyze(params)
except ApiException as e:
    print(f"API Error: {e.status} - {e.reason}")
    print(f"Response: {e.body}")
except Exception as e:
    print(f"Error: {str(e)}")

For Fraud Protection, import ApiException from fraud_intel_client instead:

from fraud_intel_client.exceptions import ApiException

try:
    result = fraud_protection.analyze_fraud(params)
except ApiException as e:
    print(f"API Error: {e.status} - {e.reason}")
    print(f"Response: {e.body}")
except Exception as e:
    print(f"Error: {str(e)}")

Below are common error responses you might encounter:

Status Code Error Type Description
400 Bad Request Invalid parameters or malformed request
401 Unauthorized Invalid or missing API key
402 Payment Required Account has insufficient credits
403 Forbidden Plan limitation or feature not available
404 Not Found Resource not found (e.g., invalid job ID)
413 Payload Too Large Request exceeds maximum size (3MB)
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server-side error occurred

About this package

This Python package is a customization of the base generated by:

Metadata

Release files for opportify-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opportify-sdk 1.0.0
File Size Uploaded Provenance Actions
opportify_sdk-1.0.0.tar.gz 114.3 kB Without provenance Details for opportify_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opportify-sdk 1.0.0
File Interpreter ABI Platform Actions
opportify_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for opportify_sdk-1.0.0-py3-none-any.whl

Total release size: 331.3 kB

Release files / opportify_sdk-1.0.0.tar.gz

Download URL opportify_sdk-1.0.0.tar.gz
Size 114.3 kB
Tags Source
SHA-256 checksum
How to use checksums
75855a316ea815994b9f37a8a37b0ce28f4af8633403dd044ae6b3a33c3dddce
BLAKE2b-256 checksum
How to use checksums
c72c375ce46a57c71351e8248a2db7cc86256e812f62c2bcc757e558a20da4b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / opportify_sdk-1.0.0-py3-none-any.whl

Download URL opportify_sdk-1.0.0-py3-none-any.whl
Size 217.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6c5fdede8c7c2e1bbd06a91e15f18f7bd70278065636502736410d9f3a26430
BLAKE2b-256 checksum
How to use checksums
40cc29f7bf14732540ced415a6f532ffa6b07093f73318acc9966b324450155b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for opportify-sdk 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page