Sessions

The Session class provides TinyAPI’s core functionality. It manages the authentication cookies and token for all requests to TinyLetter’s undocumented API.

Usage

class tinyapi.Session(username, password=False)

An authenticated tinyletter.com session.

count_messages(statuses=['sent', 'sending'])

Returns the number of messages your account has sent.

DEFAULT_MESSAGE_STATUSES is set to [ "sent", "sending" ].

Other possible statuses include “draft”, “failed_review”, “failed_disabled”, and “failed_schedule”.

get_messages(statuses=['sent', 'sending'], order='sent_at desc', offset=None, count=None, content=False)

Returns a list of messages your account sent.

Messages are sorted by order, starting at an optional integer offset, and optionally limited to the first count items (in sorted order).

Returned data includes various statistics about each message, e.g., total_opens, open_rate, total_clicks, unsubs, soft_bounces. If content=True, the returned data will also include HTML content of each message.

get_drafts(**kwargs)

Same as Session.get_messages, but where statuses=["draft"].

get_message(message_id)

Return stats and message content for a given message.

count_urls()

Returns the total number of URLs included in your messages

get_urls(order='total_clicks desc', offset=None, count=None)

Returns a list of URLs you’ve included in messages.

List is sorted by total_clicks, starting at an optional integer offset, and optionally limited to the first count items.

get_message_urls(message_id, order='total_clicks desc')

Returns a list of URLs you’ve included in a specific message.

List is sorted by total_clicks, starting at an optional integer offset, and optionally limited to the first count items.

count_subscribers()

Returns your newsletter’s number of subscribers.

get_subscribers(order='created_at desc', offset=None, count=None)

Returns a list of subscribers.

List is sorted by most-recent-to-subsribe, starting at an optional integer offset, and optionally limited to the first count items (in sorted order).

Returned data includes various statistics about each subscriber, e.g., total_sent, total_opens, total_clicks.

get_subscriber(subscriber_id)

Returns data corresponding to a specific subcriber.

create_draft()

Create a new draft message.

edit_draft(message_id)

Fetch a specific draft to be edited.

Advanced Usage

class tinyapi.Session(username, password=False)

An authenticated tinyletter.com session.

request(service, data)

Makes a call to TinyLetter’s __svcbus__ endpoint.