newsletter2-go-api

1.0.0 • Public • Published

newsletter2-go-api-(https://api/newsletter2go/com)

Newsletter2GoApi(https:ApiNewsletter2goCom) - JavaScript client for newsletter2-go-api-(https://api/newsletter2go/com)

JSON first

Our REST API exchanges data in the JSON data format. Every parameter you pass (with a few exceptions e.g. when you upload files) should therefore be formatted in JSON and our API will always return results in JSON as well.

Very RESTful

Our API follows a very RESTful approach.
Most importantly, we implemented the following four request methods for CRUD operations:

POST - Create a new record
GET - Retrieve / read records without changing anything
PATCH - Update an existing record
DELETE - Delete one or more records

HTTP Status codes

We also follow the most common HTTP status codes when outputting the API response:

2xx - Successful calls
200 - Success
201 - Created

4xx - Error codes
400 - API error - inspect the body for detailed information about what went wrong. The most common error is \"code\":1062, which means, that a unique constraint was hit. For example if the name of the group is already in use.
401 - Not authenticated - invalid access_token. Check if the access_token has expired or is incorrect.
403 - Access denied
404 - Call not available or no records found

5xx - API error - please contact support

Response format

The API always returns data in the following format

{
  \"info\": {
    \"count\": 0
  },
  \"value\": [
   {
    \"key\": \"value\"
   }
  ]
}


Recurring GET parameters

  • _filter - a complex filter for filtering the result set based on FIQL.
  • _limit - the maximum number records returned.
  • _offset - pagination for the result-set
  • _expand - submit true to get all default fields of the resource
  • _fields - submit a comma-separated list of case-sensetive field-names to get the values of these fields in the response. You can use this the get values of custom attribute of recipients for example.


Filter language

