tap-pepperjam
This is a Singer tap that produces JSON-formatted data following the Singer spec.
This tap:
-
Pulls raw data from the Pepperjam Advertiser API
-
Extracts the following resources:
- Creative Endpoints:
- group
- itemized_list
- publisher
- term
- Report Endpoints
-
Outputs the schema for each resource
-
Incrementally pulls data based on the input state
Streams
Standard Endpoints:
creative_advanced
- Endpoint: creative/advanced
- Primary key fields: id
- Replication strategy: INCREMENTAL (results filtered)
- Bookmark: modified (date-time)
- Transformations: none
- Endpoint: creative/banner
- Primary key fields: id
- Replication strategy: INCREMENTAL (results filtered)
- Bookmark: modified (date-time)
- Transformations: none
- Endpoint: creative/coupon
- Primary key fields: id
- Replication strategy: INCREMENTAL (results filtered)
- Bookmark: modified (date-time)
- Transformations: none
- Endpoint: creative/generic
- Primary key fields: type
- Replication strategy: INCREMENTAL (results filtered)
- Bookmark: modified (date-time)
- Transformations: none
- Endpoint: creative/product
- Primary key fields: type
- Replication strategy: FULL_TABLE
- Transformations: none
- Endpoint: creative/promotion
- Primary key fields: id
- Replication strategy: FULL_TABLE
- Transformations: none
- Endpoint: creative/text
- Primary key fields: id
- Replication strategy: INCREMENTAL (results filtered)
- Bookmark: modified (date-time)
- Transformations: none
- Endpoint: group
- Primary key fields: id
- Replication strategy: FULL_TABLE
- Transformations: none
- Endpoint: group/member
- Primary key fields: id
- Replication strategy: FULL_TABLE for each groupId
- Transformations: Add parent group_id
- Endpoint: itemized-list
- Primary key fields: id
- Replication strategy: FULL_TABLE
- Transformations: none
- Endpoint: itemized-list/product
- Primary key fields: id
- Replication strategy: FULL_TABLE for each listId
- Transformations: none
- Endpoint: publisher
- Primary key fields: id
- Replication strategy: FULL_TABLE for status = joined
- Transformations: none
- Endpoint: itemized-list
- Primary key fields: id
- Replication strategy: FULL_TABLE
- Transformations: none
- Endpoint: term
- Primary key fields: id
- Replication strategy: FULL_TABLE
- Transformations: none
Report Endpoints
- Endpoint: report/creative-details-publisher
- Primary key fields: creative_id, creative_type, date
- Group by: date
- Replication strategy: INCREMENTAL (query filtered)
- Bookmark query fields: startDate, endDate
- Bookmark: datetime (date-time)
- Transformations: none
creative_performance_by_publisher
- Endpoint: report/creative-details-publisher
- Primary key fields: creative_id, creative_type, publisher_id, date
- Group by: publisher_date
- Replication strategy: INCREMENTAL (query filtered)
- Bookmark query fields: startDate, endDate
- Bookmark: datetime (date-time)
- Transformations: none
- Endpoint: report/demand-details
- Primary key fields: publisher_id, order_id, sale_date
- Group by: publisher_date
- Replication strategy: INCREMENTAL (query filtered)
- Bookmark query fields: startDate, endDate
- Bookmark: sale_date (date-time)
- Transformations: none
- Endpoint: report/transaction-details
- Primary key fields: transaction_id
- Replication strategy: INCREMENTAL (query filtered)
- Bookmark query fields: startDate, endDate
- Bookmark: sale_date (date-time)
- Transformations: none
- Endpoint: report/transaction-history
- Primary key fields: transaction_id, item_id, revision
- Replication strategy: INCREMENTAL (query filtered)
- Bookmark query fields: startDate, endDate
- Bookmark: sale_date (date-time)
- Transformations: none
Authentication
Generate Advertiser API Key: The API requires an API Key for Pepperjam to authenticate you as a user. This key is required as a query parameter for all API requests. Login to Pepperjam’s Ascend Console UI. Navigate to https://ascend.pepperjam.com/merchant/api/. Select Generate New Key.
Quick Start
-
Install
Clone this repository, and then install using setup.py. We recommend using a virtualenv:
> virtualenv -p python3 venv > source venv/bin/activate > python setup.py install OR > cd .../tap-pepperjam > pip install .
-
Dependent libraries The following dependent libraries were installed.
> pip install singer-python > pip install singer-tools > pip install target-stitch > pip install target-json
-
Create your tap's
config.json
file. Theapi_key
is available in the Pepperjam Console UI (see Authentication above). Thedate_window_days
is the integer number of days (between the from and to dates) for date-windowing through the date-filtered endpoints (default = 30). Thelock_period_days
is the latency look-back period for reports/performance endpoints. Thestart_date
is the absolute beginning date from which incremental loading on the initial load will start.{ "api_key": "YOUR_API_KEY", "date_window_days": "30", "lock_period_days": "60", "start_date": "2019-01-01T00:00:00Z", "user_agent": "tap-pepperjam <api_user_email@your_company.com>", }
Optionally, also create a
state.json
file.currently_syncing
is an optional attribute used for identifying the last object to be synced in case the job is interrupted mid-stream. The next run would begin where the last job left off.{ "currently_syncing": "registers", "bookmarks": { "transaction_details": "2020-03-23T10:31:14.000000Z", "creative_performance_by_publisher": "2020-03-23T00:00:00.000000Z", "transaction_history": "2020-03-23T10:31:14.000000Z", "creative_performance": "2020-03-23T00:00:00.000000Z", "publisher_performance": "2020-03-23T00:00:00.000000Z" } }
-
Run the Tap in Discovery Mode This creates a catalog.json for selecting objects/fields to integrate:
tap-pepperjam --config config.json --discover > catalog.json
See the Singer docs on discovery mode here.
-
Run the Tap in Sync Mode (with catalog) and write out to state file
For Sync mode:
> tap-pepperjam --config tap_config.json --catalog catalog.json > state.json > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
To load to json files to verify outputs:
> tap-pepperjam --config tap_config.json --catalog catalog.json | target-json > state.json > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
To pseudo-load to Stitch Import API with dry run:
> tap-pepperjam --config tap_config.json --catalog catalog.json | target-stitch --config target_config.json --dry-run > state.json > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
-
Test the Tap
While developing the pepperjam tap, the following utilities were run in accordance with Singer.io best practices: Pylint to improve code quality:
> pylint tap_pepperjam -d missing-docstring -d logging-format-interpolation -d too-many-locals -d too-many-arguments
Pylint test resulted in the following score:
Your code has been rated at 9.70/10
To check the tap and verify working:
> tap-pepperjam --config tap_config.json --catalog catalog.json | singer-check-tap > state.json > tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
Check tap resulted in the following:
The output is valid. It contained 62636 messages for 18 streams. 18 schema messages 62505 record messages 62 state messages Details by stream: +-----------------------------------+---------+---------+ | stream | records | schemas | +-----------------------------------+---------+---------+ | creative_generic | 1 | 1 | | itemized_list_product | 2 | 1 | | group | 19 | 1 | | creative_advanced | 6 | 1 | | creative_coupon | 24 | 1 | | creative_text | 46 | 1 | | term | 171 | 1 | | publisher_performance | 2786 | 1 | | creative_product | 2 | 1 | | publisher | 63 | 1 | | creative_banner | 24 | 1 | | creative_performance_by_publisher | 5962 | 1 | | transaction_history | 23654 | 1 | | creative_performance | 5962 | 1 | | transaction_details | 23654 | 1 | | itemized_list | 34 | 1 | | group_member | 67 | 1 | | creative_promotion | 28 | 1 | +-----------------------------------+---------+---------+
Copyright © 2020 Stitch