Skip to main content

UA-Generic-Rest-Api

Provides basic REST API Implementation for GET, PUT, and POST, and DELETE.

Motivation

Was designed to remove similarities among REST API implementations by creating a generic REST API that classes can be extended and override for specific needs.

Features

  • GET - Implementation of GET which can single GET, batch GET, single GET with query, and GET every page on a paginated endpoint.
    • Batch gets with queries are unavailable as there is no way to give each get a unique query. Because of this the feature was not included.
  • PUT - Basic implementation of PUT which puts the payload to the given endpoint.
  • POST - Basic implementation of POST which posts the payload to the given endpoint.
  • DELETE - Basic implementation of DELETE which deletes the given endpoint.

Code Example

from ua_generic_rest_api import GenericRestApi

class SpecificRestApi(GenericRestApi):
    # Replace '...' with any other initialization arguments.
    def __init__(self, ...):
        # host, header_info, page_query, and page_tag are site specific.
        # Set them to your own values.
        super().__init__(host, header_info, page_query, page_tag=page_tag)

    # Can override GET, PUT, POST, or DELETE here.
  • host - The base url for the endpoint that is to be gotten.
  • header_info - Any information to be added to a request header such as Authorization or Content-Type.
    • Should be in the form of a dictionary, such as {"Authorization": None, "Content-Type": "text/xml"}.
  • page_query - The tag to use when querying for specific pages.
    • For example, for sites queried with the tag "?page=", page_query should be "page".
  • page_tag - The tag name of paginated endpoints to search for when getting data.
    • For sites paginated with the tag "page", page_tag should be "page".

Installation

pip install ua-generic-rest-api
pip install -r requirements.txt

Tests

  • Tests are only necessary when wanting to make changes to the module.
  • Run from root of repo
python -m unittest ua_generic_rest_api.tests.test_generic_rest_api

Credits

sterns1 EtienneThompson

License

MIT

Metadata

Release files for ua-generic-rest-api 2.1.0

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

Source distribution (sdist)

Source distribution for ua-generic-rest-api 2.1.0
File Size Uploaded
ua_generic_rest_api-2.1.0.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ua-generic-rest-api 2.1.0
File Interpreter ABI Platform
ua_generic_rest_api-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / ua_generic_rest_api-2.1.0.tar.gz

Download URL ua_generic_rest_api-2.1.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d71aa3c26271ef6b2be306066f19da68efbe8021662646aede9d5ff1e52fe37b
BLAKE2b-256 checksum
How to use checksums
f971728a2bcafc63f787050424ec5bf3b0f490e8236bf10ff6681d308ffa1785
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Linux/6.8.0-134-generic

Release files / ua_generic_rest_api-2.1.0-py3-none-any.whl

Download URL ua_generic_rest_api-2.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f0abb31cb8be0bed0691c23d5d99090ace477f247b727b4e1ccb26300bfc453
BLAKE2b-256 checksum
How to use checksums
12e06b09b99eb2a3602a349cf1e8df017f2b44fd6357049501cac7473df5e645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.14.6 Linux/6.8.0-134-generic

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.0

1 release file

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