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.0rc1.tar.gz (23.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.0rc1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for ds_protocol_http_py_lib-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 5dad2d4a59cbe90d36a313a22e40427a312cdeb2ba2a6010671fa699ac875810
MD5 aaf8138686b627226b1b7fa87d714904
BLAKE2b-256 25d4bfa8b875a4a215c987eb5f6119e4dc3aea748e937edb9b0304accff96603

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ds_protocol_http_py_lib-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 94dca304d3150cef6e88e608e11084b5a6cdab884967625f002a978dbfaba240
MD5 401ce40ee7d6e097a52048f341b2f95c
BLAKE2b-256 9c8d9f052a1014d2fe4cbc71a0c3cabcb46322aaa9a0056894bc4ef0b4237f69

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