Skip to content
Altdg bulk mapping tool for the merchant and domain mapper API https://developer.altdg.com/
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
.gitignore
README.md
__init__.py
adg_api_bulkMapper.py
requirements.txt
sample-domains.txt
sample-merchants.txt
testcase.txt

README.md

ADG API Python Tools

Command-line tool with methods to consume the ADG API in bulk.

© Alternative Data Group. All rights reserved.

Version 1.0.0-beta

Contents

Requirements

Python 3.6+

See also requirements.txt

Installation

Run the following commands in your shell:

# clone the repo
git clone https://github.com/altdg/bulk_mapper

# create and activate a virtual environment
cd bulk_mapper
python -m venv env
source env/bin/activate

# install requirements
pip install -r requirements.txt

Now everything is ready to run the tool.

Authorization

To use this tool you must have a valid app key to the ADG API. Depending on you account with ADG, certain methods will be available:

Account type Merchant mapper Domain mapper
DOMAINS No Yes
MERCHANT Yes No
COMBINED Yes Yes
PII No No

Usage

A preferred way to run the tool is to load it as module with the python command.

Run the tool with --help flag to dispay command's usage:

python -m adg_api_bulkMapper --help

Domain mapper

Maps domain names from given text to structured company information.

More details in https://developer.altdg.com/docs#domain-mapper

This will run all the domains in the provided text file (one per line expected):

python -m adg_api_bulkMapper -e domains sample-domains.txt -k "12345"

12345 is your ADG API application key. Sign up in https://developer.altdg.com/ to get one!

A CSV output file will be created automatically with the same path as the input file but prepending the current date.

sample-domains.txt is a sample list of domains we included in our repo. This file is downloaded as part of this package, no need to re-create it.

Merchant mapper

Maps strings from transactional purchase text (e.g. credit card transactions) to structured company information.

More details in https://developer.altdg.com/docs#merchant-mapper

python -m adg_api_bulkMapper -e merchants sample-merchants.txt -k "12345"

12345 is your ADG API application key. Sign up in https://developer.altdg.com/ to get one!

A CSV output file will be created automatically with the same path as the input file but prepending the current date.

sample-merchants.txt is a sample list of domains we included in our repo. This file is downloaded as part of this package, no need to re-create it.

Command arguments (options)

Optional arguments:

  • -e --endpoint Type of mapper. Choices are merchants and domains.
  • -k --key ADG API application key.
  • -o --out Output file path. If not provided, the input file name is used with the ".csv" extension, prepended with the date and time.
  • -F --force When providing a specific out_file, some results may already exist in that file for an input. Use this option to force re-process results that are already in that output file, otherwise existing results won't be processed again. Previous results are NOT overwritten, a new CSV row is added.
  • -n --input_no Number of requests to process in parallel. (See --help for max and default)
  • -r --retires Number of retries per request. (See --help for max and default)
  • -t --timeout API request timeout (in seconds). (See --help for max and default)

Development

Having pip for your python3 environment, clone this repo, cd into its directory, and run:

pip install -r requirements.txt

Usage as library

You may use Mapper class from your python program:

# first, import adg_api_bulkMapper module
import adg_api_bulkMapper

# initialize Mapper class with your key
domain_mapper = adg_api_bulkMapper.Mapper(endpoint='domains', api_key='12345')

# query API
results = domain_mapper.query_api(['abc.com', 'yahoo.com', 'amazon.com'])

Support

Please email info@altdg.com if you need to contact us directly.

You can’t perform that action at this time.