Skip to main content

Library for retrieving and uploading to database data from amocrm API

Project description

Amocrm custom library

  1. Retrieving data from amocrm amocrm.api (v2 and v4).
  2. Uploading data to database.

Supported databases:

  • clickhouse
  • vertica

Usage

pip3 install amocrm-talenttech-oss

Retrieving data from API:

import datetime
from api.api_loader_amocrm_v4 import AmocrmApiLoader as ApiLoaderV4


date_modified_from = datetime.datetime.now() - datetime.timedelta(days=1) #
args_api = {
                "amocrm_api_url": "https://<NAMESPACE>.amocrm.ru/amocrm.api/v4/<ENTITY>?page={page}&limit={limit}",
                "AUTH_URL":"https://<NAMESPACE>.amocrm.ru/oauth2/access_token",
                "CLIENT_SECRET":"xxxx",
                "CLIENT_ID": "xxx-xxx-xxxx-xxxx-xxxxxxx",
                "REDIRECT_URL":"https://xxxx/xx"
           }

args_s3 = {
                "aws_access_key_id": <S3_ACCESS_KEY>,
                "aws_secret_access_key":  <S3_ACCESS_SECRET>,
                "endpoint_url": <S3_ENDPOINT_URL>,
                "bucket": <S3_BUCKET>
          }



api_loader = ApiLoaderV4(
                entity=<ENTITY>,                # leads/tasks/companies or e.t.c
                s3_path=<S3_PATH>,              # this s3 folder should contain retrieved files
                s3_token_path=<S3_TOKEN_PATH>,  # directory for tokens
                args_s3=args_s3,
                args_api=args_api,
                date_modified_from=date_modified_from, #parameters is optional, if want load only updated records from date
                with_offset=True, 
                batch_api=500
            )

api_loader.auth(<CODE_AUTH>) #call it if you need to create or regenerate refresh token the first time
api_loader.extract()      

Uploading data to vertica:

from db.vertica_uploader import UploaderDB as VerticaUploaderDB
sql_credentials = {
                "database": <DATABASE>,
                "schema": <SCHEMA>
                "user": <VERTICA_WRITE_USER>,
                "host": <VERTICA_HOST>,
                "port": <VERTICA_PORT>,
                "password": <VERTICA_WRITE_PASSWORD>,
                "vertica_configs": <VERTICA_CONFIGS>,
            }

args_s3 = {
                "aws_access_key_id": <S3_ACCESS_KEY>,
                "aws_secret_access_key":  <S3_ACCESS_SECRET>,
                "endpoint_url": <S3_ENDPOINT_URL>,
                "bucket": <S3_BUCKET>
          }        

db_uploader = VerticaUploaderDB(
            args_s3=args_s3,
            s3_path=s3_path,
            sql_credentials=sql_credentials,
            entity=<ENTITY>,
            table_name=<TABLE_NAME>,
            json_columns=[<COLUM_JSON_1>, <COLUM_JSON_2>]
        )
db_uploader.load_s3_to_db()        

Project details


Download files

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

Source Distribution

amocrm-talenttech-oss-0.1.10.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

amocrm_talenttech_oss-0.1.10-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file amocrm-talenttech-oss-0.1.10.tar.gz.

File metadata

  • Download URL: amocrm-talenttech-oss-0.1.10.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.13

File hashes

Hashes for amocrm-talenttech-oss-0.1.10.tar.gz
Algorithm Hash digest
SHA256 a132b17191d0e7128c5b396fb3e84483b850d0379ba8504a93ac4ba0bdc86ea9
MD5 189eb4b7d99895da798d4d21b9d777c4
BLAKE2b-256 b0c74d2c7f9b26d960ba293a634b1895de793e21be7b305abb444f890e7c6bde

See more details on using hashes here.

File details

Details for the file amocrm_talenttech_oss-0.1.10-py3-none-any.whl.

File metadata

  • Download URL: amocrm_talenttech_oss-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.6.13

File hashes

Hashes for amocrm_talenttech_oss-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 52b10fc90b5706004b0d5419d0d17ce8f5a609abcf588b69626158e9a0f6090f
MD5 4d6cc9ccad86c349d538803d3166ac57
BLAKE2b-256 cb114cb468714b84024f34b6f80be34b7ee500e0241dfabf8b0e6dd9f3efa94d

See more details on using hashes here.

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