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.2.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.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: synthientpy-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 94a7b5355004100f8b1bad782d319a4e2ff4853c019783998af47257b9e71f0b
MD5 0ba3aa946215328ad1714a65762dd7bd
BLAKE2b-256 d4276ce83a3cb1451bff7250bdd3f3b7b990897f1c64ca13c657deceecc6d408

See more details on using hashes here.

File details

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

File metadata

  • Download URL: synthientpy-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98c17e8be7ac68018880a154c18470f2eb8a1ad5684a1201d405354c09a5719f
MD5 2534c59bd31bcefeae6356d7e8ae9782
BLAKE2b-256 6749a62dfe41968b6064883b2775f30d60c827a8792fedad9ec14321bd3d337f

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