All Projects → MediaMath → T1 Node

MediaMath / T1 Node

Licence: apache-2.0
Node SDK for MediaMath Platform APIs

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to T1 Node

Circuit Sdk
JavaScript and Node.js SDK for Circuit
Stars: ✭ 18 (+100%)
Mutual labels:  sdk
Httpdoc
基于Java标准doc注释构建的代码零侵入的HTTP RESTful API在线测试,文档阅览以及SDK导出框架,支持Spring-Boot和Spring-MVC
Stars: ✭ 23 (+155.56%)
Mutual labels:  sdk
Aliyun Openapi Python Sdk
Alibaba Cloud SDK for Python
Stars: ✭ 840 (+9233.33%)
Mutual labels:  sdk
Win Php Sdk Builder
build a php-sdk environment on Win
Stars: ✭ 19 (+111.11%)
Mutual labels:  sdk
Bitgosdk Php
BitGo SDK written in PHP
Stars: ✭ 22 (+144.44%)
Mutual labels:  sdk
Svrf Ios Sdk
iOS SDK for the Svrf API and ARKit Face Filters
Stars: ✭ 24 (+166.67%)
Mutual labels:  sdk
Azure Kinect Sensor Sdk
A cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.
Stars: ✭ 889 (+9777.78%)
Mutual labels:  sdk
Weixinmpsdk
微信全平台 SDK Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 6.0。已支持微信公众号、小程序、小游戏、企业号、企业微信、开放平台、微信支付、JSSDK、微信周边等全平台。 WeChat SDK for C#.
Stars: ✭ 7,098 (+78766.67%)
Mutual labels:  sdk
Libra Sdk Go
Go SDK for the Libra cryptocurrency
Stars: ✭ 23 (+155.56%)
Mutual labels:  sdk
Mixpanel Iphone
iPhone tracking library for Mixpanel Analytics
Stars: ✭ 939 (+10333.33%)
Mutual labels:  sdk
Mixpanel Android
Official Mixpanel Android SDK
Stars: ✭ 907 (+9977.78%)
Mutual labels:  sdk
Itext7
iText 7 for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 913 (+10044.44%)
Mutual labels:  sdk
Brfv4 mac examples
macOS C++ examples utilizing OpenCV for camera access and drawing the face tracking results.
Stars: ✭ 25 (+177.78%)
Mutual labels:  sdk
Android Sdk
Beaconstac ADVANCED SDK for Android devices
Stars: ✭ 18 (+100%)
Mutual labels:  sdk
Newbe.mahua.framework
本SDK为实现QQ机器人平台的大一统,支持多种机器人平台:酷Q、MyPCQQ、QQLight等
Stars: ✭ 849 (+9333.33%)
Mutual labels:  sdk
Centrifuge
Cross-platform runtime mod loader and API for any Unity-based game. Supports Unity 5 and up!
Stars: ✭ 18 (+100%)
Mutual labels:  sdk
Pagarme Laravel
Pagar.me SDK for Laravel applications.
Stars: ✭ 23 (+155.56%)
Mutual labels:  sdk
Node Sdk
An SDK implementation in JS (Node) for the v3 REST APIs.
Stars: ✭ 9 (+0%)
Mutual labels:  sdk
Kudo
Kubernetes Universal Declarative Operator (KUDO)
Stars: ✭ 849 (+9333.33%)
Mutual labels:  sdk
Pyintelowl
Robust Python SDK and Command Line Client for interacting with IntelOwl's API.
Stars: ✭ 26 (+188.89%)
Mutual labels:  sdk

t1-node

Codacy Badge Build Status FOSSA Status

Node implementation of a T1 API Library. Uses Bluebird for fast, simple callback handling via promises.

Compilation/Installation

From npm

npm install @mediamath/terminalone

From source

Checkout, then npm install .

Usage

T1 Node uses dotenv for easy management of environment variables. Copy .env.template to .env and fill in your details.

To get an API key, see https://apidocs.mediamath.com

Cookie Authentication (default):

Required Env variables: T1_API_USERNAME T1_API_PASSWORD T1_API_KEY

var t1 = require('@mediamath/terminalone');
var config = {
  preferCookieAuth: true,
  user: process.env.T1_API_USERNAME,
  password: process.env.T1_API_PASSWORD,
  api_key: process.env.T1_API_KEY
  };
var connection = new t1.T1Connection(config);

OAuth2 (Password - Resource Owner flow):

T1 Node is designed to be used for scripts. If you wish to make a UI for 3rd parties, we recommend use use the Application Code flow, which may require a little more engineering than what's covered here. Note: As of 2017-06-29 OAuth2 is not available everywhere within the MediaMath environment. Until then, for production, we recommend using the Cookie flow. This message will be updated with more services as the rollout completes.

