3 The Friendica API aims to be compatible to the [GNU Social API](http://wiki.gnusocial.de/gnusocial:api) and the [Twitter API](https://dev.twitter.com/rest/public).
\r
5 Please refer to the linked documentation for further information.
\r
7 ## Implemented API calls
\r
12 API endpoints can restrict the method used to request them.
\r
13 Using an invalid method results in HTTP error 405 "Method Not Allowed".
\r
15 In this document, the required method is listed after the endpoint name. "*" means every method can be used.
\r
19 Friendica supports basic http auth and OAuth 1 to authenticate the user to the api.
\r
21 OAuth settings can be added by the user in web UI under /settings/oauth/
\r
23 In this document, endpoints which requires auth are marked with "AUTH" after endpoint name
\r
25 #### Unsupported parameters
\r
26 * cursor: Not implemented in GNU Social
\r
27 * trim_user: Not implemented in GNU Social
\r
28 * contributor_details: Not implemented in GNU Social
\r
29 * place_id: Not implemented in GNU Social
\r
30 * display_coordinates: Not implemented in GNU Social
\r
31 * include_rts: To-Do
\r
32 * include_my_retweet: Retweets in Friendica are implemented in a different way
\r
34 #### Different behaviour
\r
35 * screen_name: The nick name in friendica is only unique in each network but not for all networks. The users are searched in the following priority: Friendica, StatusNet/GNU Social, Diaspora, pump.io, Twitter. If no contact was found by this way, then the first contact is taken.
\r
36 * include_entities: Default is "false". If set to "true" then the plain text is formatted so that links are having descriptions.
\r
39 * cid: Contact id of the user (important for "contact_allow" and "contact_deny")
\r
40 * network: network of the user
\r
43 When an error occour in API call, an HTTP error code is returned, with an error message
\r
45 - 400 Bad Request: if parameter are missing or items can't be found
\r
46 - 403 Forbidden: if authenticated user is missing
\r
47 - 405 Method Not Allowed: if API was called with invalid method, eg. GET when API require POST
\r
48 - 501 Not Implemented: if requested API doesn't exists
\r
49 - 500 Internal Server Error: on other error contitions
\r
56 "error": "Specific error message",
\r
57 "request": "API path requested",
\r
58 "code": "HTTP error code"
\r
65 <error>Specific error message</error>
\r
66 <request>API path requested</request>
\r
67 <code>HTTP error code</code>
\r
72 ### account/rate_limit_status (*; AUTH)
\r
75 ### account/verify_credentials (*; AUTH)
\r
78 * skip_status: Don't show the "status" field. (Default: false)
\r
79 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
82 ### conversation/show (*; AUTH)
\r
83 Unofficial Twitter command. It shows all direct answers (excluding the original post) to a given id.
\r
86 * id: id of the post
\r
87 * count: Items per page (default: 20)
\r
89 * since_id: minimal id
\r
90 * max_id: maximum id
\r
91 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
93 #### Unsupported parameters
\r
96 * contributor_details
\r
99 ### direct_messages (*; AUTH)
\r
101 * count: Items per page (default: 20)
\r
102 * page: page number
\r
103 * since_id: minimal id
\r
104 * max_id: maximum id
\r
105 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
106 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
108 #### Unsupported parameters
\r
112 ### direct_messages/all (*; AUTH)
\r
114 * count: Items per page (default: 20)
\r
115 * page: page number
\r
116 * since_id: minimal id
\r
117 * max_id: maximum id
\r
118 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
121 ### direct_messages/conversation (*; AUTH)
\r
122 Shows all direct messages of a conversation
\r
124 * count: Items per page (default: 20)
\r
125 * page: page number
\r
126 * since_id: minimal id
\r
127 * max_id: maximum id
\r
128 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
129 * uri: URI of the conversation
\r
132 ### direct_messages/new (POST,PUT; AUTH)
\r
134 * user_id: id of the user
\r
135 * screen_name: screen name (for technical reasons, this value is not unique!)
\r
136 * text: The message
\r
137 * replyto: ID of the replied direct message
\r
138 * title: Title of the direct message
\r
141 ### direct_messages/sent (*; AUTH)
\r
143 * count: Items per page (default: 20)
\r
144 * page: page number
\r
145 * since_id: minimal id
\r
146 * max_id: maximum id
\r
147 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
148 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
151 ### favorites (*; AUTH)
\r
153 * count: Items per page (default: 20)
\r
154 * page: page number
\r
155 * since_id: minimal id
\r
156 * max_id: maximum id
\r
157 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
159 #### Unsupported parameters
\r
163 Favorites aren't displayed to other users, so "user_id" and "screen_name" are unsupported.
\r
164 Set this values will result in an empty array.
\r
167 ### favorites/create (POST,PUT; AUTH)
\r
170 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
173 ### favorites/destroy (POST,DELETE; AUTH)
\r
176 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
179 ### followers/ids (*; AUTH)
\r
181 * stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)
\r
183 #### Unsupported parameters
\r
188 Friendica doesn't allow showing followers of other users.
\r
191 ### friends/ids (*; AUTH)
\r
193 * stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)
\r
195 #### Unsupported parameters
\r
200 Friendica doesn't allow showing friends of other users.
\r
206 ### media/upload (POST,PUT; AUTH)
\r
208 * media: image data
\r
211 ### oauth/request_token (*)
\r
215 #### Unsupported parameters
\r
216 * x_auth_access_type
\r
219 ### oauth/access_token (*)
\r
223 #### Unsupported parameters
\r
229 ### statuses/destroy (POST,DELETE; AUTH)
\r
231 * id: message number
\r
232 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
234 #### Unsupported parameters
\r
238 ### statuses/followers (*; AUTH)
\r
242 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
245 ### statuses/friends (*; AUTH)
\r
249 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
252 ### statuses/friends_timeline (*; AUTH)
\r
254 * count: Items per page (default: 20)
\r
255 * page: page number
\r
256 * since_id: minimal id
\r
257 * max_id: maximum id
\r
258 * exclude_replies: don't show replies (default: false)
\r
259 * conversation_id: Shows all statuses of a given conversation.
\r
260 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
262 #### Unsupported parameters
\r
265 * contributor_details
\r
268 ### statuses/home_timeline (*; AUTH)
\r
270 * count: Items per page (default: 20)
\r
271 * page: page number
\r
272 * since_id: minimal id
\r
273 * max_id: maximum id
\r
274 * exclude_replies: don't show replies (default: false)
\r
275 * conversation_id: Shows all statuses of a given conversation.
\r
276 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
278 #### Unsupported parameters
\r
281 * contributor_details
\r
284 ### statuses/mentions (*; AUTH)
\r
286 * count: Items per page (default: 20)
\r
287 * page: page number
\r
288 * since_id: minimal id
\r
289 * max_id: maximum id
\r
290 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
292 #### Unsupported parameters
\r
295 * contributor_details
\r
298 ### statuses/public_timeline (*; AUTH)
\r
300 * count: Items per page (default: 20)
\r
301 * page: page number
\r
302 * since_id: minimal id
\r
303 * max_id: maximum id
\r
304 * exclude_replies: don't show replies (default: false)
\r
305 * conversation_id: Shows all statuses of a given conversation.
\r
306 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
308 #### Unsupported parameters
\r
312 ### statuses/replies (*; AUTH)
\r
314 * count: Items per page (default: 20)
\r
315 * page: page number
\r
316 * since_id: minimal id
\r
317 * max_id: maximum id
\r
318 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
320 #### Unsupported parameters
\r
323 * contributor_details
\r
326 ### statuses/retweet (POST,PUT; AUTH)
\r
328 * id: message number
\r
329 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
331 #### Unsupported parameters
\r
335 ### statuses/show (*; AUTH)
\r
337 * id: message number
\r
338 * conversation: if set to "1" show all messages of the conversation with the given id
\r
339 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
341 #### Unsupported parameters
\r
342 * include_my_retweet
\r
346 ### statuses/update, statuses/update_with_media
\r
348 * title: Title of the status
\r
349 * status: Status in text format
\r
350 * htmlstatus: Status in HTML format
\r
351 * in_reply_to_status_id
\r
354 * media: image data
\r
355 * source: Application name
\r
361 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
362 * media_ids: (By now only a single value, no array)
\r
364 #### Unsupported parameters
\r
367 * display_coordinates
\r
370 ### statuses/user_timeline (*; AUTH)
\r
372 * user_id: id of the user
\r
373 * screen_name: screen name (for technical reasons, this value is not unique!)
\r
374 * count: Items per page (default: 20)
\r
375 * page: page number
\r
376 * since_id: minimal id
\r
377 * max_id: maximum id
\r
378 * exclude_replies: don't show replies (default: false)
\r
379 * conversation_id: Shows all statuses of a given conversation.
\r
380 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
382 #### Unsupported parameters
\r
386 * contributor_details
\r
389 ### statusnet/config (*)
\r
392 ### statusnet/conversation (*; AUTH)
\r
393 It shows all direct answers (excluding the original post) to a given id.
\r
396 * id: id of the post
\r
397 * count: Items per page (default: 20)
\r
398 * page: page number
\r
399 * since_id: minimal id
\r
400 * max_id: maximum id
\r
401 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
404 ### statusnet/version (*)
\r
406 #### Unsupported parameters
\r
411 Friendica doesn't allow showing followers of other users.
\r
414 ### users/search (*)
\r
416 * q: name of the user
\r
418 #### Unsupported parameters
\r
426 * user_id: id of the user
\r
427 * screen_name: screen name (for technical reasons, this value is not unique!)
\r
428 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
430 #### Unsupported parameters
\r
435 Friendica doesn't allow showing friends of other users.
\r
438 ## Implemented API calls (not compatible with other APIs)
\r
442 ### friendica/activity/<verb>
\r
446 Add or remove an activity from an item.
\r
447 'verb' can be one of:
\r
455 To remove an activity, prepend the verb with "un", eg. "unlike" or "undislike"
\r
456 Attend verbs disable eachother: that means that if "attendyes" was added to an item, adding "attendno" remove previous "attendyes".
\r
457 Attend verbs should be used only with event-related items (there is no check at the moment)
\r
466 ```<ok>true</ok>```
\r
469 HTTP 400 BadRequest
\r
472 ### friendica/group_show (*; AUTH)
\r
473 Return all or a specified group of the user with the containing contacts as array.
\r
476 * gid: optional, if not given, API returns all groups of the user
\r
481 * name: name of the group
\r
482 * gid: id of the group
\r
483 * user: array of group members (return from api_get_user() function for each member)
\r
487 ### friendica/group_delete (POST,DELETE; AUTH)
\r
488 delete the specified group of contacts; API call need to include the correct gid AND name of the group to be deleted.
\r
491 * gid: id of the group to be deleted
\r
492 * name: name of the group to be deleted
\r
497 * success: true if successfully deleted
\r
498 * gid: gid of the deleted group
\r
499 * name: name of the deleted group
\r
500 * status: „deleted“ if successfully deleted
\r
501 * wrong users: empty array
\r
505 ### friendica/group_create (POST,PUT; AUTH)
\r
506 Create the group with the posted array of contacts as members.
\r
509 * name: name of the group to be created
\r
512 JSON data as Array like the result of "users/group_show":
\r
521 * success: true if successfully created or reactivated
\r
522 * gid: gid of the created group
\r
523 * name: name of the created group
\r
524 * status: „missing user“ | „reactivated“ | „ok“
\r
525 * wrong users: array of users, which were not available in the contact table
\r
529 ### friendica/group_update (POST)
\r
530 Update the group with the posted array of contacts as members (post all members of the group to the call; function will remove members not posted).
\r
533 * gid: id of the group to be changed
\r
534 * name: name of the group to be changed
\r
537 JSON data as array like the result of „users/group_show“:
\r
546 * success: true if successfully updated
\r
547 * gid: gid of the changed group
\r
548 * name: name of the changed group
\r
549 * status: „missing user“ | „ok“
\r
550 * wrong users: array of users, which were not available in the contact table
\r
555 ### friendica/notifications (GET)
\r
556 Return last 50 notification for current user, ordered by date with unseen item on top
\r
564 * id: id of the note
\r
565 * type: type of notification as int (see NOTIFY_* constants in boot.php)
\r
566 * name: full name of the contact subject of the note
\r
567 * url: contact's profile url
\r
568 * photo: contact's profile photo
\r
569 * date: datetime string of the note
\r
570 * timestamp: timestamp of the node
\r
571 * date_rel: relative date of the note (eg. "1 hour ago")
\r
572 * msg: note message in bbcode
\r
573 * msg_html: note message in html
\r
574 * msg_plain: note message in plain text
\r
575 * link: link to note
\r
576 * seen: seen state: 0 or 1
\r
580 ### friendica/notifications/seen (POST)
\r
581 Set note as seen, returns item object if possible
\r
584 id: id of the note to set seen
\r
587 If the note is linked to an item, the item is returned, just like one of the "statuses/*_timeline" api.
\r
589 If the note is not linked to an item, a success status is returned:
\r
591 * "success" (json) | "<status>success</status>" (xml)
\r
595 ### friendica/photo (*; AUTH)
\r
597 * photo_id: Resource id of a photo.
\r
598 * scale: (optional) scale value of the photo
\r
600 Returns data of a picture with the given resource.
\r
601 If 'scale' isn't provided, returned data include full url to each scale of the photo.
\r
602 If 'scale' is set, returned data include image data base64 encoded.
\r
604 possibile scale value are:
\r
606 * 0: original or max size by server settings
\r
607 * 1: image with or height at <= 640
\r
608 * 2: image with or height at <= 320
\r
609 * 3: thumbnail 160x160
\r
610 * 4: Profile image at 175x175
\r
611 * 5: Profile image at 80x80
\r
612 * 6: Profile image at 48x48
\r
614 An image used as profile image has only scale 4-6, other images only 0-3
\r
622 "created": "date(YYYY-MM-GG HH:MM:SS)",
\r
623 "edited": "date(YYYY-MM-GG HH:MM:SS)",
\r
624 "title": "photo title",
\r
625 "desc": "photo description",
\r
626 "album": "album name",
\r
627 "filename": "original file name",
\r
628 "type": "mime type",
\r
629 "height": "number",
\r
631 "profile": "1 if is profile photo",
\r
633 "<scale>": "url to image"
\r
636 // if 'scale' is set
\r
637 "datasize": "size in byte",
\r
638 "data": "base64 encoded image data"
\r
646 <created>date(YYYY-MM-GG HH:MM:SS)</created>
\r
647 <edited>date(YYYY-MM-GG HH:MM:SS)</edited>
\r
648 <title>photo title</title>
\r
649 <desc>photo description</desc>
\r
650 <album>album name</album>
\r
651 <filename>original file name</filename>
\r
652 <type>mime type</type>
\r
653 <height>number</height>
\r
654 <width>number</width>
\r
655 <profile>1 if is profile photo</profile>
\r
656 <links type="array">
\r
657 <link type="mime type" scale="scale number" href="image url"/>
\r
664 ### friendica/photos/list (*; AUTH)
\r
666 Returns a list of all photo resources of the logged in user.
\r
675 album: "album name",
\r
676 filename: "original file name",
\r
677 type: "image mime type",
\r
678 thumb: "url to thumb sized image"
\r
686 <photos type="array">
\r
687 <photo id="resource_id"
\r
689 filename="original file name"
\r
690 type="image mime type">
\r
691 "url to thumb sized image"
\r
699 ## Not Implemented API calls
\r
700 The following API calls are implemented in GNU Social but not in Friendica: (incomplete)
\r
702 * statuses/retweets_of_me
\r
703 * friendships/create
\r
704 * friendships/destroy
\r
705 * friendships/exists
\r
707 * account/update_profile_background_image
\r
708 * account/update_profile_image
\r
712 The following API calls from the Twitter API aren't implemented neither in Friendica nor in GNU Social:
\r
714 * statuses/mentions_timeline
\r
715 * statuses/retweets/:id
\r
717 * statuses/retweeters/ids
\r
719 * direct_messages/show
\r
721 * direct_messages/destroy
\r
722 * friendships/no_retweets/ids
\r
723 * friendships/incoming
\r
724 * friendships/outgoing
\r
725 * friendships/update
\r
727 * friendships/lookup
\r
729 * account/update_delivery_device
\r
730 * account/update_profile
\r
731 * account/update_profile_background_image
\r
732 * account/update_profile_image
\r
738 * account/remove_profile_banner
\r
739 * account/update_profile_banner
\r
740 * users/profile_banner
\r
741 * mutes/users/create
\r
742 * mutes/users/destroy
\r
745 * users/suggestions/:slug
\r
746 * users/suggestions
\r
747 * users/suggestions/:slug/members
\r
751 * lists/members/destroy
\r
752 * lists/memberships
\r
753 * lists/subscribers
\r
754 * lists/subscribers/create
\r
755 * lists/subscribers/show
\r
756 * lists/subscribers/destroy
\r
757 * lists/members/create_all
\r
758 * lists/members/show
\r
760 * lists/members/create
\r
765 * lists/subscriptions
\r
766 * lists/members/destroy_all
\r
768 * saved_searches/list
\r
769 * saved_searches/show/:id
\r
770 * saved_searches/create
\r
771 * saved_searches/destroy/:id
\r
773 * geo/reverse_geocode
\r
778 * help/configuration
\r
783 * users/report_spam
\r
791 Betamax has documentated some example API usage from a [bash script](https://en.wikipedia.org/wiki/Bash_(Unix_shell) employing [curl](https://en.wikipedia.org/wiki/CURL) (see [his posting](https://betamax65.de/display/betamax65/43539)).
\r
793 /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"
\r
796 The [RSStoFriedika](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.
\r
798 def tweet(server, message, group_allow=None):
\r
799 url = server + '/api/statuses/update'
\r
800 urllib2.urlopen(url, urllib.urlencode({'status': message,'group_allow[]':group_allow}, doseq=True))
\r
802 There is also a [module for python 3](https://bitbucket.org/tobiasd/python-friendica) for using the API.
\r