user31712: I want to write some scripts for experiments with Lightning. Python is the language I'm most comfortable with. From the three major implementations, LND has python-grpc and c-lightning has pylightning, but what about Eclair? How can I interact with an Eclair node from a Python script?

user81940: This might not be a satisfying answer but if you look at the eclair git repo and their Wiki you will find that the eclair API is a JSON API and is exposed via http and web sockets and can be queried with regular http requests.
If you look at the c-lightning python client it is a tool that talks via a unixDomainSocket to the exposed lightningd api. So I guess you could in a smilar way quickly create a python wrapper to be able to talk to eclair. 
It seems to me that currently no one has bothered to do so. 

user100027: Here is a simple implementation that just works
import requests

class EclairClient():
    def __init__(self,host, port, password, service_name=None, session=None):
        self._host = host
        self._port = port
        self._password = password
        self._session = session
        if session is None:
            self._session = requests.Session()
        self._service_name = service_name
        self._url = "http://%s:%s/%s" % (self._host, self._port, self._service_name)

    def __getattr__(self, name):
        if name.startswith('__') and name.endswith('__'):
            # Python internal stuff
            raise AttributeError
        if self._service_name is not None:
            name = "%s.%s" % (self._service_name, name)
        return EclairClient(self._host, self._port, self._password, name, self._session )

    def __call__(self, *args, **kwargs):
        return self._session.post(self._url, data=kwargs,auth=('', self._password)).json()

password = "mypassword"
c = EclairClient("localhost", 8080, password)
c.getinfo()
>>> {u'alias': u'blinktrade DEV',
>>>  u'blockHeight': 1583023,
>>> u'chainHash': u'43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
>>> u'nodeId': u'038b3f00c4a535238b748f025038dcbb825c4e2a03f08ab1c391f0bfada4b31b45',
>>> u'publicAddresses': []}

c.createinvoice(description="testing", amountMsat=15000)
>>>{u'amount': 15000,
>>> u'description': u'testing',
>>> u'expiry': 3600,
>>> u'nodeId': u'038b3f00c4a535238b748f025038dcbb825c4e2a03f08ab1c391f0bfada4b31b45',
>>> u'paymentHash': u'0eb6ea2dcb36b99a0e7ab3e09bff97c0e32277a5017034cf2e39859de00f4a8e',
>>> u'prefix': u'lntb',
>>> u'serialized': u'lntb150n1pw62a8zpp5p6mw5twtx6ue5rn6k0sfhluhcr3jyaa9q9crfnew8xzemcq0f28qdqvw3jhxarfdensxqrrssdwfxdxrvkdtaetg5k8dz3j42hpupffvdzljsl3nls9faujuxt5e4elu0cnvszg0vhs3m2gw28d4h9c83saxfk0qs4ygwd6yaa5dt8uqpamka3f',
>>> u'timestamp': 1571124450}


31712: <p>I want to write some scripts for experiments with Lightning. Python is the language I'm most comfortable with. From the three major implementations, LND has <a href="https://dev.lightning.community/guides/python-grpc/" rel="nofollow noreferrer">python-grpc</a> and c-lightning has <a href="https://github.com/ElementsProject/lightning/tree/master/contrib/pylightning" rel="nofollow noreferrer">pylightning</a>, but what about Eclair? How can I interact with an Eclair node from a Python script?</p>
 81940: <p>This might not be a satisfying answer but if you look at the eclair git repo and their <a href="https://github.com/ACINQ/eclair/wiki/API" rel="nofollow noreferrer">Wiki</a> you will find that <a href="https://acinq.github.io/eclair/" rel="nofollow noreferrer">the eclair API</a> is a JSON API and is exposed via http and web sockets and can be queried with regular http requests.</p>

<p>If you look at the <a href="https://github.com/ElementsProject/lightning/blob/master/contrib/pylightning/lightning/lightning.py" rel="nofollow noreferrer">c-lightning python client</a> it is a tool that talks via a unixDomainSocket to the exposed <code>lightningd</code> api. So I guess you could in a smilar way quickly create a python wrapper to be able to talk to eclair. </p>

<p>It seems to me that currently no one has bothered to do so. </p>
 100027: <p>Here is a simple implementation that just works</p>

<pre><code>import requests

class EclairClient():
    def __init__(self,host, port, password, service_name=None, session=None):
        self._host = host
        self._port = port
        self._password = password
        self._session = session
        if session is None:
            self._session = requests.Session()
        self._service_name = service_name
        self._url = "http://%s:%s/%s" % (self._host, self._port, self._service_name)

    def __getattr__(self, name):
        if name.startswith('__') and name.endswith('__'):
            # Python internal stuff
            raise AttributeError
        if self._service_name is not None:
            name = "%s.%s" % (self._service_name, name)
        return EclairClient(self._host, self._port, self._password, name, self._session )

    def __call__(self, *args, **kwargs):
        return self._session.post(self._url, data=kwargs,auth=('', self._password)).json()
</code></pre>

<pre><code>password = "mypassword"
c = EclairClient("localhost", 8080, password)
c.getinfo()
&gt;&gt;&gt; {u'alias': u'blinktrade DEV',
&gt;&gt;&gt;  u'blockHeight': 1583023,
&gt;&gt;&gt; u'chainHash': u'43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000',
&gt;&gt;&gt; u'nodeId': u'038b3f00c4a535238b748f025038dcbb825c4e2a03f08ab1c391f0bfada4b31b45',
&gt;&gt;&gt; u'publicAddresses': []}

c.createinvoice(description="testing", amountMsat=15000)
&gt;&gt;&gt;{u'amount': 15000,
&gt;&gt;&gt; u'description': u'testing',
&gt;&gt;&gt; u'expiry': 3600,
&gt;&gt;&gt; u'nodeId': u'038b3f00c4a535238b748f025038dcbb825c4e2a03f08ab1c391f0bfada4b31b45',
&gt;&gt;&gt; u'paymentHash': u'0eb6ea2dcb36b99a0e7ab3e09bff97c0e32277a5017034cf2e39859de00f4a8e',
&gt;&gt;&gt; u'prefix': u'lntb',
&gt;&gt;&gt; u'serialized': u'lntb150n1pw62a8zpp5p6mw5twtx6ue5rn6k0sfhluhcr3jyaa9q9crfnew8xzemcq0f28qdqvw3jhxarfdensxqrrssdwfxdxrvkdtaetg5k8dz3j42hpupffvdzljsl3nls9faujuxt5e4elu0cnvszg0vhs3m2gw28d4h9c83saxfk0qs4ygwd6yaa5dt8uqpamka3f',
&gt;&gt;&gt; u'timestamp': 1571124450}
</code></pre>
