Giter Site home page Giter Site logo

twitter-ads's Introduction

Twitter Ads API

Build Status Dependency Status NPM version

NPM stats

A simple wrapper for Twitter Ads & TON API in NodeJS.

Installation

$ npm install twitter-ads

Usage

var TwitterAdsAPI = require('twitter-ads');
var T = new TwitterAdsAPI({
  consumer_key: 'XXX',
  consumer_secret: 'XXX',
  access_token: 'XXX',
  access_token_secret: 'XXX',
  sandbox: false, // defaults to true
  api_version: '2' //defaults to 2
});

T.get('accounts/:account_id', {account_id: 'XXX'}, function(error, resp, body) {
  if (error) return console.error(error);
  console.log(body);
  /* If everything goes okay,
  you should get something similar to this:
  
    {
      data: {
        approval_status: "ACCEPTED",
        created_at: "2014-07-14T22:51:48Z",
        deleted: false,
        id: "hkkd",
        name: "Some person named Emma",
        salt: "973fef8gce1c5d5f6bba4b91827c214a",
        timezone: "America/Los_Angeles",
        timezone_switch_at: "2014-07-27T07:00:00Z",
        updated_at: "2014-08-27T21:59:56Z"
      },
      data_type: "account",
      request: {
        params: {
          account_id: "hkkd"
        }
      }
    }  
  */
  
});

/* Use T.get, T.post, T.put and T.delete
   refer to Twitter API docs for the details on call parameters. */

Twitter TON API

T.tonUpload({
    file: './test.txt',
    content_type: 'text/plain',
    bucket_name: 'ta_partner'
  },
  function(error, location) {
    if (error) return console.error(error);
    console.log(location);
    /* If everything goes okay,
    you should get something similar to this:
      https://ton.twitter.com/1.1/ton/bucket/ta_partner/2892314386/n3UPAcC02roTP6C
    */
});

T.tonDownload({
    file: './test.txt',
    url: 'https://ton.twitter.com/1.1/ton/bucket/ta_partner/2892314386/n3UPAcC02roTP6C'
  },
  function(error, size) {
    if (error) return console.error(error);
    console.log(size);
    /* If everything goes okay,
    you should get something similar to this:
      204923
    */
});

Additional Configurables

  • sandbox (Boolean) - (Default: true) - Uses sandbox API host.
  • api_version (String) - (Default: 2) - Ads API version to use.

twitter-ads's People

Contributors

talha-asad avatar

Watchers

James Cloos avatar Takuma Nishino avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.