Skip to main content

Utility libraries from Alternative Data Group

Project description

ADG API Python Tools

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

© Alternative Data Group. All rights reserved.

Contents

Requirements

Python 3.6+

See also requirements.txt

Installation

Run the following commands in your shell:

# you may install "altdg" package directly from repo
pip install git+https://github.com/altdg/bulk_mapper.git

# if you want to get samples for testing, clone the repo
git clone https://github.com/altdg/bulk_mapper.git adg
cd adg

Now everything is ready to run the tool.

Authorization

To use this tool you must have a valid app key to the ADG API. Methods are available depending on you account type with ADG.

Free tier key

Use this key to try the API for free: f816b9125492069f7f2e3b1cc60659f0

Sign up at https://developer.altdg.com/ to get a non-trial key.

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 display command's usage:

python -m altdg.api --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 altdg.api -e domain-mapper sample-domains.txt -k "f816b9125492069f7f2e3b1cc60659f0"

Sign up at https://developer.altdg.com/ to get a non-trial key.

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 altdg.api -e merchant-mapper sample-merchants.txt -k "f816b9125492069f7f2e3b1cc60659f0"

Sign up at https://developer.altdg.com/ to get a non-trial key.

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.

Product mapper

Maps strings from product related text (e.g. inventory) to structured company information.

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

python -m altdg.api -e product-mapper sample-products.txt -k "f816b9125492069f7f2e3b1cc60659f0"

Sign up at https://developer.altdg.com/ to get a non-trial key.

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

Command arguments (options)

Arguments:

  • -e <endpoint> --endpoint Type of mapper. Choices are "merchant-mapper", "domain-mapper" and "product-mapper".
  • -k <key> --key ADG API application key.
  • -o <filename> --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 --num-threads Number of requests to process in parallel. (See --help for max and default)
  • -r --num-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)
  • -th <hint> --type-hint Improves the accuracy by providing the industry name or any keyword hint relevant to the inputs. E.g. -th "medical"

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 AdgApi class from your python program:

from altdg.api import AdgApi

# initialize Mapper class with your key
mapper = AdgApi('domain-mapper', api_key='f816b9125492069f7f2e3b1cc60659f0')

# single query
print(mapper.query('abc.com'))

# bulk query
for result in mapper.bulk_query(['yahoo.com', 'amazon.com']):
    print(result)

Support

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

altdg-1.0.1-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page