Skip to main content

A Python package from the ds-protocol library collection

Project description

ds-protocol-http-py-lib

A Python package from the ds-common library collection.

Installation

Install the package using pip:

pip install ds-protocol-http-py-lib

Or using uv (recommended):

uv pip install ds-protocol-http-py-lib

Quick Start

from ds_protocol_http_py_lib import __version__

print(f"ds-protocol-http-py-lib version: {__version__}")

Usage

Read from a static URL

import uuid
from ds_protocol_http_py_lib.dataset.http import HttpDataset, HttpDatasetSettings
from ds_protocol_http_py_lib.enums import AuthType, HttpMethod
from ds_protocol_http_py_lib.linked_service import OAuth2AuthSettings
from ds_protocol_http_py_lib.linked_service.http import HttpLinkedService, HttpLinkedServiceSettings

linked_service = HttpLinkedService(
    id=uuid.uuid4(),
    name="my-linked-service",
    version="1.0.0",
    settings=HttpLinkedServiceSettings(
        host="https://api.example.com",
        auth_type=AuthType.OAUTH2,
        oauth2=OAuth2AuthSettings(
            token_endpoint="https://api.example.com/oauth/token",
            client_id="my-client",
            client_secret="******",
        ),
    ),
)

dataset = HttpDataset(
    id=uuid.uuid4(),
    name="my-dataset",
    version="1.0.0",
    linked_service=linked_service,
    settings=HttpDatasetSettings(
        method=HttpMethod.GET,
        url="https://api.example.com/data",
    ),
)

linked_service.connect()
dataset.read()
df = dataset.output

Read from a URL with path parameters

Use {param} placeholders in the URL and supply their values via path_params:

import uuid
from ds_protocol_http_py_lib.dataset.http import HttpDataset, HttpDatasetSettings
from ds_protocol_http_py_lib.enums import AuthType, HttpMethod
from ds_protocol_http_py_lib.linked_service import OAuth2AuthSettings
from ds_protocol_http_py_lib.linked_service.http import HttpLinkedService, HttpLinkedServiceSettings

linked_service = HttpLinkedService(
    id=uuid.uuid4(),
    name="my-linked-service",
    version="1.0.0",
    settings=HttpLinkedServiceSettings(
        host="https://api.example.com",
        auth_type=AuthType.OAUTH2,
        oauth2=OAuth2AuthSettings(
            token_endpoint="https://api.example.com/oauth/token",
            client_id="my-client",
            client_secret="******",
        ),
    ),
)

dataset = HttpDataset(
    id=uuid.uuid4(),
    name="my-dataset",
    version="1.0.0",
    linked_service=linked_service,
    settings=HttpDatasetSettings(
        method=HttpMethod.GET,
        url="https://api.example.com/documents/{document_guid}/original",
        path_params={"document_guid": "abc123"},
    ),
)

linked_service.connect()
dataset.read()
df = dataset.output
# Request is sent to: https://api.example.com/documents/abc123/original

Requirements

  • Python 3.11 or higher

Documentation

Full documentation is available at:

Development

To contribute or set up a development environment:

# Clone the repository
git clone https://github.com/grasp-labs/ds-protocol-http-py-lib.git
cd ds-protocol-http-py-lib

# Install development dependencies
uv sync --all-extras --dev

# Run tests
make test

See the README for more information.

License

This package is licensed under the Apache License 2.0. See the LICENSE-APACHE file for details.

Support

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

ds_protocol_http_py_lib-0.1.0b7.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

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

ds_protocol_http_py_lib-0.1.0b7-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file ds_protocol_http_py_lib-0.1.0b7.tar.gz.

File metadata

File hashes

Hashes for ds_protocol_http_py_lib-0.1.0b7.tar.gz
Algorithm Hash digest
SHA256 5d7aa88288a44fd263ff550571137ac44d90e24a37ea32415033cf21c515fb40
MD5 d346f6322d791d12617c716019dc45db
BLAKE2b-256 4fdd7471e05fdc58e8d79ff86e334cc002afb059d612fba906d23b83438ceab7

See more details on using hashes here.

File details

Details for the file ds_protocol_http_py_lib-0.1.0b7-py3-none-any.whl.

File metadata

File hashes

Hashes for ds_protocol_http_py_lib-0.1.0b7-py3-none-any.whl
Algorithm Hash digest
SHA256 5b2ee864260612e0fc896226a0be681179d1927fcbdfcdb296c4447d2b8050ff
MD5 e5fabc42e7c3fbb94280c7eca26dc932
BLAKE2b-256 ae3ba98f98a79740faa92533122552eb8ed35576f45adb6a5b51c9c94f0b6327

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