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.0b5.tar.gz (22.1 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.0b5-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for ds_protocol_http_py_lib-0.1.0b5.tar.gz
Algorithm Hash digest
SHA256 91ce09a5575d240ae0265f6440728e5cfc9f00f50951cad7bb5294d5eb3f38c4
MD5 bbcfc7e3808ab24a744c425aacd57eab
BLAKE2b-256 df54ce37673d419fc5824bdb963f5bb16c1946b5c148c92d674834e34c894b48

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ds_protocol_http_py_lib-0.1.0b5-py3-none-any.whl
Algorithm Hash digest
SHA256 3f14e246820e5a527547cc5324e1b0459d277d1bd1508ed3fed2e04008f83577
MD5 9b92697e1eab0ad5e4de1f590adcaa22
BLAKE2b-256 70da7f780fd09cc30fb262f3e877e5623c1008ee56cae1e01da494777cdb0150

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