t1conf = {
    preferCookieAuth: false,
    user: process.env.T1_API_USERNAME,
    password: process.env.T1_API_PASSWORD,
    client_id: process.env.T1_CLIENT_ID,
    client_secret: process.env.T1_CLIENT_SECRET,
};
var connection = new t1.T1Connection(config);

Single Entities

Retrieve, edit and save a single entity

var agencyPromise = new t1.Entity('agency')
  .get(1234, connection)
  .then(function(agency) {
    agency = agency;
    agency.name = 'new name';
    return agency.save(connection)
    })
    .then(function () {
      console.log('saved')})
    .catch(error => console.log(error));
Entity Lists

Returns a generator to entities

var userParams = {
  'page_limit':10
  };
var that = this;
t1.EntityList.get('campaigns', connection,  userParams)
.then(function(list) {
  that.pg1 = list;
  return t1.EntityList.getNextPage(pg1, connection)
  })
    .then(function(list) {
    that.pg2 = list;
    for (var entity of list.entities) {console.log(entity)}});
  
Related entities

It's possible to include related entities by including in a 'with' property in userParams.

var userParams = {
  'page_limit':10,
  'with':['strategies']
  };
var that = this;
t1.EntityList.get('campaigns', connection,  userParams).then(function(list) {
  that.pg1 = list;
  for (var entity of list.entities) {console.log(entity)}});

Targeting

Strategy Target Segments

To get a strategy's targeting segments:

var targetingSegmentsPromise = new t1.StrategyTargetSegments()
  .get(strategyId, connection)
  .then(function(targetingSegments) {this.targetingSegments = targetingSegments});

To edit strategy targeting segments:

targetingSegments.include = [[1, 'OR']];
targetingSegments.exclude = [[119, 'OR']];
targetingSegments.include_op = 'OR';
targetingSegments.exclude_op = 'OR';
targetingSegments.save(connection).then(function () { console.log('saved') });
Strategy Target Dimensions/Values

To get a strategy's targeting values:

var targetValuesPromise = new t1.StrategyTargetValues()
  .get(strategyId, connection)
  .then(function(targetValues) {this.targetValues = targetValues});

To edit strategy targeting segments:

targetValues.include = [[1, 'OR']];
targetValues.addTargetValues('REGN', 'INCLUDE', 'OR', [23, 251]);
targetValues.save(connection).then(function () { console.log('saved') });
Strategy Audience Segments

To get a strategy's audience segments:

var audienceSegmentsPromise = new t1.StrategyAudienceegments()
  .get(strategyId, connection)
  .then(function(audienceSegments) {this.targetingSegments = targetingSegments});

To edit strategy audience segments:

audienceSegments.include = [1405158];
audienceSegments.exclude = [1405158];
targetingSegments.include_op = 'OR';
targetingSegments.exclude_op = 'OR';
targetingSegments.save(connection).then(function () { console.log('saved') });

Basic Reporting

To get a list of all reports provided by the MediaMath Reports API:

var metaReport = new t1.Report('meta');
metaReport.getMeta(conn).then(
    function(report) {
        console.log(report)
    },
    function(error) {
        console.log(error.message)
    });

To get a report with parameters:

var performanceReport = new t1.Report('performance');
performanceReport.get(conn, {
    time_window: 'yesterday',
    time_rollup: 'by_day',
    dimensions: 'advertiser_id',
    filter: 'organization_id=???'
}).then(
    function(report) {
        console.log(report)
    },
    function(error) {
        console.log(error.message)
    });

To get a report's metadata, which specifies fields and parameters:

performanceReport.getMeta(conn).then(
    function(report) {
        console.log(report)
    },
    function(error) {
        console.log(error.message)
    });

Tests

npm test will run local tests.

To run integration tests, copy .env.template to .env and fill in the required values.

npm run integration will run integration tests with Mocha.

FAQ

The EntityList I requested has an empty entities object but the metadata has a nonzero count! What gives?

t1-node returns an ES6 generator for the entities property, which looks like an empty object if you inspect it in the node REPL. You can iterate over it using for (let ... of), or simply call entities.next().value to get each entity. Check out the Mozilla documentation for more information on iterators and generators.

There's a feature that isn't supported yet! Can you add it?

Yep! Please check the open issues to see if this is already a known problem or request. If it is, we'd love to hear your comments and ideas on how best to approach it. If not, please create an issue. Alternatively, consider contributing to the project!

I want to contribute! Is that OK?

Yes! PRs are more than welcome. Please review the contributing guidelines on how best to go about this.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].