Skip to main content

Python client for the Userlist API

Project description

Userlist Python Tests

This library helps with integrating Userlist into Python applications.

Installation

This library can be installed via pip:

pip install userlist-python

Configuration

The only required configuration is the Push API key. You can get your Push API key via the Push API settings in your Userlist account.

Configuration values can be set when creating a new push client or via environment variables. The environment takes precedence over values provided during the initialization process.

Configuration via environment variables

USERLIST_PUSH_KEY=401e5c498be718c0a38b7da7f1ce5b409c56132a49246c435ee296e07bf2be39

Configuration during initialization

from userlist import Userlist

userlist = Userlist(push_key='401e5c498be718c0a38b7da7f1ce5b409c56132a49246c435ee296e07bf2be39')

Usage

Before tracking user or event data, create a new push client. If you configured your push key via environment variables there's nothing to add. Otherwise, see the example above.

from userlist import Userlist
userlist = Userlist()

Tracking Users

Creating & updating Users

user = {
    'identifier': 'user-1',
    'email': 'user@example.com',
    'properties': {
        'first_name': 'Jane',
        'last_name': 'Doe'
    }
}

userlist.users.push(user)

# Aliases
userlist.user(user)
userlist.users.create(user)

Deleting Users

userlist.users.delete('user-1')
userlist.users.delete(user)

Tracking Companies

Creating & updating Companies

company = {
    'identifier': 'company-1',
    'name': 'Example, Inc.',
    'properties': {
        'industry': 'Software Testing'
    }
}

userlist.companies.push(company)

# Aliases
userlist.company(company)
userlist.companies.create(company)

Deleting Companies

userlist.companies.delete('company-1')
userlist.companies.delete({'identifier': 'company-1'})

Tracking Relationships

Creating & updating Relationships

relationship = {
    'user': 'user-1',
    'company': 'company-1',
    'properties': {
        'role': 'admin'
    }
}

userlist.relationships.push(relationship)

# Aliases
userlist.relationship(relationship)
userlist.relationships.create(relationship)

This is equivalent to specifying the relationship on the user model:

user = {
    'identifier': 'user-1',
    'relationships': [{
        'company': 'company-1',
        'properties': {
            'role': 'admin'
        }
    }]
}

userlist.users.push(user)

Or specifying the relationship on the company model:

company = {
    'identifier': 'company-1',
    'relationships': [{
        'user': 'user-1',
        'properties': {
            'role': 'admin'
        }
    }]
}

userlist.companies.push(company)

Deleting Relationships

relationship = {
    'user': 'user-1',
    'company': 'company-1'
}

userlist.relationships.delete(relationship)

Tracking Events

event = {
    'name': 'project_created',
    'user': 'user-1',
    'properties': {
        'name': 'Example Project'
    }
}

userlist.events.push(event)

# Aliases
userlist.event(event)
userlist.events.create(event)

Sending Transactional Messages

message = {
    'user': 'user-1',
    'template': 'welcome-email',
    'properties': {
        'account_name': 'Example, Inc.',
        'billing_plan': 'Pro'
    }
}

userlist.messages.push(message)

# Aliases
userlist.message(message)
userlist.messages.create(message)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/userlist/userlist-python. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The library is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Userlist project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

What is Userlist?

Userlist

Userlist allows you to onboard and engage your SaaS users with targeted behavior-based campaigns using email or in-app messages.

Userlist was started in 2017 as an alternative to bulky enterprise messaging tools. We believe that running SaaS products should be more enjoyable. Learn more about us.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

userlist_python-1.0.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

userlist_python-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file userlist_python-1.0.0.tar.gz.

File metadata

  • Download URL: userlist_python-1.0.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for userlist_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1e4acba2f5edd11d45730106f2bef78668dea14e1e9bf272c21f86444b4e893d
MD5 af994328eb382e8c37f76e47c5aeb857
BLAKE2b-256 94d655744c706b2ba75a6ac127a1e3aecaef7ed5e0d50a9ab1151e7e3d577016

See more details on using hashes here.

File details

Details for the file userlist_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: userlist_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for userlist_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54848f530a9ea37e19ea809b5cc64af1c0b4b1644a66b5e6221aed2b5d91abb3
MD5 29c0a91d627fab4074677f7a2054a52c
BLAKE2b-256 6ed23b3353e70d24edc95c7e76a8ae3dbaca00295e9ff55cc9f4e2abe56d4ec7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page