PHPackages                             richardhj/newsletter2go-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. richardhj/newsletter2go-api

ActiveLibrary[API Development](/categories/api)

richardhj/newsletter2go-api
===========================

Model based Newsletter2Go API implementation

v2.0.0(8y ago)11.6k2[1 PRs](https://github.com/richardhj/newsletter2go-api/pulls)1LGPL-3.0-or-laterPHPPHP ^5.4|^7.0

Since Aug 27Pushed 7y ago1 watchersCompare

[ Source](https://github.com/richardhj/newsletter2go-api)[ Packagist](https://packagist.org/packages/richardhj/newsletter2go-api)[ RSS](/packages/richardhj-newsletter2go-api/feed)WikiDiscussions v2.0 Synced today

READMEChangelog (5)Dependencies (1)Versions (8)Used By (1)

Newsletter2Go model based API integration
=========================================

[](#newsletter2go-model-based-api-integration)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0fa2796ab8a406973a445e14187b443520bb589cf0c640096efdf48b8930db90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696368617264686a2f6e6577736c657474657232676f2d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/richardhj/newsletter2go-api)![Software License](https://camo.githubusercontent.com/2bc95db9d4d6b319fe40fe1a46431a18f9684b30d516775115c5d0df6aa3e9b4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4c47504c2d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)[![Dependency Status](https://camo.githubusercontent.com/6c18c0d2baac35c857b80379099886c1764bafb4b26f4bcd77bfbe29d0b05297/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f72696368617264686a3a6e6577736c657474657232676f2d6170692f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/php/richardhj:newsletter2go-api)

This package provides a model based implementation of the Newsletter2Go API. It aims to make complex documentations unnecessary. With its clear structure and extensive PHPDoc, it is really easy to use.

Install
-------

[](#install)

Via Composer

```
$ composer require richardhj/newsletter2go-api
```

Usage
-----

[](#usage)

### Fetch and alter

[](#fetch-and-alter)

If you want to fetch items via the API there might be a static function for. Example:

```
$users = Richardhj\Newsletter2Go\Api\Model\NewsletterUser::findAll(null, $apiCredentials);

// Use a PHPDoc comment and profit from auto suggestion
/** @var NewsletterUser $user */
foreach ($users as $user) {
    // What's about naming all users "Doe"?
    $user->setLastName('Doe');
    // Save the user (via the API of course)
    $user->save();

    // $data contains all data fetched for this item
    $data = $user->getData();
}
```

```
$recipients = Richardhj\Newsletter2Go\Api\Model\NewsletterRecipient::findByListAndGroup('abc123', 'xyz987', null, $apiCredentials);
var_dump($recipients);

foreach ($recipients as $recipient) {
    $recipient->addToGroup('xyz345');
    $recipient->removeFromGroup('asdf12');
}
```

#### Api Credentials

[](#api-credentials)

`ApiCredentials` are mandatory for the api communication. First of all you need the `auth_key` that can be found in the Newsletter2Go back end. The `auth_key` is the same for all company's accounts. Furthermore you either need a user's `username` and `password` or a user's `refresh_token`.

If you rather want to use and save the `refresh_token` instead of username and password in your application, you have to make an initial api authorization call with the `username` and `password` anyway. Check the [manual of the corresponding OAuth provider](https://github.com/richardhj/oauth2-newsletter2go/blob/master/README.md) to get to know how to fetch a `refresh_token`.

```
// Use the ApiCredentialsFactory
$apiCredentials = ApiCredentialsFactory::createFromUsernameAndPassword('secret_auth_token', 'user@example.org', 'open_sesame');
$apiCredentials = ApiCredentialsFactory::createFromRefreshToken('secret_auth_token', 'secret_users_refresh_token');
// Or simply use ::create()
$apiCredentials = ApiCredentialsFactory::create('secret_auth_token', 'secret_users_refresh_token');
```

#### Get parameters

[](#get-parameters)

When fetching a collection from the api, you can provide a `GetParamters` instance. Get parameters allow you to filter, limit etc. the item collection that will be returned. Example:

```
$getParams = new Richardhj\Newsletter2Go\Api\Tool\GetParameters();
$getParams
    ->setExpand(true)
    ->setFilter('email=like="%@example.org"')
    ->setOffset(2)
    ->setLimit(1);

$recipients = Richardhj\Newsletter2Go\Api\Model\NewsletterRecipient::findByListAndGroup('abc123', 'xyz987', $getParams, $apiCredentials);
var_dump($recipients);
```

### Create

[](#create)

If you want to create items via the API, this is how. Example:

```
$recipient = new Richardhj\Newsletter2Go\Api\Model\NewsletterRecipient();
$recipient->setApiCredentials($apiCredentials);
$recipient
    ->setListId('abc123')
    ->setFirstName('John')
    ->setLastName('Doe')
    ->setEmail('doe@example.org')
    ->setGender('m');

// Good to have an id, otherwise the email address will be the primary key and you will not be able to change the email address of a recipient properly
$recipient->setId('xyz123');

// Update an existing recipient (when id given or email address known in Newsletter2Go) or create a new recipient
$recipient->save();
```

### Delete

[](#delete)

For models that implement `Newsletter2Go\Api\Model\ModelDeletableInterface`, `delete()` is available. Example:

```
$groups = Newsletter2Go\Api\Model\NewsletterGroup::findByList('abc123', $getParams, $credentials);

/** @var NewsletterGroup $group */
foreach ($groups as $group) {
    $group->delete();
}
```

### Official API documentation

[](#official-api-documentation)

Visit [the official API documentation](https://docs.newsletter2go.com) for reference.

License
-------

[](#license)

The GNU Lesser General Public License (LGPL).

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~127 days

Total

6

Last Release

2955d ago

Major Versions

v1.0.0-beta.4 → v2.0.02018-05-28

PHP version history (3 changes)v1.0.0-beta.1PHP &gt;=5.4

v1.0.0-beta.3PHP ^5.4 || ^7.0

v2.0.0PHP ^5.4|^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1284725?v=4)[Richard Henkenjohann](/maintainers/richardhj)[@richardhj](https://github.com/richardhj)

---

Top Contributors

[![richardhj](https://avatars.githubusercontent.com/u/1284725?v=4)](https://github.com/richardhj "richardhj (22 commits)")

---

Tags

apiapi-wrappernewsletternewsletter2gonewsletter2go-apiapinewsletter2go

### Embed Badge

![Health badge](/badges/richardhj-newsletter2go-api/health.svg)

```
[![Health](https://phpackages.com/badges/richardhj-newsletter2go-api/health.svg)](https://phpackages.com/packages/richardhj-newsletter2go-api)
```

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.5k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
