Skip to content

Commit

Permalink
PINDP-3072: update doc links
Browse files Browse the repository at this point in the history
  • Loading branch information
David Chaiken committed Jul 24, 2024
1 parent df64eaa commit 9b5c543
Show file tree
Hide file tree
Showing 33 changed files with 112 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This quickstart used to support Pinterest API version v3 and v4, but that code h

1. Set up the environment with your credentials (app ID and secret). This configuration works with the code in all of the language-specific directories.

* Get an application ID and secret by hitting the "Connect app" button at the [apps dashboard](https://developers.pinterest.com/apps/). You may first need to follow the steps required to [request trial access](https://developers.pinterest.com/docs/getting-started/getting-access/) to the Pinterest API. You can also find step-by-step instructions on the [Glitch-based tutorial](https://pinterest-oauth-tutorial.glitch.me/).
* Get an application ID and secret by hitting the "Connect app" button at the [apps dashboard](https://developers.pinterest.com/apps/). You may first need to follow the steps required to [request trial access](https://developers.pinterest.com/docs/getting-started/connect-app/) to the Pinterest API. You can also find step-by-step instructions on the [Glitch-based tutorial](https://pinterest-oauth-tutorial.glitch.me/).
* Once your app is connected, hit the Manage button for the app on the [apps dashboard](https://developers.pinterest.com/apps/) to see your App id and App secret key. (Click the Show key button to see the App secret key.)
* Put your App ID and App secret key in an environment script file.
```
Expand Down
2 changes: 2 additions & 0 deletions nodejs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ lint-fix:

# Run this command after changing the help text for a script,
# so that the usage.md file is updated.
# Note: The line length of the resulting README file depends
# on the width of the terminal used to run this command.
help-doc:
../common/scripts/help_doc_generator ./README.md
16 changes: 8 additions & 8 deletions nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Below you will find a description of each script along with an example of its he


### [get_access_token.js](./scripts/get_access_token.js)
Quick start code that demonstrates the OAuth 2.0 flow and tests the authentication by reading the user profile using the `/v5/user_account` [endpoint](https://developers.pinterest.com/docs/api/v5/#tag/user_account). Running this script with the `-w` parameter (`./scripts/get_access_token.js -w`) stores the access token in `../common/oauth_tokens/access_token.json` for future use. Use `-w` parameter in combination with the `-a` (access token name) parameter to store separate access tokens for different purposes. When requesting an access token without specifying scopes, the script will default to `user_accounts:read` `pins:read` and `boards:read`. To see a complete list of scopes, refer to the Enums in [`./src/oauth_scope.js`](./src/oauth_scope.js). You can also run `./scripts/get_access_token.js -s help` to see the scopes.
Quick start code that demonstrates the OAuth 2.0 flow and tests the authentication by reading the user profile using the `/v5/user_account` [endpoint](https://developers.pinterest.com/docs/api/v5/user_account-get/). Running this script with the `-w` parameter (`./scripts/get_access_token.js -w`) stores the access token in `../common/oauth_tokens/access_token.json` for future use. Use `-w` parameter in combination with the `-a` (access token name) parameter to store separate access tokens for different purposes. When requesting an access token without specifying scopes, the script will default to `user_accounts:read` `pins:read` and `boards:read`. To see a complete list of scopes, refer to the Enums in [`./src/oauth_scope.js`](./src/oauth_scope.js). You can also run `./scripts/get_access_token.js -s help` to see the scopes.

<!--gen-->
```
Expand All @@ -69,7 +69,7 @@ optional arguments:
-s SCOPES, --scopes SCOPES
comma separated list of scopes or "help"
-c, --client_credentials
use client credentials
access the application user account
-a ACCESS_TOKEN, --access-token ACCESS_TOKEN
access token name
-l LOG_LEVEL, --log-level LOG_LEVEL
Expand Down Expand Up @@ -147,7 +147,7 @@ optional arguments:
```

### [get_pin.js](./scripts/get_pin.js)
Retrieves the information for a specific board with the `/v5/pins/{pin_id}` [endpoint](https://developers.pinterest.com/docs/api/v5/#operation/pins/get).
Retrieves the information for a specific board with the `/v5/pins/{pin_id}` [endpoint](https://developers.pinterest.com/docs/api/v5/pins-get/).

<!--gen-->
```
Expand All @@ -168,7 +168,7 @@ optional arguments:
```

### [get_board.js](./scripts/get_board.js)
Retrieves the information for a specific board with the `/v5/boards/{board_id}` [endpoint](https://developers.pinterest.com/docs/api/v5/#operation/boards/get).
Retrieves the information for a specific board with the `/v5/boards/{board_id}` [endpoint](https://developers.pinterest.com/docs/api/v5/boards-get/).

<!--gen-->
```
Expand Down Expand Up @@ -211,7 +211,7 @@ optional arguments:
```

### [get_user_boards.js](./scripts/get_user_boards.js)
Retrieves all of the boards for a user with the `/v5/boards` [endpoint](https://developers.pinterest.com/docs/api/v5/#operation/boards/list), using the paging mechanism of the API.
Retrieves all of the boards for a user with the `/v5/boards` [endpoint](https://developers.pinterest.com/docs/api/v5/boards-list/), using the paging mechanism of the API.

<!--gen-->
```
Expand Down Expand Up @@ -239,7 +239,7 @@ optional arguments:
```

### [copy_pin.js](./scripts/copy_pin.js)
Demonstration of how to use the `POST /v5/pins` [endpoint](https://developers.pinterest.com/docs/api/v5/#operation/pins/create) to create a pin. Copying a pin can be useful functionality for API developers, but does not represent typical user behavior on Pinterest. Note that `copy_pin.js` can create a video pin from an image pin by suppling the `-m/--media` argument, which is either a Pinterest media identifier (a number) or the path name of a file that contains a video.
Demonstration of how to use the `POST /v5/pins` [endpoint](https://developers.pinterest.com/docs/api/v5/pins-create/) to create a pin. Copying a pin can be useful functionality for API developers, but does not represent typical user behavior on Pinterest. Note that `copy_pin.py` can create a video pin from an image pin by suppling the `-m/--media` argument, which is either a Pinterest media identifier (a number) or the path name of a file that contains a video.

<!--gen-->
```
Expand Down Expand Up @@ -267,7 +267,7 @@ optional arguments:
```

### [copy_board.js](./scripts/copy_board.js)
Demonstration of how to use the `POST /v5/boards` [endpoint](https://developers.pinterest.com/docs/api/v5/#operation/boards/create) to create a board. Also uses the `POST /boards/{board_id}/sections` [endpoint](https://developers.pinterest.com/docs/api/v5/#operation/board_sections/create) to create board sections. This script accepts source and target access tokens, so that a board can be copied from one account to another. It also provides an `--all` option that copies all of the boards and pins from a source account into a target account. Copying one or multiple boards can be useful functionality for API developers, but does not represent typical user behavior on Pinterest.
Demonstration of how to use the `POST /v5/boards` [endpoint](https://developers.pinterest.com/docs/api/v5/boards-create/) to create a board. Also uses the `POST /boards/{board_id}/sections` [endpoint](https://developers.pinterest.com/docs/api/v5/board_sections-create/) to create board sections. This script accepts source and target access tokens, so that a board can be copied from one account to another. It also provides an `--all` option that copies all of the boards and pins from a source account into a target account. Copying one or multiple boards can be useful functionality for API developers, but does not represent typical user behavior on Pinterest.

<!--gen-->
```
Expand Down Expand Up @@ -360,7 +360,7 @@ optional arguments:
```

### [analytics_api_example.js](./scripts/analytics_api_example.js)
Demonstrates how to use the API to generate an asynchronous delivery metrics report using the [create](https://developers.pinterest.com/docs/api/v5/#operation/analytics/create_report) and [get](https://developers.pinterest.com/docs/api/v5/#operation/analytics/get_report) endpoints.
Demonstrates how to use the API to generate an asynchronous delivery metrics report using the [create](https://developers.pinterest.com/docs/api/v5/analytics-create_report/) and [get](https://developers.pinterest.com/docs/api/v5/analytics-get_report/) endpoints.

<!--gen-->
```
Expand Down
12 changes: 6 additions & 6 deletions nodejs/scripts/analytics_api_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { User } from '../src/user.js';
* from a Pinterest Solutions Engineer that has been useful to advertiser and
* partner engineers who need to fetch a wide range of metrics.
* The documentation for this API is here:
* https://developers.pinterest.com/docs/redoc/combined_reporting/#tag/reports
* https://developers.pinterest.com/docs/api-features/analytics-overview/
*
* Synchronous metrics retrieval is demonstrated by the get_analytics script
* in this directory.
Expand Down Expand Up @@ -78,9 +78,9 @@ async function main(argv) {
// We often recommend that they set up a new 'developer' Pinterest user,
// and then request that this new account is granted access to the
// advertiser account via:
// https://help.pinterest.com/en/business/article/add-people-to-your-ad-account
// This process is also touched on in the API docs:
// https://developers.pinterest.com/docs/redoc/combined_reporting/#tag/Account-Sharing
// https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts
// This process is also described in the Developer Platform documentation:
// https://developers.pinterest.com/docs/getting-started/using-business-access/

const advertisers = new Advertisers(user_id, api_config, access_token);
const iterator = await advertisers.get();
Expand Down Expand Up @@ -110,7 +110,7 @@ async function main(argv) {
// and clicks my ads got in the last 30 days.

// Step 3: Learn more about the metrics available
// https://developers.pinterest.com/docs/api/v5/#operation/delivery_metrics/get
// https://developers.pinterest.com/docs/api/v5/delivery_metrics-get/

// the output of delivery_metrics.get() is too long to be printed
const verbosity = api_config.verbosity;
Expand All @@ -136,7 +136,7 @@ async function main(argv) {

// Step 4: Configure the options for the report
// For documentation on async reports, see:
// https://developers.pinterest.com/docs/redoc/combined_reporting/#tag/reports
// https://developers.pinterest.com/docs/api/v5/analytics-create_report
console.log(`Requesting report for advertiser id ${advertiser_id}...`);

// Configure the report. Request 30 days of data, up to the current date.
Expand Down
6 changes: 3 additions & 3 deletions nodejs/scripts/get_ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ async function main(argv) {
// We often recommend that they set up a new "developer" Pinterest user,
// and then request that this new account is granted access to the
// advertiser account via:
// https://help.pinterest.com/en/business/article/add-people-to-your-ad-account
// This process is also touched on in the API docs:
// https://developers.pinterest.com/docs/redoc/combined_reporting/#tag/Account-Sharing
// https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts
// This process is also described in the Developer Platform documentation:
// https://developers.pinterest.com/docs/getting-started/using-business-access/
const advertisers = new Advertisers(
user_data.id, api_config, access_token);

Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/access_token.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class AccessToken extends ApiCommon {
/**
* Execute the OAuth 2.0 process for obtaining an access token.
* For more information, see IETF RFC 6749: https://tools.ietf.org/html/rfc6749
* and https://developers.pinterest.com/docs/api/v5/#tag/oauth
* and https://developers.pinterest.com/docs/getting-started/authentication-and-scopes/
*
* Constructor may not be async, so OAuth must be performed as a separate method.
*/
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/ad_metrics_async_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AsyncReport } from './async_report.js';
/**
* Specifies all of the attributes for the async advertiser
* metrics report. For more information, see:
* https://developers.pinterest.com/docs/api/v5/#operation/analytics/create_report
* https://developers.pinterest.com/docs/api/v5/analytics-create_report/
*
*
* The attribute functions are chainable. For example:
Expand Down
8 changes: 4 additions & 4 deletions nodejs/src/advertisers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class Advertisers extends ApiObject {
}

// Get the advertisers shared with the specified user_id.
// https://developers.pinterest.com/docs/api/v5/#operation/ad_accounts/list
// https://developers.pinterest.com/docs/api/v5/ad_accounts-list/
async get(query_parameters) {
return this.get_iterator('/v5/ad_accounts', query_parameters);
}
Expand Down Expand Up @@ -34,14 +34,14 @@ export class Advertisers extends ApiObject {
}

// Get the campaigns associated with an Ad Account.
// https://developers.pinterest.com/docs/api/v5/#operation/campaigns/list
// https://developers.pinterest.com/docs/api/v5/campaigns-list/
async get_campaigns(ad_account_id, query_parameters) {
return this.get_iterator(`/v5/ad_accounts/${ad_account_id}/campaigns`,
query_parameters);
}

// Get the ad groups associated with an Ad Account and Campaign.
// https://developers.pinterest.com/docs/api/v5/#operation/ad_groups/list
// https://developers.pinterest.com/docs/api/v5/ad_groups-list/
async get_ad_groups(ad_account_id, campaign_id, query_parameters) {
return this.get_iterator(
`/v5/ad_accounts/${ad_account_id}/ad_groups?campaign_ids=${campaign_id}`,
Expand All @@ -50,7 +50,7 @@ export class Advertisers extends ApiObject {
}

// Get the ads associated with an Ad Account, Campaign, and Ad Group.
// https://developers.pinterest.com/docs/api/v5/#operation/ads/list
// https://developers.pinterest.com/docs/api/v5/ads-list/
async get_ads(ad_account_id, campaign_id, ad_group_id, query_parameters) {
return this.get_iterator(`\
/v5/ad_accounts/${ad_account_id}/ads\
Expand Down
16 changes: 8 additions & 8 deletions nodejs/src/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ApiObject } from './api_object.js';
* to fetch the metrics.
*/
export class UserAnalytics extends AnalyticsAttributes {
// https://developers.pinterest.com/docs/api/v5/#operation/user_account/analytics
// https://developers.pinterest.com/docs/api/v5/user_account-analytics/
constructor(_user_id, api_config, access_token) {
super();
this.api_object = new ApiObject(api_config, access_token);
Expand Down Expand Up @@ -65,7 +65,7 @@ export class UserAnalytics extends AnalyticsAttributes {

// Get analytics for the user account. If ad_account_id is set, get user
// analytics associated with the specified Ad Account.
// https://developers.pinterest.com/docs/api/v5/#operation/user_account/analytics
// https://developers.pinterest.com/docs/api/v5/pins-analytics/
async get(ad_account_id) {
if (ad_account_id) {
this.attrs.ad_account_id = ad_account_id;
Expand Down Expand Up @@ -97,7 +97,7 @@ ${this.uri_attributes('metric_types', false)}`);
* to fetch the metrics.
*/
export class PinAnalytics extends AnalyticsAttributes {
// https://developers.pinterest.com/docs/api/v5/#operation/pins/analytics
// https://developers.pinterest.com/docs/api/v5/user_account-analytics/
constructor(pin_id, api_config, access_token) {
super();
this.pin_id = pin_id;
Expand Down Expand Up @@ -165,7 +165,7 @@ export class AdAnalytics extends AdAnalyticsAttributes {
this.api_object = new ApiObject(api_config, access_token);
this.required_attrs.add('granularity');
Object.assign(this.enumerated_values, {
// https://developers.pinterest.com/docs/api/v5/#operation/ad_account/analytics
// https://developers.pinterest.com/docs/api/v5/ad_account-analytics/
conversion_report_time: ['TIME_OF_AD_ACTION', 'TIME_OF_CONVERSION']
});
}
Expand All @@ -179,29 +179,29 @@ export class AdAnalytics extends AdAnalyticsAttributes {
}

// Get analytics for the ad account.
// https://developers.pinterest.com/docs/api/v5/#operation/ad_account/analytics
// https://developers.pinterest.com/docs/api/v5/ad_account-analytics/
async get_ad_account(ad_account_id) {
return await this.request(`/v5/ad_accounts/${ad_account_id}/analytics?`);
}

// Get analytics for the campaign.
// https://developers.pinterest.com/docs/api/v5/#operation/campaigns/analytics
// https://developers.pinterest.com/docs/api/v5/campaigns-analytics/
async get_campaign(ad_account_id, campaign_id) {
return await this.request(`\
/v5/ad_accounts/${ad_account_id}/campaigns/analytics\
?campaign_ids=${campaign_id}&`);
}

// Get analytics for the ad group.
// https://developers.pinterest.com/docs/api/v5/#operation/ad_groups/analytics
// https://developers.pinterest.com/docs/api/v5/ad_groups-analytics/
async get_ad_group(ad_account_id, _campaign_id, ad_group_id) {
return await this.request(`\
/v5/ad_accounts/${ad_account_id}/ad_groups/analytics\
?ad_group_ids=${ad_group_id}&`);
}

// Get analytics for the ad.
// https://developers.pinterest.com/docs/api/v5/#operation/ads/analytics
// https://developers.pinterest.com/docs/api/v5/ads-analytics/
async get_ad(ad_account_id, _campaign_id, _ad_group_id, ad_id) {
return await this.request(`\
/v5/ad_accounts/${ad_account_id}/ads/analytics\
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/api_media_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ApiMediaObject extends ApiObject {
* media_id => an existing media identifier
*
* Reference:
* https://developers.pinterest.com/docs/solutions/content-apps/#creatingvideopins
* https://developers.pinterest.com/docs/api-features/creating-boards-and-pins/#creating-video-pins
*/
async media_to_media_id(media) {
if (!media) {
Expand Down
2 changes: 1 addition & 1 deletion nodejs/src/async_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class AsyncReport extends ApiObject {
}

// For documentation, see:
// https://developers.pinterest.com/docs/api/v5/#operation/analytics/get_report
// https://developers.pinterest.com/docs/api/v5/analytics-get_report/
async request_report(post_data_attributes) {
this.token = (await this.post_data(this.path, post_data_attributes)).token;
return this.token; // so that tests can verify the token
Expand Down
Loading

0 comments on commit 9b5c543

Please sign in to comment.