Skip to main content

anslapi

A python3 module for creating a simple API with AWS Lambda and API Gateway.

Install

python3 -m pip install anslapi

Configuration

Create an api gateway with the methods that are needed, and set up authentication, schemas, etc. as wished. Create a Lambda function and configure our function as the target for each method. Use Lambda proxy mode.

Usage example

from anslapi import APIHandler

def get_user(userid):
  return "user.name@example.com"

def add(event):
  import json
  result = { 
    "status": "FAIL"
  }

  j = json.loads(event["body"])

  if "userid" in j:
    result["response"] = cls.get_user(j["userid"])
    result["status"] = "SUCCESS"
    return (200, result)

  else:
    result["reason"] = "Invalid request"
    return (400, result)  


def lambda_handler(event, context):
  ah = APIHandler()

  ah.add_handler('/add', 'POST',  Actions.add)
  
  response = ah.handle(event)
    
  return response

Release files for anslapi 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for anslapi 1.0.1
File Size Uploaded
anslapi-1.0.1.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for anslapi 1.0.1
File Interpreter ABI Platform
anslapi-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.9 kB

Release files / anslapi-1.0.1.tar.gz

Download URL anslapi-1.0.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5f72aca1e6e636ec35dc3fe76e667d241db710954c005700100c7a6643ac17f2
BLAKE2b-256 checksum
How to use checksums
ebb8a2ef78eb8eb12ade4ea8842f18e5d9ccb44e19a3cdb006cf02d3b7c49906
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

Release files / anslapi-1.0.1-py3-none-any.whl

Download URL anslapi-1.0.1-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49df0a8c578fc0fd8bde3ad64ba4e7b568c14afd4cb35dae40fe2cf7ff945241
BLAKE2b-256 checksum
How to use checksums
87b905aa58f707d8ed2d1b584b3d54ca0411e8a79414019b93715641e344e4ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page