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

Uploaded Python 3

File details

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

File metadata

  • Download URL: synthientpy-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 d55a54091e50f678bad8a48398e1c506b259712614f696ca870b33a1f37fd378
MD5 a89057672075dde02324d6cb2cf4fe02
BLAKE2b-256 e3a0f61cb65147de1cc1f21f325ab43204541d7fd3531d1b86fe9a4392e73c84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: synthientpy-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4dfd7fc4222a049fbfa7dde5144041c509254a244e3283d4b1e4bcfc824f5a32
MD5 e4ff7d649f1e586ce871bc8acc113f44
BLAKE2b-256 40b85a7f7d50e94fb50b53a085c523033fc4229b623a24582a50a1ca02287b9f

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