Skip to content

Instantly share code, notes, and snippets.

@alvmgdev
Last active March 16, 2025 21:56
Show Gist options
  • Save alvmgdev/86f98c58c92abf9b72687b9fa3b2f452 to your computer and use it in GitHub Desktop.
Save alvmgdev/86f98c58c92abf9b72687b9fa3b2f452 to your computer and use it in GitHub Desktop.

Revisions

  1. alvmgdev revised this gist Jan 2, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion consumer_ps3838_api.py
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ def get_operation_endpoint(operation: str) -> str:


    def get_sports():
    operation = '/v1/sports'
    operation = '/v3/sports'
    req = requests.get(
    get_operation_endpoint(operation),
    headers=get_headers(HttpMethod.GET)
  2. @alvaroMerino alvaroMerino created this gist Jun 26, 2019.
    56 changes: 56 additions & 0 deletions consumer_ps3838_api.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    import base64
    import requests
    from enum import Enum

    """
    Script to connect to ps3838 API
    URL to check API User Guide:
    https://www.tender88.com/static/index.php/es-es/help/api-user-guide-es-es
    In order to access PS3838 API you must have a funded account.
    """

    # API ENDPOINT
    API_ENDPOINT = 'http://api.ps3838.com'


    # Available Request Methods
    class HttpMethod(Enum):
    GET = 'GET'
    POST = 'POST'


    # Constants to fill by each user
    PS3838_USERNAME = "FILL_USERNAME_HERE"
    PS3838_PASSWORD = "FILL_PASSWORD_HERE"


    def get_headers(request_method: HttpMethod) -> dict:
    headers = {}
    headers.update({'Accept': 'application/json'})
    if request_method is HttpMethod.POST:
    headers.update({'Content-Type': 'application/json'})

    headers.update({'Authorization': 'Basic {}'.format(
    base64.b64encode((bytes("{}:{}".format(PS3838_USERNAME, PS3838_PASSWORD), 'utf-8'))).decode())
    })

    return headers


    def get_operation_endpoint(operation: str) -> str:
    return '{}{}'.format(API_ENDPOINT, operation)


    def get_sports():
    operation = '/v1/sports'
    req = requests.get(
    get_operation_endpoint(operation),
    headers=get_headers(HttpMethod.GET)
    )
    return req.json()


    # Test retrieve sports endpoint
    print(get_sports())