+
Skip to content

jmarxuach/TeenvioAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TeenvioAPI

Overview

TeenvioAPI is a Python class that provides an interface to interact with the Teenvio email marketing API. It allows users to:

  • Authenticate and establish a session
  • Create newsletters
  • Create recipient groups
  • Add recipients to a group
  • Send email campaigns

Installation

This module requires requests for making API calls. Install it using:

pip install requests

Usage

Import the Class

from teenvio_api import TeenvioAPI

Initialize and Authenticate

api = TeenvioAPI()
username = "your_username"
password = "your_password"
host = "https://<api_teenvio_url>"

if api.GetSession(username, password, host):
    print("Authenticated successfully!")
else:
    print("Authentication failed!")

Create a Newsletter

newsletter_name = "My Newsletter"
newsletter_html = "<h1>Welcome to our newsletter!</h1>"
newsletter_id = api.CreateNewsletter(newsletter_name, newsletter_html)

if newsletter_id:
    print(f"Newsletter created successfully with ID: {newsletter_id}")
else:
    print("Failed to create newsletter")

Create a Group and Add Recipients

group_name = "Subscribers"
recipients = ["user1@example.com", "user2@example.com"]

group_id = api.CreateGroup(group_name, recipients)
if group_id:
    print(f"Group created successfully with ID: {group_id}")
else:
    print("Failed to create group")

Send a Campaign

campaign_name = "New Product Launch"
sender_id = "12345" # sender id in teenvio
replyto = "12345" # None or sender id in teenvio 
subject = "Introducing our new product!"
lang_id = "4" # Languages code in teenvio {'ca': '15', 'en': '4', 'es': '3'}   

campaign_id = api.SendCampaign(
    campaign_name, sender_id, replyto, subject, newsletter_id, group_id, lang_id
)

if campaign_id:
    print(f"Campaign sent successfully with ID: {campaign_id}")
else:
    print("Failed to send campaign")

Logging

The class uses Python's logging module to log errors and responses. To enable logging, configure it as follows:

import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

License

This project is licensed under the MIT License.

About

Python class that provides an interface to interact with the Teenvio email marketing API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载