Skip to main content

AltDG API Python Tools

Command-line tool with methods to consume the AltDG 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:

# install as usual python package
pip install altdg

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

# ... or if you want to get samples for testing, clone the repo
git clone https://github.com/altdg/bulk_mapper.git altdg
pip install -e altdg

Now everything is ready to run the tool.

Authorization

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

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:

altdg --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):

altdg -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

altdg -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

altdg -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 AltDG 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"

Usage as library

You may use AltdgAPI class from your python program:

from altdg.api import AltdgAPI

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

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

# single query with hint
print(mapper.query('abc.com', hint='news'))

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

# bulk query with same hint for all inputs
print(mapper.bulk_query(['yahoo.com', 'amazon.com'], hint='company'))

# bulk query with overwriting hint
print(mapper.bulk_query([
    ('purple mint', 'restaurant'),  # (input, hint) tuple
    'amazon',  # just input with base hint
], hint='company'))  # base hint

Support

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

Metadata

Release files for altdg 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for altdg 1.0.5
File Size Uploaded Provenance
altdg-1.0.5.tar.gz 11.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for altdg 1.0.5
File Interpreter ABI Platform
altdg-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 20.6 kB

Release files / altdg-1.0.5.tar.gz

Download URL altdg-1.0.5.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f055389d82f7f07b2e1650c935f9f11b251e40efe74c64266ad1cc63f055a505
BLAKE2b-256 checksum
How to use checksums
996fb907c6bd3e1b1f9dc79b6d0957ee855610ae68f9f021dd9efa000403a594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.5

Release files / altdg-1.0.5-py3-none-any.whl

Download URL altdg-1.0.5-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18ba970c84d4dc48df012f1725619b16918e716e7305bba271b4b91f7da9b825
BLAKE2b-256 checksum
How to use checksums
1faebd127d6d54e5196ab04eef402f770de85a9613f0a8fbc73cb7deaa61e419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.5

Security for altdg 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page