1.1.0 • Published 2 years ago

pinterest-sdk v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

pinterest-sdk

PinterestSdk - JavaScript client for pinterest-sdk Pinterest's REST API This SDK is automatically generated by the OpenAPI Generator project:

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 pinterest-sdk --save

Finally, you need to build the module:

npm run build
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

To use the link you just defined in your project, switch to the directory you want to use your pinterest-sdk from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/cliffano/pinterest-sdk then install it via:

    npm install cliffano/pinterest-sdk --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.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

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

var PinterestSdk = require('pinterest-sdk');

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

var api = new PinterestSdk.AdAccountsApi()
var adAccountId = "adAccountId_example"; // {String} Unique identifier of an ad account.
var startDate = new Date("2013-10-20"); // {Date} Metric report start date (UTC). Format: YYYY-MM-DD
var endDate = new Date("2013-10-20"); // {Date} Metric report end date (UTC). Format: YYYY-MM-DD
var columns = ["SPEND_IN_DOLLAR"]; // {[String]} Columns to retrieve. **NOTE**: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD,($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency.<br/>For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound).<br/>If a column has no value, it may not be returned
var granularity = DAY; // {Granularity} Granularity
var opts = {
  'clickWindowDays': 1, // {Number} Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days.
  'engagementWindowDays': 30, // {Number} Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days.
  'viewWindowDays': 1, // {Number} Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day.
  'conversionReportTime': TIME_OF_AD_ACTION // {String} The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event.
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.adAccountAnalytics(adAccountId, startDate, endDate, columns, granularity, opts, callback);

Documentation for API Endpoints

All URIs are relative to https://api.pinterest.com/v5

ClassMethodHTTP requestDescription
PinterestSdk.AdAccountsApiadAccountAnalyticsGET /ad_accounts/{ad_account_id}/analyticsGet ad account analytics
PinterestSdk.AdAccountsApiadAccountsListGET /ad_accountsList ad accounts
PinterestSdk.AdAccountsApiadGroupsAnalyticsGET /ad_accounts/{ad_account_id}/ad_groups/analyticsGet ad group analytics
PinterestSdk.AdAccountsApiadGroupsListGET /ad_accounts/{ad_account_id}/ad_groupsList ad groups
PinterestSdk.AdAccountsApiadsAnalyticsGET /ad_accounts/{ad_account_id}/ads/analyticsGet ad analytics
PinterestSdk.AdAccountsApiadsListGET /ad_accounts/{ad_account_id}/adsList ads
PinterestSdk.AdAccountsApianalyticsCreateReportPOST /ad_accounts/{ad_account_id}/reportsCreate async request for an account analytics report
PinterestSdk.AdAccountsApianalyticsGetReportGET /ad_accounts/{ad_account_id}/reportsGet the account analytics report created by the async call
PinterestSdk.AdAccountsApicampaignsAnalyticsGET /ad_accounts/{ad_account_id}/campaigns/analyticsGet campaign analytics
PinterestSdk.AdAccountsApicampaignsListGET /ad_accounts/{ad_account_id}/campaignsList campaigns
PinterestSdk.AdAccountsApiproductGroupsAnalyticsGET /ad_accounts/{ad_account_id}/product_groups/analyticsGet product group analytics
PinterestSdk.BoardsApiboardSectionsCreatePOST /boards/{board_id}/sectionsCreate board section
PinterestSdk.BoardsApiboardSectionsDeleteDELETE /boards/{board_id}/sections/{section_id}Delete board section
PinterestSdk.BoardsApiboardSectionsListGET /boards/{board_id}/sectionsList board sections
PinterestSdk.BoardsApiboardSectionsListPinsGET /boards/{board_id}/sections/{section_id}/pinsList Pins on board section
PinterestSdk.BoardsApiboardSectionsUpdatePATCH /boards/{board_id}/sections/{section_id}Update board section
PinterestSdk.BoardsApiboardsCreatePOST /boardsCreate board
PinterestSdk.BoardsApiboardsDeleteDELETE /boards/{board_id}Delete board
PinterestSdk.BoardsApiboardsGetGET /boards/{board_id}Get board
PinterestSdk.BoardsApiboardsListGET /boardsList boards
PinterestSdk.BoardsApiboardsListPinsGET /boards/{board_id}/pinsList Pins on board
PinterestSdk.BoardsApiboardsUpdatePATCH /boards/{board_id}Update board
PinterestSdk.CatalogsApicatalogsProductGroupsCreatePOST /catalogs/product_groupsCreate product group
PinterestSdk.CatalogsApicatalogsProductGroupsDeleteDELETE /catalogs/product_groups/{product_group_id}Delete product group
PinterestSdk.CatalogsApicatalogsProductGroupsListGET /catalogs/product_groupsGet product groups list
PinterestSdk.CatalogsApicatalogsProductGroupsUpdatePATCH /catalogs/product_groups/{product_group_id}Update product group
PinterestSdk.CatalogsApifeedProcessingResultsListGET /catalogs/feeds/{feed_id}/processing_resultsList processing results for a given feed
PinterestSdk.CatalogsApifeedsCreatePOST /catalogs/feedsCreate feed
PinterestSdk.CatalogsApifeedsDeleteDELETE /catalogs/feeds/{feed_id}Delete feed
PinterestSdk.CatalogsApifeedsGetGET /catalogs/feeds/{feed_id}Get feed
PinterestSdk.CatalogsApifeedsListGET /catalogs/feedsList feeds
PinterestSdk.CatalogsApifeedsUpdatePATCH /catalogs/feeds/{feed_id}Update feed
PinterestSdk.CatalogsApiitemsBatchGetGET /catalogs/items/batch/{batch_id}Get catalogs items batch
PinterestSdk.CatalogsApiitemsBatchPostPOST /catalogs/items/batchPerform an operation on an item batch
PinterestSdk.CatalogsApiitemsGetGET /catalogs/itemsGet catalogs items
PinterestSdk.MediaApimediaCreatePOST /mediaRegister media upload
PinterestSdk.MediaApimediaGetGET /media/{media_id}Get media upload details
PinterestSdk.MediaApimediaListGET /mediaList media uploads
PinterestSdk.OauthApioauthTokenPOST /oauth/tokenGenerate OAuth access token
PinterestSdk.PinsApipinsAnalyticsGET /pins/{pin_id}/analyticsGet Pin analytics
PinterestSdk.PinsApipinsCreatePOST /pinsCreate Pin
PinterestSdk.PinsApipinsDeleteDELETE /pins/{pin_id}Delete Pin
PinterestSdk.PinsApipinsGetGET /pins/{pin_id}Get Pin
PinterestSdk.UserAccountApiuserAccountAnalyticsGET /user_account/analyticsGet user account analytics
PinterestSdk.UserAccountApiuserAccountGetGET /user_accountGet user account

Documentation for Models

Documentation for Authorization

basic

  • Type: HTTP basic authentication

pinterest_oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://www.pinterest.com/oauth/
  • Scopes:
    • ads:read: See all of your advertising data, including ads, ad groups, campaigns etc.
    • ads:write: Create, update, or delete ads, ad groups, campaigns etc.
    • boards:read: See your public boards, including group boards you join
    • boards:read_secret: See your secret boards
    • boards:write: Create, update, or delete your public boards
    • boards:write_secret: Create, update, or delete your secret boards
    • catalogs:read: See all of your catalogs data
    • catalogs:write: Create, update, or delete your catalogs data
    • pins:read: See your public Pins
    • pins:read_secret: See your secret Pins
    • pins:write: Create, update, or delete your public Pins
    • pins:write_secret: Create, update, or delete your secret Pins
    • user_accounts:read: See your user accounts