How to use the duniterpy.api.client.Client function in duniterpy

To help you get started, we’ve selected a few duniterpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duniter / duniter-python-api / tests / api / bma / test_network.py View on Github external
async def go():
            _, port, _ = await self.create_server(
                "GET", "/network/peering/peers", handler
            )
            with self.assertRaises(jsonschema.exceptions.ValidationError):
                client = Client(BMAEndpoint("127.0.0.1", "", "", port))
                await client(network.peers)
            await client.close()
github duniter / duniter-python-api / tests / api / bma / test_wot.py View on Github external
async def go():
            _, port, _ = await self.create_server(
                "GET", "/wot/certified-by/pubkey", handler
            )
            with self.assertRaises(jsonschema.exceptions.ValidationError):
                client = Client(BMAEndpoint("127.0.0.1", "", "", port))
                await client(certified_by, "pubkey")
            await client.close()
github duniter / duniter-python-api / tests / api / bma / test_blockchain.py View on Github external
async def go():
            _, port, _ = await self.create_server(
                "GET", "/blockchain/with/leavers", handler
            )
            with self.assertRaises(jsonschema.exceptions.ValidationError):
                client = Client(BMAEndpoint("127.0.0.1", "", "", port))
                await client(leavers)
            await client.close()
github duniter / duniter-python-api / examples / request_data_async.py View on Github external
async def main():
    """
    Main code (asynchronous requests)

    You can send one millions request with aiohttp :

    https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html

    But don't do that on one server, it's DDOS !

    """
    # Create Client from endpoint string in Duniter format
    client = Client(BMAS_ENDPOINT)
    tasks = []

    # Get the node summary infos by dedicated method (with json schema validation)
    print("\nCall bma.node.summary:")
    task = asyncio.ensure_future(client(bma.node.summary))
    tasks.append(task)

    # Get the money parameters located in the first block
    print("\nCall bma.blockchain.parameters:")
    task = asyncio.ensure_future(client(bma.blockchain.parameters))
    tasks.append(task)

    responses = await asyncio.gather(*tasks)
    # you now have all response bodies in this variable
    print("\nResponses:")
    print(responses)
github duniter / duniter-python-api / examples / send_certification.py View on Github external
async def main():
    """
    Main code
    """
    # Create Client from endpoint string in Duniter format
    client = Client(BMAS_ENDPOINT)

    # Get the node summary infos to test the connection
    response = await client(bma.node.summary)
    print(response)

    # prompt hidden user entry
    salt = getpass.getpass("Enter your passphrase (salt): ")

    # prompt hidden user entry
    password = getpass.getpass("Enter your password: ")

    # create key from credentials
    key = SigningKey.from_credentials(salt, password)
    pubkey_from = key.pubkey

    # prompt entry