Skip to main content

A Python client for the Datascribe API

Project description

DataScribe API Client

License: GPL v3 Python Platforms

Test API Test CLI Test Filter

datascribe_api is a Python client for interacting with the DataScribe API. It allows users to search for data tables and their metadata, automating data retrieval and analysis workflows.

Report a Bug | Request a Feature


Features

  • Search and retrieve data tables and metadata from the DataScribe API
  • Simple Python interface for querying endpoints
  • Automatic model mapping for API responses
  • Context manager support for resource management

Installation

You can use pip to install the datascribe_api package directly from PyPI:

pip install datascribe_api

Quick Start

Python Client Usage

To get started with the datascribe_api, you can use the following example to retrieve and print the names of data tables available to the user:

from datascribe_api import DataScribeClient

with DataScribeClient(api_key="YOUR_API_TOKEN") as client:
    tables = client.get_data_tables_for_user()
    for table in tables:
        print(f"Table Name: {table.display_name}")

Make sure to replace the DataScribeClient initialization with your actual API key or store it in an environment variable named DATASCRIBE_API_TOKEN for authentication.

Filtering Data with the Filter Class

The datascribe_api package provides a powerful and expressive Filter class for building complex queries in a Pythonic way. Filters can be passed to API methods as dictionaries, single Filter objects, or lists of Filter objects (for AND logic).

Basic Usage

from datascribe_api import DataScribeClient
from datascribe_api.filter import Filter

with DataScribeClient(api_key="YOUR_API_TOKEN") as client:
    filters = Filter("age") > 30
    rows = client.get_data_table_rows(tableName="users", columns=["age", "name"], filters=filters)
    for row in rows:
        print(row)

Supported Filter Operations

  • Equality and Comparison

    Filter("age") == 25
    Filter("score") != 100
    Filter("height") > 170
    Filter("height") >= 180
    Filter("height") < 200
    Filter("height") <= 160
    
  • IN and NOT IN

    Filter("status").in_(["active", "pending"])
    Filter("role").not_in(["guest", "banned"])
    
  • LIKE and ILIKE (case-insensitive LIKE)

    Filter("name").like("%John%")
    Filter("email").ilike("%@gmail.com")
    
  • IS NULL and IS NOT NULL

    Filter("deleted_at").is_null()
    Filter("deleted_at").is_not_null()
    

Combining Multiple Filters (AND logic)

You can pass a list of filters to combine them with AND logic:

filters = [
    Filter("age") > 18,
    Filter("status") == "active",
    Filter("country").in_(["US", "CA"])
]
rows = client.get_data_table_rows(tableName="users", columns=["age", "status", "country"], filters=filters)

Passing Filters as Dictionaries

You can also pass filters as plain dictionaries if you prefer:

filters = {"column": "age", "operator": ">", "value": 21}
rows = client.get_data_table_rows(tableName="users", columns=["age"], filters=filters)

CLI Usage

You can also use the command-line interface to interact with the DataScribe API. Here are some examples:

# List all data tables for the authenticated user
datascribe_api data-tables-for-user

See the CLI documentation for more commands and options.


License

This project is licensed under the GNU GPLv3 License. See the LICENSE file for details.

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

datascribe_api-1.0.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datascribe_api-1.0.0-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file datascribe_api-1.0.0.tar.gz.

File metadata

  • Download URL: datascribe_api-1.0.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.16

File hashes

Hashes for datascribe_api-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eef7e982f66892d760a85b5be74e5ee784a86158e39638157215572a8b294ec0
MD5 2c4b2ef8a03d997fb444868dd80d12c2
BLAKE2b-256 59bd3cc3491e5ebc9b5f822c1642d362dcfb9b1f4aae717a15f5f0bdfe2d1d88

See more details on using hashes here.

File details

Details for the file datascribe_api-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for datascribe_api-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c44e83ff9a10fc563247c1ba32d5bce52e193b360a7bbb6cb532e5135deb839b
MD5 fbbb9cda5d8097abc6dc7a9d5b0a2467
BLAKE2b-256 b985bd44fc31868ae35eb69f04588de43afce003edd5fdcaf5d5db94922d5d92

See more details on using hashes here.

Supported by

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