Skip to content

User module

The user module contains methods regarding the handling of Fanpoints users and their ids.

Checking if a user id is valid

In order to check if a user id is valid (i.e. the checksum is correct), you can use the is_valid_user_id method:

from fanpoints_python import FanpointsClient
client = FanpointsClient(
partner_id='<your partner id>',
client_id='<your client id>',
secret='<your client secret>',
)
is_valid = client.users.is_valid_user_id("123456789012")
print(is_valid) # True
is_valid = client.users.is_valid_user_id("123456789010")
print(is_valid) # False

Checking if a user id exists

Checking the checksum is very fast, as no network request is made. However, sometimes it is useful to check if a user id actually exists. You can use the does_user_id_exist method to do that:

import asyncio
from fanpoints_python import FanpointsClient
client = FanpointsClient(
partner_id='<your partner id>',
client_id='<your client id>',
secret='<your client secret>',
)
async def run():
result = await client.users.does_user_exist("123456789012")
print(result) # True or False
asyncio.run(run())

Formatting a user id

As a convenience method, you can use the format_user_id method to format a user id:

from fanpoints_python import FanpointsClient
client = FanpointsClient(
partner_id='<your partner id>',
client_id='<your client id>',
secret='<your client secret>',
)
formatted_user_id = client.users.format_user_id("123456789012")
print(formatted_user_id) # 1234 5678 9012