The filter language for filtering results is based on FIQL.
With the only restriction, that plain values must be surrounded by \". For example first_name==\"Max\"
The following operators are supported
  • Equals - ==
  • Not equals - =ne=
  • Greater than - =gt=
  • Greater than equals - =ge=
  • Lower than - =lt=
  • Lower than equals - =le=
  • Like - =like= (in combination with % you are able to search for starts with, ends with, contains. For example first_name=like=\"%Max%\")
  • Not like - =nlike=
  • Logical and - ;
  • Logical or - ,


How to make Calls?

After you authenticated and received a valid access_token, you have to pass it in every consecutive call. Use the Authorization header for that purpose as follows:
xhr.setRequestHeader(\"Authorization\", \"Bearer \" + your_access_token);

Every call takes additional parameters that can be used to modify the request. These parameters should be passed as JSON
var params = {
  \"key\"= \"value\"
}
xhr.send(JSON.stringify(params));


Sending transactional emails

It is very important to understand the following concept in order for you to take full advantage of our powerful personalization features and our detailed reports when sending transactional emails.

First, you will have to create a new mailing. We recommend that you create that mailing through our UI in order to take full advantage of our powerful newsletter builder. This way, we will automatically create cross-client optimized and responsive HTML. Yet another advantage lies in the possibility for other users (e.g. the marketing team) to change the layout or the content of the mailing without having to contact the developer (you).

Of course, it is also possible to create a mailing through the API. When doing so, you can also take advantage of our cross-client optimized responsive HTML by passing us JSON or YAML according to the Newsletter2Go Markup Language.
No matter how you create the mailing, try to create *one* reusable template. You can customize individual emails by inserting placeholders for personalized fields such as name, products or other information that will be filled through an API call when sending.

By only creating one template, you can take advantage of our full reporting since all emails will be treated part of a \"campaign\". When you change that template, we will create a new version of the mailing in the background and you will be able to see the difference in performance in the reports. This is particularily useful when you are trying to test and optimize different versions of transactional emails such as a sign up email.

After creating a mailing, you will have access to its ID. Use that ID to actually send the email in the next step.

When sending an email, you have to pass the newsletter ID and information about the recipient. Either pass the recipient ID or pass all the recipient's data (including the e-mail-address) as JSON.

If you only pass the recipient ID, we will use his or her data from your list to personalize the mailing. If you pass full recipient data as JSON, we will try to merge the data with existing data from your list.

You can also pass additional data such as product data which is not saved in your list. Just make sure that the placeholders in the source of the mailing correspond to the parameters that you are passing.
This way you can also create for-loops which can be useful if you pass different amounts of data for each recipient (e.g. a purchase confirmation where you want to list all the products that were just bought). This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
  • API version: 1.0.0
  • Package version: 1.0.0
  • Build date: 2016-06-08T06:59:42.502Z
  • Build package: class io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install newsletter2-go-api-(https://api/newsletter2go/com) --save

git

If the library is hosted at a git repository, e.g. https://github.com/YOUR_USERNAME/newsletter2-go-api-(https://api/newsletter2go/com) then install it via:

    npm install YOUR_USERNAME/newsletter2-go-api-(https://api/newsletter2go/com) --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Getting Started

Please follow the installation instruction and execute the following JS code:

var Newsletter2GoApi(https:ApiNewsletter2goCom) = require('newsletter2-go-api-(https://api/newsletter2go/com)');

var defaultClient = Newsletter2GoApi(https:ApiNewsletter2goCom).ApiClient.default;

// Configure OAuth2 access token for authorization: OAuth
var OAuth = defaultClient.authentications['OAuth'];
OAuth.accessToken = "YOUR ACCESS TOKEN"

var api = new Newsletter2GoApi(https:ApiNewsletter2goCom).AttributeApi()

var attribute = new Newsletter2GoApi(https:ApiNewsletter2goCom).AttributePost(); // {AttributePost} the data to save


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.createAttribute(attribute, callback);

Documentation for API Endpoints

All URIs are relative to https://api.newsletter2go.com

Class Method HTTP request Description
Newsletter2GoApi(https:ApiNewsletter2goCom).AttributeApi createAttribute POST /attributes creates a new attribute
Newsletter2GoApi(https:ApiNewsletter2goCom).AttributeApi deleteAttribute DELETE /lists/{lid}/attributes/{id} delete the attribute
Newsletter2GoApi(https:ApiNewsletter2goCom).AttributeApi getAttributes GET /lists/{lid}/attributes get all Attributes of selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).AttributeApi updateAttribute PATCH /attributes/{id} update the attribute
Newsletter2GoApi(https:ApiNewsletter2goCom).AuthorizationApi getToken POST /oauth/v2/token Endpoint for retrieving a token
Newsletter2GoApi(https:ApiNewsletter2goCom).CompanyApi getCompany GET /companies get the details of a company
Newsletter2GoApi(https:ApiNewsletter2goCom).CompanyApi updateCompany PATCH /companies/{id} update the Company
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi addRecipientToGroup POST /lists/{lid}/groups/{gid}/recipients/{id} add single recipient to group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi addRecipientsToGroup POST /lists/{lid}/groups/{gid}/recipients add all Recipients to the given group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi createGroup POST /groups creates a new group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi deleteGroup DELETE /groups/{id} delete the Group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi getGroups GET /lists/{lid}/groups get all Group of selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi getRecipientsByGroup GET /lists/{lid}/groups/{gid}/recipients get all Recipients of selected group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi removeRecipientFromGroup DELETE /lists/{lid}/groups/{gid}/recipients/{id} remove single recipient from group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi removeRecipientsFromGroup DELETE /lists/{lid}/groups/{gid}/recipients remove all Recipients from given group
Newsletter2GoApi(https:ApiNewsletter2goCom).GroupApi updateGroup PATCH /groups/{id} update the Group
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi createList POST /lists creates a new list
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi deleteList DELETE /lists/{id} delete the List
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi getLists GET /lists get all lists
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi getRecipients GET /lists/{lid}/recipients get all Recipients of selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi removeRecipientsFromList DELETE /lists/{lid}/recipients remove all Recipients from selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi updateList PATCH /lists/{id} update the List
Newsletter2GoApi(https:ApiNewsletter2goCom).ListApi updateRecipients PATCH /lists/{lid}/recipients update all Recipients in selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).NewsletterApi createNewsletter POST /lists/{lid}/newsletters creates a new newsletter
Newsletter2GoApi(https:ApiNewsletter2goCom).NewsletterApi getNewsletter GET /newsletters/{id} get one newsletter
Newsletter2GoApi(https:ApiNewsletter2goCom).NewsletterApi getNewsletters GET /lists/{lid}/newsletters get all newsletters of the given list
Newsletter2GoApi(https:ApiNewsletter2goCom).NewsletterApi getReports GET /lists/{lid}/newsletters/{nid}/aggregations get reports for the newsletter aggregated by days
Newsletter2GoApi(https:ApiNewsletter2goCom).NewsletterApi sendNewsletter POST /newsletters/{id}/send Sends the newsletter to a list or group
Newsletter2GoApi(https:ApiNewsletter2goCom).NewsletterApi updateNewsletter PATCH /newsletters/{id} update the Newsletter
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi addRecipientToGroup POST /lists/{lid}/groups/{gid}/recipients/{id} add single recipient to group
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi addRecipientsToGroup POST /lists/{lid}/groups/{gid}/recipients add all Recipients to the given group
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi createRecipient POST /recipients create new recipient(s) or updates existing ones
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi deleteRecipient DELETE /lists/{lid}/recipients/{id} delete the recipient
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi getRecipients GET /lists/{lid}/recipients get all Recipients of selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi getRecipientsByGroup GET /lists/{lid}/groups/{gid}/recipients get all Recipients of selected group
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi importRecipientsInit POST /lists/{lid}/recipients/import/init Initialize the import of recipients by file
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi importRecipientsSave POST /lists/{lid}/recipients/import/save Start the import recipients by file
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi importRecipientsStatistics GET /import/{id}/info Get statistics about the import by file
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi removeRecipientFromGroup DELETE /lists/{lid}/groups/{gid}/recipients/{id} remove single recipient from group
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi removeRecipientsFromGroup DELETE /lists/{lid}/groups/{gid}/recipients remove all Recipients from given group
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi removeRecipientsFromList DELETE /lists/{lid}/recipients remove all Recipients from selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi subscribeRecipient POST /forms/submit/{code} Creates a new recipient and sends a DOI-Mail
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi updateRecipient PATCH /lists/{lid}/recipients/{id} update the recipient.
Newsletter2GoApi(https:ApiNewsletter2goCom).RecipientApi updateRecipients PATCH /lists/{lid}/recipients update all Recipients in selected list
Newsletter2GoApi(https:ApiNewsletter2goCom).ReportApi getReports GET /lists/{lid}/newsletters/{nid}/aggregations get reports for the newsletter aggregated by days
Newsletter2GoApi(https:ApiNewsletter2goCom).UserApi getUsers GET /users get all users of the company where the current user has access to
Newsletter2GoApi(https:ApiNewsletter2goCom).UserApi updateUser PATCH /users/{id} update the user

Documentation for Models

Documentation for Authorization

OAuth

  • Type: OAuth
  • Flow: implicit
  • Authorization URL: /oauth/v2/token
  • Scopes: N/A

Basic

  • Type: HTTP basic authentication

Readme

Keywords

none

Package Sidebar

Install

npm i newsletter2-go-api

Weekly Downloads

2

Version

1.0.0

License

Apache-2.0

Unpacked Size

461 kB

Total Files

119

Last publish

Collaborators

  • grafzahl-io