6 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
8 Please refer to the linked documentation for further information.
\r
10 ## Implemented API calls
\r
15 API endpoints can restrict the method used to request them.
\r
16 Using an invalid method results in HTTP error 405 "Method Not Allowed".
\r
18 In this document, the required method is listed after the endpoint name. "*" means every method can be used.
\r
22 Friendica supports basic http auth and OAuth 1 to authenticate the user to the api.
\r
24 OAuth settings can be added by the user in web UI under /settings/oauth/
\r
26 In this document, endpoints which requires auth are marked with "AUTH" after endpoint name
\r
28 #### Unsupported parameters
\r
29 * cursor: Not implemented in GNU Social
\r
30 * trim_user: Not implemented in GNU Social
\r
31 * contributor_details: Not implemented in GNU Social
\r
32 * place_id: Not implemented in GNU Social
\r
33 * display_coordinates: Not implemented in GNU Social
\r
34 * include_rts: To-Do
\r
35 * include_my_retweet: Retweets in Friendica are implemented in a different way
\r
37 #### Different behaviour
\r
38 * 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
39 * include_entities: Default is "false". If set to "true" then the plain text is formatted so that links are having descriptions.
\r
42 * cid: Contact id of the user (important for "contact_allow" and "contact_deny")
\r
43 * network: network of the user
\r
46 When an error occour in API call, an HTTP error code is returned, with an error message
\r
48 - 400 Bad Request: if parameter are missing or items can't be found
\r
49 - 403 Forbidden: if authenticated user is missing
\r
50 - 405 Method Not Allowed: if API was called with invalid method, eg. GET when API require POST
\r
51 - 501 Not Implemented: if requested API doesn't exists
\r
52 - 500 Internal Server Error: on other error contitions
\r
59 "error": "Specific error message",
\r
60 "request": "API path requested",
\r
61 "code": "HTTP error code"
\r
68 <error>Specific error message</error>
\r
69 <request>API path requested</request>
\r
70 <code>HTTP error code</code>
\r
75 ### account/rate_limit_status (*; AUTH)
\r
78 ### account/verify_credentials (*; AUTH)
\r
81 * skip_status: Don't show the "status" field. (Default: false)
\r
82 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
85 ### conversation/show (*; AUTH)
\r
86 Unofficial Twitter command. It shows all direct answers (excluding the original post) to a given id.
\r
89 * id: id of the post
\r
90 * count: Items per page (default: 20)
\r
92 * since_id: minimal id
\r
93 * max_id: maximum id
\r
94 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
96 #### Unsupported parameters
\r
99 * contributor_details
\r
102 ### direct_messages (*; AUTH)
\r
104 * count: Items per page (default: 20)
\r
105 * page: page number
\r
106 * since_id: minimal id
\r
107 * max_id: maximum id
\r
108 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
109 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
110 * friendica_verbose: "true" enables different error returns (default: "false")
\r
112 #### Unsupported parameters
\r
116 ### direct_messages/all (*; AUTH)
\r
118 * count: Items per page (default: 20)
\r
119 * page: page number
\r
120 * since_id: minimal id
\r
121 * max_id: maximum id
\r
122 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
123 * friendica_verbose: "true" enables different error returns (default: "false")
\r
126 ### direct_messages/conversation (*; AUTH)
\r
127 Shows all direct messages of a conversation
\r
129 * count: Items per page (default: 20)
\r
130 * page: page number
\r
131 * since_id: minimal id
\r
132 * max_id: maximum id
\r
133 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
134 * uri: URI of the conversation
\r
135 * friendica_verbose: "true" enables different error returns (default: "false")
\r
138 ### direct_messages/sent (*; AUTH)
\r
140 * count: Items per page (default: 20)
\r
141 * page: page number
\r
142 * since_id: minimal id
\r
143 * max_id: maximum id
\r
144 * getText: Defines the format of the status field. Can be "html" or "plain"
\r
145 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
146 * friendica_verbose: "true" enables different error returns (default: "false")
\r
149 ### direct_messages/new (POST,PUT; AUTH)
\r
151 * user_id: id of the user
\r
152 * screen_name: screen name (for technical reasons, this value is not unique!)
\r
153 * text: The message
\r
154 * replyto: ID of the replied direct message
\r
155 * title: Title of the direct message
\r
158 ### direct_messages/destroy (POST,DELETE; AUTH)
\r
160 * id: id of the message to be deleted
\r
161 * include_entities: optional, currently not yet implemented
\r
162 * friendica_parenturi: optional, can be used for increased safety to delete only intended messages
\r
163 * friendica_verbose: "true" enables different error returns (default: "false")
\r
168 * JSON return as defined for Twitter API not yet implemented
\r
169 * on friendica_verbose=true: JSON return {"result":"ok","message":"message deleted"}
\r
172 HTTP 400 BadRequest
\r
173 * on friendica_verbose=true: different JSON returns {"result":"error","message":"xyz"}
\r
176 ### favorites (*; AUTH)
\r
178 * count: Items per page (default: 20)
\r
179 * page: page number
\r
180 * since_id: minimal id
\r
181 * max_id: maximum id
\r
182 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
184 #### Unsupported parameters
\r
188 Favorites aren't displayed to other users, so "user_id" and "screen_name" are unsupported.
\r
189 Set this values will result in an empty array.
\r
192 ### favorites/create (POST,PUT; AUTH)
\r
195 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
198 ### favorites/destroy (POST,DELETE; AUTH)
\r
201 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
204 ### followers/ids (*; AUTH)
\r
206 * stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)
\r
208 #### Unsupported parameters
\r
213 Friendica doesn't allow showing followers of other users.
\r
216 ### friends/ids (*; AUTH)
\r
218 * stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)
\r
220 #### Unsupported parameters
\r
225 Friendica doesn't allow showing friends of other users.
\r
231 ### media/upload (POST,PUT; AUTH)
\r
233 * media: image data
\r
236 ### oauth/request_token (*)
\r
240 #### Unsupported parameters
\r
241 * x_auth_access_type
\r
244 ### oauth/access_token (*)
\r
248 #### Unsupported parameters
\r
254 ### statuses/destroy (POST,DELETE; AUTH)
\r
256 * id: message number
\r
257 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
259 #### Unsupported parameters
\r
263 ### statuses/followers (*; AUTH)
\r
267 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
270 ### statuses/friends (*; AUTH)
\r
274 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
277 ### statuses/friends_timeline (*; AUTH)
\r
279 * count: Items per page (default: 20)
\r
280 * page: page number
\r
281 * since_id: minimal id
\r
282 * max_id: maximum id
\r
283 * exclude_replies: don't show replies (default: false)
\r
284 * conversation_id: Shows all statuses of a given conversation.
\r
285 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
287 #### Unsupported parameters
\r
290 * contributor_details
\r
293 ### statuses/home_timeline (*; AUTH)
\r
295 * count: Items per page (default: 20)
\r
296 * page: page number
\r
297 * since_id: minimal id
\r
298 * max_id: maximum id
\r
299 * exclude_replies: don't show replies (default: false)
\r
300 * conversation_id: Shows all statuses of a given conversation.
\r
301 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
303 #### Unsupported parameters
\r
306 * contributor_details
\r
309 ### statuses/mentions (*; AUTH)
\r
311 * count: Items per page (default: 20)
\r
312 * page: page number
\r
313 * since_id: minimal id
\r
314 * max_id: maximum id
\r
315 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
317 #### Unsupported parameters
\r
320 * contributor_details
\r
323 ### statuses/public_timeline (*; AUTH)
\r
325 * count: Items per page (default: 20)
\r
326 * page: page number
\r
327 * since_id: minimal id
\r
328 * max_id: maximum id
\r
329 * exclude_replies: don't show replies (default: false)
\r
330 * conversation_id: Shows all statuses of a given conversation.
\r
331 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
333 #### Unsupported parameters
\r
337 ### statuses/replies (*; AUTH)
\r
339 * count: Items per page (default: 20)
\r
340 * page: page number
\r
341 * since_id: minimal id
\r
342 * max_id: maximum id
\r
343 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
345 #### Unsupported parameters
\r
348 * contributor_details
\r
351 ### statuses/retweet (POST,PUT; AUTH)
\r
353 * id: message number
\r
354 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
356 #### Unsupported parameters
\r
360 ### statuses/show (*; AUTH)
\r
362 * id: message number
\r
363 * conversation: if set to "1" show all messages of the conversation with the given id
\r
364 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
366 #### Unsupported parameters
\r
367 * include_my_retweet
\r
371 ### statuses/update, statuses/update_with_media
\r
373 * title: Title of the status
\r
374 * status: Status in text format
\r
375 * htmlstatus: Status in HTML format
\r
376 * in_reply_to_status_id
\r
379 * media: image data
\r
380 * source: Application name
\r
386 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
387 * media_ids: (By now only a single value, no array)
\r
389 #### Unsupported parameters
\r
392 * display_coordinates
\r
395 ### statuses/user_timeline (*; AUTH)
\r
397 * user_id: id of the user
\r
398 * screen_name: screen name (for technical reasons, this value is not unique!)
\r
399 * count: Items per page (default: 20)
\r
400 * page: page number
\r
401 * since_id: minimal id
\r
402 * max_id: maximum id
\r
403 * exclude_replies: don't show replies (default: false)
\r
404 * conversation_id: Shows all statuses of a given conversation.
\r
405 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
407 #### Unsupported parameters
\r
411 * contributor_details
\r
414 ### statusnet/config (*)
\r
417 ### statusnet/conversation (*; AUTH)
\r
418 It shows all direct answers (excluding the original post) to a given id.
\r
421 * id: id of the post
\r
422 * count: Items per page (default: 20)
\r
423 * page: page number
\r
424 * since_id: minimal id
\r
425 * max_id: maximum id
\r
426 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
429 ### statusnet/version (*)
\r
431 #### Unsupported parameters
\r
436 Friendica doesn't allow showing followers of other users.
\r
439 ### users/search (*)
\r
441 * q: name of the user
\r
443 #### Unsupported parameters
\r
451 * user_id: id of the user
\r
452 * screen_name: screen name (for technical reasons, this value is not unique!)
\r
453 * include_entities: "true" shows entities for pictures and links (Default: false)
\r
455 #### Unsupported parameters
\r
460 Friendica doesn't allow showing friends of other users.
\r
463 ## Implemented API calls (not compatible with other APIs)
\r
467 ### friendica/activity/<verb>
\r
471 Add or remove an activity from an item.
\r
472 'verb' can be one of:
\r
480 To remove an activity, prepend the verb with "un", eg. "unlike" or "undislike"
\r
481 Attend verbs disable eachother: that means that if "attendyes" was added to an item, adding "attendno" remove previous "attendyes".
\r
482 Attend verbs should be used only with event-related items (there is no check at the moment)
\r
491 ```<ok>true</ok>```
\r
494 HTTP 400 BadRequest
\r
497 ### friendica/group_show (*; AUTH)
\r
498 Return all or a specified group of the user with the containing contacts as array.
\r
501 * gid: optional, if not given, API returns all groups of the user
\r
506 * name: name of the group
\r
507 * gid: id of the group
\r
508 * user: array of group members (return from api_get_user() function for each member)
\r
512 ### friendica/group_delete (POST,DELETE; AUTH)
\r
513 delete the specified group of contacts; API call need to include the correct gid AND name of the group to be deleted.
\r
516 * gid: id of the group to be deleted
\r
517 * name: name of the group to be deleted
\r
522 * success: true if successfully deleted
\r
523 * gid: gid of the deleted group
\r
524 * name: name of the deleted group
\r
525 * status: „deleted“ if successfully deleted
\r
526 * wrong users: empty array
\r
530 ### friendica/group_create (POST,PUT; AUTH)
\r
531 Create the group with the posted array of contacts as members.
\r
534 * name: name of the group to be created
\r
537 JSON data as Array like the result of "users/group_show":
\r
546 * success: true if successfully created or reactivated
\r
547 * gid: gid of the created group
\r
548 * name: name of the created group
\r
549 * status: „missing user“ | „reactivated“ | „ok“
\r
550 * wrong users: array of users, which were not available in the contact table
\r
554 ### friendica/group_update (POST)
\r
555 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
558 * gid: id of the group to be changed
\r
559 * name: name of the group to be changed
\r
562 JSON data as array like the result of „users/group_show“:
\r
571 * success: true if successfully updated
\r
572 * gid: gid of the changed group
\r
573 * name: name of the changed group
\r
574 * status: „missing user“ | „ok“
\r
575 * wrong users: array of users, which were not available in the contact table
\r
580 ### friendica/notifications (GET)
\r
581 Return last 50 notification for current user, ordered by date with unseen item on top
\r
589 * id: id of the note
\r
590 * type: type of notification as int (see NOTIFY_* constants in boot.php)
\r
591 * name: full name of the contact subject of the note
\r
592 * url: contact's profile url
\r
593 * photo: contact's profile photo
\r
594 * date: datetime string of the note
\r
595 * timestamp: timestamp of the node
\r
596 * date_rel: relative date of the note (eg. "1 hour ago")
\r
597 * msg: note message in bbcode
\r
598 * msg_html: note message in html
\r
599 * msg_plain: note message in plain text
\r
600 * link: link to note
\r
601 * seen: seen state: 0 or 1
\r
605 ### friendica/notifications/seen (POST)
\r
606 Set note as seen, returns item object if possible
\r
609 id: id of the note to set seen
\r
612 If the note is linked to an item, the item is returned, just like one of the "statuses/*_timeline" api.
\r
614 If the note is not linked to an item, a success status is returned:
\r
616 * "success" (json) | "<status>success</status>" (xml)
\r
620 ### friendica/photo (*; AUTH)
\r
622 * photo_id: Resource id of a photo.
\r
623 * scale: (optional) scale value of the photo
\r
625 Returns data of a picture with the given resource.
\r
626 If 'scale' isn't provided, returned data include full url to each scale of the photo.
\r
627 If 'scale' is set, returned data include image data base64 encoded.
\r
629 possibile scale value are:
\r
631 * 0: original or max size by server settings
\r
632 * 1: image with or height at <= 640
\r
633 * 2: image with or height at <= 320
\r
634 * 3: thumbnail 160x160
\r
635 * 4: Profile image at 175x175
\r
636 * 5: Profile image at 80x80
\r
637 * 6: Profile image at 48x48
\r
639 An image used as profile image has only scale 4-6, other images only 0-3
\r
647 "created": "date(YYYY-MM-GG HH:MM:SS)",
\r
648 "edited": "date(YYYY-MM-GG HH:MM:SS)",
\r
649 "title": "photo title",
\r
650 "desc": "photo description",
\r
651 "album": "album name",
\r
652 "filename": "original file name",
\r
653 "type": "mime type",
\r
654 "height": "number",
\r
656 "profile": "1 if is profile photo",
\r
658 "<scale>": "url to image"
\r
661 // if 'scale' is set
\r
662 "datasize": "size in byte",
\r
663 "data": "base64 encoded image data"
\r
671 <created>date(YYYY-MM-GG HH:MM:SS)</created>
\r
672 <edited>date(YYYY-MM-GG HH:MM:SS)</edited>
\r
673 <title>photo title</title>
\r
674 <desc>photo description</desc>
\r
675 <album>album name</album>
\r
676 <filename>original file name</filename>
\r
677 <type>mime type</type>
\r
678 <height>number</height>
\r
679 <width>number</width>
\r
680 <profile>1 if is profile photo</profile>
\r
681 <links type="array">
\r
682 <link type="mime type" scale="scale number" href="image url"/>
\r
689 ### friendica/photos/list (*; AUTH)
\r
691 Returns a list of all photo resources of the logged in user.
\r
700 album: "album name",
\r
701 filename: "original file name",
\r
702 type: "image mime type",
\r
703 thumb: "url to thumb sized image"
\r
711 <photos type="array">
\r
712 <photo id="resource_id"
\r
714 filename="original file name"
\r
715 type="image mime type">
\r
716 "url to thumb sized image"
\r
723 ### friendica/direct_messages_setseen (GET; AUTH)
\r
725 * id: id of the message to be updated as seen
\r
730 * JSON return {"result":"ok","message":"message set to seen"}
\r
733 * different JSON returns {"result":"error","message":"xyz"}
\r
736 ### friendica/direct_messages_search (GET; AUTH)
\r
738 * searchstring: string for which the API call should search as '%searchstring%' in field 'body' of all messages of the authenticated user (caption ignored)
\r
741 Returns only tested with JSON, XML might work as well.
\r
744 * JSON return {"success":"true","search_results": array of found messages}
\r
745 * JSOn return {"success":"false","search_results":"nothing found"}
\r
748 * different JSON returns {"result":"error","message":"searchstring not specified"}
\r
751 ### friendica/profile/show (GET; AUTH)
\r
752 show data of all profiles or a single profile of the authenticated user
\r
755 * profile_id: id of the profile to be returned (optional, if omitted all profiles are returned by default)
\r
758 On success: Array of:
\r
760 * multi_profiles: true if user has activated multi_profiles
\r
761 * global_dir: URL of the global directory set in server settings
\r
762 * friendica_owner: user data of the authenticated user
\r
763 * profiles: array of the profile data
\r
766 HTTP 403 Forbidden: when no authentication provided
\r
767 HTTP 400 Bad Request: if given profile_id is not in db or not assigned to authenticated user
\r
769 General description of profile data in API returns:
\r
772 * is_default: true if this is the public profile
\r
773 * hide_friends: true if friends are hidden
\r
776 * publish: true if published on the server's local directory
\r
777 * net_publish: true if published to global_dir
\r
778 * description ... homepage: different data fields from 'profile' table in database
\r
779 * users: array with the users allowed to view this profile (empty if is_default=true)
\r
783 ## Not Implemented API calls
\r
784 The following API calls are implemented in GNU Social but not in Friendica: (incomplete)
\r
786 * statuses/retweets_of_me
\r
787 * friendships/create
\r
788 * friendships/destroy
\r
789 * friendships/exists
\r
791 * account/update_profile_background_image
\r
792 * account/update_profile_image
\r
796 The following API calls from the Twitter API aren't implemented neither in Friendica nor in GNU Social:
\r
798 * statuses/mentions_timeline
\r
799 * statuses/retweets/:id
\r
801 * statuses/retweeters/ids
\r
803 * direct_messages/show
\r
805 * friendships/no_retweets/ids
\r
806 * friendships/incoming
\r
807 * friendships/outgoing
\r
808 * friendships/update
\r
810 * friendships/lookup
\r
812 * account/update_delivery_device
\r
813 * account/update_profile
\r
814 * account/update_profile_background_image
\r
815 * account/update_profile_image
\r
821 * account/remove_profile_banner
\r
822 * account/update_profile_banner
\r
823 * users/profile_banner
\r
824 * mutes/users/create
\r
825 * mutes/users/destroy
\r
828 * users/suggestions/:slug
\r
829 * users/suggestions
\r
830 * users/suggestions/:slug/members
\r
834 * lists/members/destroy
\r
835 * lists/memberships
\r
836 * lists/subscribers
\r
837 * lists/subscribers/create
\r
838 * lists/subscribers/show
\r
839 * lists/subscribers/destroy
\r
840 * lists/members/create_all
\r
841 * lists/members/show
\r
843 * lists/members/create
\r
848 * lists/subscriptions
\r
849 * lists/members/destroy_all
\r
851 * saved_searches/list
\r
852 * saved_searches/show/:id
\r
853 * saved_searches/create
\r
854 * saved_searches/destroy/:id
\r
856 * geo/reverse_geocode
\r
861 * help/configuration
\r
866 * users/report_spam
\r
874 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
876 /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
879 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
881 def tweet(server, message, group_allow=None):
\r
882 url = server + '/api/statuses/update'
\r
883 urllib2.urlopen(url, urllib.urlencode({'status': message,'group_allow[]':group_allow}, doseq=True))
\r
885 There is also a [module for python 3](https://bitbucket.org/tobiasd/python-friendica) for using the API.
\r