Sam B Sam B - 1 month ago 13x
Python Question

Posting Content to Friendica using Python

I'm working on a project that is written in Python and needs to post updates to a Friendica server and interact using various APIs available. However, I have had very limited API usage experience and so I'm unsure of how to code this functionality in Python. There is an example on the Friendica GitHub however the Python example would not work for me. There is a Python3 module, however when trying to connect using this in a test script as follows:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import friendica
# make a new instance of friendica
f = friendica.friendica (server = '', username = 'newtest', password = 'klaup8744')

# check that we are logged in

# get the current notifications
print (

# post something with the default settings
f.statuses_update( status = "here is the message you are going to post" )

it would refuse the connection with the following message:

Traceback (most recent call last):
File "/usr/lib/python3.4/urllib/", line 1182, in do_open
h.request(req.get_method(), req.selector,, headers)
File "/usr/lib/python3.4/http/", line 1088, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/", line 1126, in _send_request
File "/usr/lib/python3.4/http/", line 1084, in endheaders
File "/usr/lib/python3.4/http/", line 922, in _send_output
File "/usr/lib/python3.4/http/", line 857, in send
File "/usr/lib/python3.4/http/", line 1223, in connect
File "/usr/lib/python3.4/http/", line 834, in connect
self.timeout, self.source_address)
File "/usr/lib/python3.4/", line 512, in create_connection
raise err
File "/usr/lib/python3.4/", line 503, in create_connection
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 12, in <module>
print (
File "/home/sambraidley/Desktop/", line 851, in ping
res = urlopen(self.protocol()+self.apipath[:-4]+'/ping').read().decode('utf-8')
File "/usr/lib/python3.4/urllib/", line 161, in urlopen
return, data, timeout)
File "/usr/lib/python3.4/urllib/", line 463, in open
response = self._open(req, data)
File "/usr/lib/python3.4/urllib/", line 481, in _open
'_open', req)
File "/usr/lib/python3.4/urllib/", line 441, in _call_chain
result = func(*args)
File "/usr/lib/python3.4/urllib/", line 1225, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib/python3.4/urllib/", line 1184, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>

The friendica Python3 module can be found at the following

My Friendica server is setup within a VM with the address, with test credentials of username = 'newtest' and password 'klaup8744' and it is fully working as using the curl example code to post an update worked perfectly, as follows:

/usr/bin/curl -u newtest:klaup8744 -d source="Testing" -d status="This is a test status"


According to the source link you posted, friendica uses https by default. Your successful curl request is using http.
Try instantiating friendica it using http:

f = friendica.friendica (server = '', 
username = 'newtest', password = 'klaup8744', useHTTPS=False)