Skip to main content

Library for interacting with API Gateway and DynamoDB

Project description

API Gateway & DynamoDB Utility Library

Overview

This library provides utility functions to interact with AWS API Gateway and DynamoDB. It enables secure API communication for fetching and upserting data via API Gateway, ensuring robust error handling, logging, and authentication using an API Key.

Features

  • Fetch Data from DynamoDB via API Gateway
  • Upsert Data (Insert/Update) into DynamoDB
  • Secure API Access using API Key
  • Robust Logging & Error Handling
  • Optimized JSON Response Handling
  • Support for Private Repository Deployment

Installation

Prerequisites

Ensure you have Python 3.8+ installed.

Install the required dependencies:

pip install requests
pip install api_gateway_dynamodb 

Usage - Read Data

 from api_gateway_dynamodb import get_data_from_api_gateway_dynamodb

# API Gateway Endpoint URL
api_url = "https://your-api-gateway-url.com/get-data"

# Example Parameters
database_table_name = "customer"
partition_key = "customer_id"
partition_key_value = "123456"
api_key = "your-api-key-here"

# Fetch data
response = get_data_from_api_gateway_dynamodb(api_url, 
                                              database_table_name, 
                                              partition_key, 
                                              partition_key_value, 
                                              api_key)

print(response)  # Output: JSON response with data from DynamoDB

Usage - Insert / Update data

from api_gateway_dynamodb import upsert_data_via_api_gateway_dynamodb

# API Gateway Endpoint URL
api_url = "https://your-api-gateway-url.com/upsert-data"

# Example Data Payload
payload = {
    "id_number": "123456",
    "name": "John",
    "surname": "Doe",
    "title": "Mr"
}

# Upsert Parameters
method_name = "insert"
table_name = "customer"
partition_key = "id_number"
api_key = "your-api-key-here"

# Insert or Update Data
response = upsert_data_via_api_gateway_dynamodb(payload, method_name, table_name, partition_key, api_key, api_url)

print(response)  # Output: JSON response confirming the operation

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

api_gateway_dynamodb-0.1.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

api_gateway_dynamodb-0.1.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file api_gateway_dynamodb-0.1.2.tar.gz.

File metadata

  • Download URL: api_gateway_dynamodb-0.1.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for api_gateway_dynamodb-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4a46473d6b430ebf288fe45612e13eeb068511d9d0972ad084d936c2381341b7
MD5 c3d86c251a5bd65d73222f7dc5431c00
BLAKE2b-256 eca0b3f5a51bbb00f9509c79f3083091fd5a3382e7b906b96f7b5d8c8837578e

See more details on using hashes here.

File details

Details for the file api_gateway_dynamodb-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for api_gateway_dynamodb-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b3ae28cedb1e9e425585c3d7796e4e45d0cd7e31833894911f21f253a3ebd07a
MD5 b82f095331061703ab79f0fc829d9fc5
BLAKE2b-256 4aaf3e5f6edfef20596ca7448267841ea97e070744a73f7230c3f3773730cc83

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