Skip to main content

crma-api-client

License

CRM Analytics REST API Client

Features:

  • Execute SAQL queries
  • List dataset versions

Table of Contents:

Installation

crma-api-client requires Python 3.9 or above.

pip install crma-api-client
# or
poetry add crma-api-client

Guide

First, you need to create a new client instance. To do that, you either need to have credentials for an OAuth app or an existing access token handy:

from crma_api_client.client import ConnectionInfo, CRMAAPIClient

# Generate connection info if you don't already have an access token
conn = await ConnectionInfo.generate(
    client_id="abc123",
    client_secret="***",
    username="me@salesforce.com",
    password="***"
)

# If you already have an instance URL and access token, you can instantiate directly
conn = ConnectionInfo(instance_url="https://company.my.salesforce.com", access_token="XYZ123")

# Create the client, passing in the connection object
client = CRMAAPIClient(conn)

Next, you can use methods on the client to make requests:

response = await client.list_dataset_versions("Sample_Superstore_xls_Orders")
version = response.versions[0]
query = "\n".join(
    [
        f"""q = load "{version.dataset.id}/{version.id}";""",
        """q = group q by 'Category';""",
        """q = foreach q generate q.'Category' as 'Category', sum(q.'Sales') as 'Sales';""",
        """q = order q by 'Category' asc;""",
    ]
)
response = await client.query(query)
assert response.results.records == [
    {"Category": "Furniture", "Sales": 741999.7953},
    {"Category": "Office Supplies", "Sales": 719047.032},
    {"Category": "Technology", "Sales": 836154.033},
]

Development

To develop crma-api-client, install dependencies and enable the pre-commit hook:

pip install pre-commit poetry
poetry install
pre-commit install -t pre-commit -t pre-push

To run tests:

poetry run pytest

Metadata

Release files for crma-api-client 0.9.0

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

Source distribution (sdist)

Source distribution for crma-api-client 0.9.0
File Size Uploaded Provenance
crma-api-client-0.9.0.tar.gz 9.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for crma-api-client 0.9.0
File Interpreter ABI Platform
crma_api_client-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.9 kB

Release files / crma-api-client-0.9.0.tar.gz

Download URL crma-api-client-0.9.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d8bc273914f7327607554f7bbe5b76a959a0a324fa448dd390258599af54809c
BLAKE2b-256 checksum
How to use checksums
4a27928c87aa0212d667da8b66e7b42a3d15e8e14d51946adda0b926b2638c86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.13 Linux/5.13.0-1023-aws

Release files / crma_api_client-0.9.0-py3-none-any.whl

Download URL crma_api_client-0.9.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
223201d6c952f3fa71dfa7ca3a84c90c286cdfb7aba5dc7839a5008b5cfcf4df
BLAKE2b-256 checksum
How to use checksums
0cf72a36598fd306d74f7ba812f74124c01e5bfaa615d9fd47b6f51b51c27bde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.13 Linux/5.13.0-1023-aws

Security for crma-api-client 0.9.0

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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