simple api client for onetimesecret.com
Project description
onetimesecret-cli
A simple Python client for interacting with the OneTimeSecret API, allowing you to securely share secrets with a customizable expiration time and region support.
Installation
Install via pip:
pip install onetimesecret
Usage
To use the OneTimeSecretCli client, import the class and initialize it with your OneTimeSecret API credentials. You can optionally specify a default region (e.g., "us" or "eu").
from onetimesecret import OneTimeSecretCli
# Replace with your OneTimeSecret credentials and preferred region
ONETIMESECRET_USER = "your_username"
ONETIMESECRET_KEY = "your_api_key"
REGION = "us" # Default region, can be "us" or "eu"
# Initialize the client
cli = OneTimeSecretCli(ONETIMESECRET_USER, ONETIMESECRET_KEY, REGION)
# Create a link for a secret message with a specified Time-to-Live (TTL)
link = cli.create_link("Your secret message here")
print("Secret link:", link)
Parameters
Initialization
cli = OneTimeSecretCli(ONETIMESECRET_USER, ONETIMESECRET_KEY, REGION)
- ONETIMESECRET_USER (str, optional): Your OneTimeSecret API username (usually your account email).
- ONETIMESECRET_KEY (str, optional): Your OneTimeSecret API key.
- REGION (str, optional): The region subdomain to use for API requests. Defaults to "us". Use "eu" for Europe. See Onetimesecret's website for the latest regions available.
Examples:
# US region (default)
cli = OneTimeSecretCli("user@email.com", "api-key")
# EU region
cli = OneTimeSecretCli("user@email.com", "api-key", "eu")
# Anonymous Request (default region: US)
cli = OneTimeSecretCli()
Creating a Link
create_link(secret, ttl=900)
- secret (str): The secret message you want to securely share.
- ttl (int, optional): The time-to-live for the secret in seconds (e.g., 900 for 15 minutes). Defaults to 900 seconds.
Expected Output
Running the example code will print a secure link that can be shared:
Secret link: https://us.onetimesecret.com/secret/xxxxxxxxxxx
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file onetimesecret-1.tar.gz
.
File metadata
- Download URL: onetimesecret-1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa66f87b2ae7179baa4e7c6f8c99d4bbaa2f0ea27f7df6d27422a972222982d |
|
MD5 | 27bbf674cb9ce8d1c08e1be45046d4e2 |
|
BLAKE2b-256 | f041bb50778b54a8e05aab493fb9b030476df4bbfed15cd9d2f00f4c395302e3 |
File details
Details for the file onetimesecret-1-py3-none-any.whl
.
File metadata
- Download URL: onetimesecret-1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65ec46ec6be7d58bc0c8c7e98cd32b2d17b448b688736b632d32c6f408f6e104 |
|
MD5 | 476ba25b3d66dc6350565a605dc1aac4 |
|
BLAKE2b-256 | 2ac2ffde8d82c38cbccae6f7d25b9562d7411dcebecfc94902d59be844bd8c2c |