Table of Contents

Friendica API

Friendica offers multiple API endpoints to interface with third-party applications:

Usage

HTTP Method

API endpoints can restrict the HTTP method used to request them. Using an invalid method results in HTTP error 405 “Method Not Allowed”.

Authentication

Friendica supports basic HTTP Auth and OAuth 1 to authenticate the user to the APIs. See Friendica API authentication for more details.

Errors

When an error occurs in API call, an HTTP error code is returned, with an error message Usually:

Error body is

{
    "error": "Specific error message",
    "request": "API path requested",
    "code": "HTTP error code"
}
<status>
    <error>Specific error message</error>
    <request>API path requested</request>
    <co.de>HTTP error code</co.de>
</status>

Usage Examples

BASH / cURL

/usr/bin/curl -u USER:PASS https://YOUR.FRIENDICA.TLD/api/statuses/update.xml -d source="some source id" -d status="the status you want to post"

Python

The [RSStoFriendika](https://github.com/pafcu/RSStoFriendika) code can be used as an example of how to use the API with python. The lines for posting are located at [line 21](https://github.com/pafcu/RSStoFriendika/blob/master/RSStoFriendika.py#L21) and following.

def tweet(server, message, group_allow=None):
  url = server + '/api/statuses/update'
  urllib2.urlopen(url, urllib.urlencode({'status': message,'group_allow[]':group_allow}, doseq=True))