SDKs overview

Privacy.com offers Software Development Kits (SDKs) and libraries designed to facilitate interaction with its API. These tools allow developers to programmatically manage virtual cards, monitor transactions, and integrate Privacy.com's features into custom applications or financial management systems. The API itself enables operations such as creating new virtual cards, setting spending limits, pausing or closing cards, and retrieving transaction data. This functionality is useful for automating payment processes, enhancing security for online purchases, and managing subscriptions efficiently.

The primary benefit of using an SDK over direct API calls is the abstraction of HTTP requests, authentication, and response parsing, which can reduce development time and potential errors. SDKs often provide language-specific object models that map directly to API resources, making the development experience more intuitive. For example, creating a virtual card through an SDK might involve calling a single method with relevant parameters, rather complex HTTP POST requests and JSON payload construction. The official Privacy.com documentation provides comprehensive resources for developers, including API reference materials and guides for integrating various functionalities Privacy.com API documentation.

Official SDKs by language

Privacy.com provides official SDKs to streamline the integration process for developers. These SDKs are maintained by Privacy.com and are designed to offer a stable and consistent interface for interacting with the Privacy.com API. The official offerings typically cover the most commonly used programming languages, providing idiomatic wrappers around the RESTful API endpoints. Using an official SDK ensures compatibility with the latest API versions and features, as well as access to direct support channels for any integration issues.

The official SDKs abstract the complexities of HTTP requests, error handling, and authentication, allowing developers to focus on application logic rather than low-level API communication. Each SDK typically includes methods corresponding to the main API resources, such as card creation, card management, and transaction retrieval. Developers can find detailed usage instructions and examples within the respective SDK repositories or the main Privacy.com developer documentation Privacy.com developer guides.

Language Package Maturity Description
Python privacy-api Stable Official Python client library for the Privacy.com API, enabling programmatic control of virtual cards.
Node.js privacy-api-node Stable Official Node.js client for integrating virtual card functionalities into JavaScript applications.

Installation

Installing Privacy.com's official SDKs typically follows standard package management procedures for each respective programming language. These methods ensure that all necessary dependencies are resolved and the library is correctly integrated into your project environment. Before installation, it is recommended to ensure your development environment meets the minimum version requirements for the chosen language and its package manager.

Python SDK Installation

For the Python SDK, installation is managed via pip, the standard package installer for Python. Open your terminal or command prompt and execute the following command:

pip install privacy-api

After installation, you can import the library into your Python projects and begin interacting with the Privacy.com API. It's often good practice to install libraries within a virtual environment to manage dependencies for specific projects, avoiding conflicts with other Python projects on your system. Python's official documentation provides extensive guidance on using virtual environments for project isolation.

Node.js SDK Installation

For Node.js projects, the SDK is installed using npm (Node Package Manager) or yarn. Navigate to your project directory in the terminal and run one of the following commands:

npm install privacy-api-node

Or, if you prefer to use Yarn:

yarn add privacy-api-node

Once installed, the library can be imported into your Node.js application using require or ES6 import statements, depending on your project's module system. This will make the Privacy.com API client available for use in your JavaScript code.

Quickstart example

The following quickstart example demonstrates how to use the Privacy.com Python SDK to create a new virtual card. This example assumes you have already obtained your Privacy.com API key and have installed the privacy-api Python package. The process involves initializing the client with your API key and then calling the appropriate method to create a card. For security, API keys should never be hardcoded directly into your application's source code, especially in production environments. Instead, they should be loaded from environment variables or a secure configuration management system.

Python Quickstart: Create a Virtual Card

This Python snippet illustrates the basic steps to authenticate and create a single-use virtual card with a specified spending limit. The card_type parameter can be configured for different use cases, such as 'SINGLE_USE' for one-time purchases or 'MERCHANT_LOCKED' for recurring payments to a specific vendor.


import os
from privacy import PrivacyClient

# Retrieve API key from environment variable for security
API_KEY = os.environ.get("PRIVACY_API_KEY")

if not API_KEY:
    raise ValueError("PRIVACY_API_KEY environment variable not set.")

# Initialize the Privacy.com client
client = PrivacyClient(api_key=API_KEY)

try:
    # Create a new single-use virtual card with a $10.00 spending limit
    new_card = client.card.create(
        memo="My Test Card",
        spend_limit=1000,  # Amount in cents ($10.00)
        spend_limit_duration="TRANSACTION",
        type="SINGLE_USE"
    )

    print(f"Successfully created card: {new_card['token']}")
    print(f"Card number: {new_card['pan']}")
    print(f"Card expiration: {new_card['exp_month']}/{new_card['exp_year']}")
    print(f"Card CVV: {new_card['cvv']}")
    print(f"Card state: {new_card['state']}")

    # Example: Retrieve card details by token
    retrieved_card = client.card.retrieve(new_card['token'])
    print(f"Retrieved card state: {retrieved_card['state']}")

except Exception as e:
    print(f"An error occurred: {e}")

# Further actions could include:
# - Listing all cards: client.card.list()
# - Updating a card's limit: client.card.update(card_token, spend_limit=2000)
# - Pausing a card: client.card.pause(card_token)
# - Closing a card: client.card.close(card_token)

This example demonstrates the basic workflow: setting up the client, making an API call to create a card, and handling the response. The spend_limit is specified in cents, so a value of 1000 corresponds to $10.00. The spend_limit_duration can be set to TRANSACTION (for single transaction limits), MONTHLY, ANNUALLY, or FOREVER, depending on the desired card behavior Privacy.com card creation API reference. After creating a card, its token can be used for subsequent operations like retrieving details, updating limits, or closing the card. For comprehensive details on API endpoints and available parameters, refer to the official Privacy.com API documentation.

Community libraries

While Privacy.com maintains official SDKs for popular languages, the developer community often contributes additional libraries or wrappers that can extend functionality or support other programming environments. These community-driven projects can offer alternative approaches to integration, cater to niche use cases, or provide support for languages not officially covered. However, it is important to note that community libraries may not be officially supported by Privacy.com and their maintenance status can vary.

When considering a community library, developers should evaluate its active maintenance, community support, and alignment with the official API specifications. Checking the project's GitHub repository for recent commits, issue activity, and clear documentation can help assess its reliability. Examples of community contributions might include wrappers in languages like Go, Ruby, or PHP, or integrations with specific frameworks. These often leverage the underlying RESTful API directly, similar to how official SDKs operate. For instance, a community library might provide a more opinionated ORM-like interface for managing virtual cards, or integrate with a popular web framework for easier webhook handling.

Developers who create or discover useful community libraries are encouraged to contribute back to the ecosystem, often by sharing their projects on platforms like GitHub or relevant developer forums. While official SDKs provide a guaranteed path, community efforts can sometimes offer innovative solutions or fill gaps in cross-platform support. Always verify the security and functionality of third-party libraries before integrating them into production systems, especially when dealing with financial data. Information on general practices for secure API integration often applies when using community-developed tools.