.. _querying_horizon: **************** Querying Horizon **************** py-stellar-base gives you access to all the endpoints exposed by Horizon. Building requests ================= py-stellar-base uses the `Builder pattern `_ to create the requests to send to Horizon. Starting with a :py:class:`Server ` object, you can chain methods together to generate a query. (See the `Horizon reference `_ documentation for what methods are possible.) .. literalinclude:: ../../examples/query_horizon.py :language: python :linenos: Once the request is built, it can be invoked with :py:meth:`call() ` or with :py:meth:`stream() `. :py:meth:`call() ` will return the response given by Horizon. Streaming requests ================== Many requests can be invoked with :py:meth:`stream() `. Instead of returning a result like :py:meth:`call() ` does, :py:meth:`stream() ` will return an EventSource. Horizon will start sending responses from either the beginning of time or from the point specified with :py:meth:`cursor() `. (See the `Horizon reference `_ documentation to learn which endpoints support streaming.) For example, to log instances of transactions from a particular account: .. literalinclude:: ../../examples/stream_requests.py :language: python :linenos: