mirror of
https://github.com/deesiigneer/pyspapi.git
synced 2026-04-20 12:35:26 +00:00
v3 asyncio/aiohttp alpha
This commit is contained in:
12
examples/get_name_history.py
Normal file
12
examples/get_name_history.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
api = pyspapi.API(card_id='card_id', token='token')
|
||||
|
||||
|
||||
async def main():
|
||||
print(await api.get_name_history(uuid='63ed47877aa3470fbfc46c5356c3d797'))
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
||||
15
examples/get_profile.py
Normal file
15
examples/get_profile.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
api = pyspapi.API(card_id='card_id', token='token')
|
||||
|
||||
|
||||
async def main():
|
||||
mojang_profile = await api.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797')
|
||||
print(mojang_profile)
|
||||
print(mojang_profile.id, mojang_profile.timestamp)
|
||||
print(mojang_profile.skin, mojang_profile.skin.model, mojang_profile.skin.cape_url, mojang_profile.skin.url)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
||||
21
examples/get_user and get_users.py
Normal file
21
examples/get_user and get_users.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
|
||||
api = pyspapi.API(card_id='card_id', token='token')
|
||||
|
||||
|
||||
async def main():
|
||||
user = await api.get_user(264329096920563714)
|
||||
print(user)
|
||||
print(user.access)
|
||||
# У API есть лимиты, каждый user = 1 запрос, учитывайте это при использовании get_users
|
||||
# https://spworlds.readthedocs.io/ru/latest/index.html#id3
|
||||
users = await api.get_users([262632724928397312, 264329096920563714])
|
||||
for user in users:
|
||||
print(user)
|
||||
if user is not None:
|
||||
print(user.access)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
17
examples/get_uuid and get_uuids.py
Normal file
17
examples/get_uuid and get_uuids.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import pyspapi
|
||||
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
api = pyspapi.API(card_id='card_id', token='token')
|
||||
|
||||
|
||||
async def main():
|
||||
uuid = await pyspapi.API(card_id='card_id', token='token').get_uuid(username='deesiigneer')
|
||||
print(uuid)
|
||||
print(uuid.id, uuid.name)
|
||||
print(await pyspapi.API(card_id='card_id', token='token').get_uuids(['deesiigneer', '5opka', 'OsterMiner']))
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
print(pyspapi.MojangAPI.get_name_history(uuid='63ed47877aa3470fbfc46c5356c3d797'))
|
||||
@@ -1,20 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797'))
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').timestamp)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').id)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').name)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').is_legacy_profile)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').cape_url)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').skin_url)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').skin_model)
|
||||
|
||||
print(pyspapi.MojangAPI.get_profile(uuid='63ed47877aa3470fbfc46c5356c3d797').skin)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
print(pyspapi.MojangAPI.get_username(uuid='63ed47877aa3470fbfc46c5356c3d797'))
|
||||
@@ -1,5 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
print(pyspapi.MojangAPI.get_uuid(username='deesiigneer'))
|
||||
|
||||
print(pyspapi.MojangAPI.get_uuids(['deesiigneer', '5opka', 'OsterMiner']))
|
||||
16
examples/payments.py
Normal file
16
examples/payments.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
api = pyspapi.API(card_id='card_id', token='token')
|
||||
|
||||
|
||||
async def main():
|
||||
print(await api.payment(amount=1,
|
||||
redirect_url='https://www.google.com/',
|
||||
webhook_url='https://www.google.com/',
|
||||
data='some-data'
|
||||
)
|
||||
)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
@@ -1,5 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
spapi = pyspapi.SPAPI(card_id='card_id', token='token')
|
||||
|
||||
print(spapi.check_users_access([262632724928397312, 264329096920563714]))
|
||||
@@ -1,11 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
spapi = pyspapi.SPAPI(card_id='card_id', token='token')
|
||||
|
||||
print(spapi.get_user(262632724928397312))
|
||||
|
||||
print(spapi.get_user(262632724928397312).username)
|
||||
|
||||
print(spapi.get_user(262632724928397312).access)
|
||||
|
||||
print(spapi.get_users([262632724928397312, 264329096920563714]))
|
||||
@@ -1,10 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
spapi = pyspapi.SPAPI(card_id='card_id', token='token')
|
||||
|
||||
print(spapi.payment(amount=1,
|
||||
redirect_url='https://www.google.com/',
|
||||
webhook_url='https://www.google.com/',
|
||||
data='some-data'
|
||||
)
|
||||
)
|
||||
@@ -1,9 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
spapi = pyspapi.SPAPI(card_id='CARD_ID', token='TOKEN')
|
||||
|
||||
print(spapi.transaction(receiver=12345,
|
||||
amount=1,
|
||||
comment="test"
|
||||
)
|
||||
)
|
||||
@@ -1,5 +0,0 @@
|
||||
import pyspapi
|
||||
|
||||
spapi = pyspapi.SPAPI(card_id='your_card_id', token='your_token')
|
||||
|
||||
print(spapi.webhook_verify(data='webhook_data', header='webhook_header'))
|
||||
15
examples/transaction.py
Normal file
15
examples/transaction.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
api = pyspapi.API(card_id='CARD_ID', token='TOKEN')
|
||||
|
||||
|
||||
async def main():
|
||||
print(await api.transaction(receiver=12345,
|
||||
amount=1,
|
||||
comment="test"
|
||||
)
|
||||
)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
5
examples/webhook_listener.py
Normal file
5
examples/webhook_listener.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import pyspapi
|
||||
|
||||
api = pyspapi.API(card_id='your_card_id', token='your_token')
|
||||
|
||||
api.listener(host='myhost.com', port=80, webhook_path='/webhook/')
|
||||
10
examples/webhook_verify.py
Normal file
10
examples/webhook_verify.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import pyspapi
|
||||
import asyncio
|
||||
|
||||
api = pyspapi.API(card_id='your_card_id', token='your_token')
|
||||
|
||||
async def main():
|
||||
print(await api.webhook_verify(data='webhook_data', header='webhook_header'))
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(main())
|
||||
Reference in New Issue
Block a user