Skip to main content

Synthient API bindings.

Project description

synthientpy

A strongly typed Python client for Synthient. Supports asynchronous and synchronous requests to the Synthient API.

Installation

MacOS/Linux

pip3 install synthientpy

Windows

pip install synthientpy

Usage

Check synthientpy/models for the available fields in the response object.

Client and AsyncClient have the following methods:

class Client:
    def __init__(
        self,
        api_key: str,
        default_timeout: int = DEFAULT_TIMEOUT,
        proxy: Optional[str] = None,
    ) -> None: ...
     def lookup(self, token: str) -> LookupResponse: ...
     def visits(self, session: str) -> VisitsResponse: ...
     def delete(self, token: str) -> DeleteResponse: ...

Synchronous Usage

import synthientpy as synthient
client = synthient.Client(
    api_key=os.getenv("SYNTHIENT_API_KEY"),
)
token = "..."
visitor_info = client.lookup(token)
print(visitor_info)

Asynchronous Usage

import asyncio
import synthientpy as synthient

async def main():
    client = synthient.AsyncClient(
        api_key=os.getenv("SYNTHIENT_API_KEY"),
    )
    token = "..."
    visitor_info = await client.lookup(token)
    print(visitor_info)

asyncio.run(main())

Helper Functions

In addition to the client, there are helper functions that can be used to interact with the Synthient API.

def verify_token(lookup: LookupResponse, token_type: TokenType) -> bool: ...

def determine_action(lookup: LookupResponse, token_type: TokenType) -> str: ...

Verify token checks if the token is valid and if the server should reject or accept it. Determine action checks if the token is valid and returns the action that should be taken based on the token type.

class ActionType(str, Enum):
    """Translates the risk level into an action to take.
    ALLOW - Allow the visitor to continue.
    REDIRECT - Redirect the visitor to a different page. Or have them perform another form of verification.
    BLOCK - Block the visitor from accessing
    """

    ALLOW = 0
    REDIRECT = 1
    BLOCK = 2

Models

Full documentation of the fields and their types can be found in the Synthient API documentation. You can also find all the types in the synthientpy.models module.

Issues

For any issues or feature requests, please open an issue on the GitHub repository

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

synthientpy-0.1.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

synthientpy-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file synthientpy-0.1.3.tar.gz.

File metadata

  • Download URL: synthientpy-0.1.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for synthientpy-0.1.3.tar.gz
Algorithm Hash digest
SHA256 1602e3e1592e5d1864fcb3962fba23e511788e5669158ef065bffa9682c8c37b
MD5 cabf69bd9cfac97230ebb86f80a1cf7c
BLAKE2b-256 8f8794b3512edc523322e8082b2e2aeedcc1e85ef6cf9f09930b25a76a8ea88f

See more details on using hashes here.

File details

Details for the file synthientpy-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: synthientpy-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for synthientpy-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3586f2d8b76657aaddc757a98ef5d57d92da151efff3402b65af87a0d53be48
MD5 c9b4e30bd7bb8836e013a80b564ad808
BLAKE2b-256 d161675dc83467dc3389d3486f405005fb21c0fbe915945eddffb3ac4d0906fc

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