3 <!-- markdownlint-disable MD010 MD013 MD024 -->
7 The Friendica API aims to be compatible with the [GNU Social API](http://wiki.gnusocial.de/gnusocial:api) and the [Twitter API](https://dev.twitter.com/rest/public).
9 Please refer to the linked documentation for further information.
11 ## Implemented API calls
17 API endpoints can restrict the method used to request them.
18 Using an invalid method results in HTTP error 405 "Method Not Allowed".
20 In this document, the required method is listed after the endpoint name. "*" means every method can be used.
24 Friendica supports basic http auth and OAuth 1 to authenticate the user to the api.
26 OAuth settings can be added by the user in web UI under /settings/oauth/
28 In this document, endpoints which requires auth are marked with "AUTH" after endpoint name
30 #### Unsupported parameters
32 * cursor: Not implemented in GNU Social
33 * trim_user: Not implemented in GNU Social
34 * contributor_details: Not implemented in GNU Social
35 * place_id: Not implemented in GNU Social
36 * display_coordinates: Not implemented in GNU Social
38 * include_my_retweet: Retweets in Friendica are implemented in a different way
40 #### Different behaviour
42 * 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.
43 * include_entities: Default is "false". If set to "true" then the plain text is formatted so that links are having descriptions.
47 * cid: Contact id of the user (important for "contact_allow" and "contact_deny")
48 * network: network of the user
52 When an error occurs in API call, an HTTP error code is returned, with an error message
55 * 400 Bad Request: if parameters are missing or items can't be found
56 * 403 Forbidden: if the authenticated user is missing
57 * 405 Method Not Allowed: if API was called with an invalid method, eg. GET when API require POST
58 * 501 Not Implemented: if the requested API doesn't exist
59 * 500 Internal Server Error: on other error conditions
67 "error": "Specific error message",
68 "request": "API path requested",
69 "code": "HTTP error code"
77 <error>Specific error message</error>
78 <request>API path requested</request>
79 <code>HTTP error code</code>
85 ### account/rate_limit_status (*; AUTH)
89 ### account/verify_credentials (*; AUTH)
93 * skip_status: Don't show the "status" field. (Default: false)
94 * include_entities: "true" shows entities for pictures and links (Default: false)
98 ### conversation/show (*; AUTH)
100 Unofficial Twitter command. It shows all direct answers (excluding the original post) to a given id.
105 * count: Items per page (default: 20)
107 * since_id: minimum id
109 * include_entities: "true" shows entities for pictures and links (Default: false)
111 #### Unsupported parameters
115 * contributor_details
119 ### direct_messages (*; AUTH)
123 * count: Items per page (default: 20)
125 * since_id: minimum id
127 * getText: Defines the format of the status field. Can be "html" or "plain"
128 * include_entities: "true" shows entities for pictures and links (Default: false)
129 * friendica_verbose: "true" enables different error returns (default: "false")
131 #### Unsupported parameters
137 ### direct_messages/all (*; AUTH)
141 * count: Items per page (default: 20)
143 * since_id: minimum id
145 * getText: Defines the format of the status field. Can be "html" or "plain"
146 * friendica_verbose: "true" enables different error returns (default: "false")
150 ### direct_messages/conversation (*; AUTH)
152 Shows all direct messages of a conversation
156 * count: Items per page (default: 20)
158 * since_id: minimum id
160 * getText: Defines the format of the status field. Can be "html" or "plain"
161 * uri: URI of the conversation
162 * friendica_verbose: "true" enables different error returns (default: "false")
166 ### direct_messages/sent (*; AUTH)
170 * count: Items per page (default: 20)
172 * since_id: minimum id
174 * getText: Defines the format of the status field. Can be "html" or "plain"
175 * include_entities: "true" shows entities for pictures and links (Default: false)
176 * friendica_verbose: "true" enables different error returns (default: "false")
180 ### direct_messages/new (POST,PUT; AUTH)
184 * user_id: id of the user
185 * screen_name: screen name (for technical reasons, this value is not unique!)
187 * replyto: ID of the replied direct message
188 * title: Title of the direct message
192 ### direct_messages/destroy (POST,DELETE; AUTH)
196 * id: id of the message to be deleted
197 * include_entities: optional, currently not yet implemented
198 * friendica_parenturi: optional, can be used for increased safety to delete only intended messages
199 * friendica_verbose: "true" enables different error returns (default: "false")
205 * JSON return as defined for Twitter API not yet implemented
206 * on friendica_verbose=true: JSON return {"result":"ok","message":"message deleted"}
211 * on friendica_verbose=true: different JSON returns {"result":"error","message":"xyz"}
215 ### externalprofile/show (*)
219 * profileurl: profile url
223 ### favorites (*; AUTH)
227 * count: Items per page (default: 20)
229 * since_id: minimum id
231 * include_entities: "true" shows entities for pictures and links (Default: false)
233 #### Unsupported parameters
238 Favorites aren't displayed to other users, so "user_id" and "screen_name" are unsupported.
239 Set this values will result in an empty array.
243 ### favorites/create (POST,PUT; AUTH)
248 * include_entities: "true" shows entities for pictures and links (Default: false)
252 ### favorites/destroy (POST,DELETE; AUTH)
257 * include_entities: "true" shows entities for pictures and links (Default: false)
261 ### followers/ids (*; AUTH)
265 * stringify_ids: Send id numbers as text (true) or integers (false)? (default: false)
267 #### Unsupported parameters
273 Friendica doesn't allow showing the followers of other users.
277 ### friends/ids (*; AUTH)
281 * stringify_ids: Send the id numbers as text (true) or integers (false)? (default: false)
283 #### Unsupported parameters
289 Friendica doesn't allow showing the friends of other users.
297 ### media/upload (POST,PUT; AUTH)
305 ### oauth/request_token (*)
311 #### Unsupported parameters
317 ### oauth/access_token (*)
323 #### Unsupported parameters
331 ### statuses/destroy (POST,DELETE; AUTH)
336 * include_entities: "true" shows entities for pictures and links (Default: false)
338 #### Unsupported parameters
344 ### statuses/followers (*; AUTH)
348 * include_entities: "true" shows entities for pictures and links (Default: false)
352 ### statuses/friends (*; AUTH)
356 * include_entities: "true" shows entities for pictures and links (Default: false)
360 ### blocks/list (*; AUTH)
364 * include_entities: "true" shows entities for pictures and links (Default: false)
365 * count: Items per page (default: 20).
368 #### Unsupported parameters
375 ### statuses/friends_timeline (*; AUTH)
379 * count: Items per page (default: 20)
381 * since_id: minimum id
383 * exclude_replies: don't show replies (default: false)
384 * conversation_id: Shows all statuses of a given conversation.
385 * include_entities: "true" shows entities for pictures and links (Default: false)
387 #### Unsupported parameters
391 * contributor_details
395 ### statuses/home_timeline (*; AUTH)
399 * count: Items per page (default: 20)
401 * since_id: minimum id
403 * exclude_replies: don't show replies (default: false)
404 * conversation_id: Shows all statuses of a given conversation.
405 * include_entities: "true" shows entities for pictures and links (Default: false)
407 #### Unsupported parameters
411 * contributor_details
415 ### statuses/mentions (*; AUTH)
419 * count: Items per page (default: 20)
421 * since_id: minimum id
423 * include_entities: "true" shows entities for pictures and links (Default: false)
425 #### Unsupported parameters
429 * contributor_details
433 ### statuses/public_timeline (*; AUTH)
437 * count: Items per page (default: 20)
439 * since_id: minimum id
441 * exclude_replies: don't show replies (default: false)
442 * conversation_id: Shows all statuses of a given conversation.
443 * include_entities: "true" shows entities for pictures and links (Default: false)
445 #### Unsupported parameters
451 ### statuses/networkpublic_timeline (*; AUTH)
455 * count: Items per page (default: 20)
457 * since_id: minimum id
459 * include_entities: "true" shows entities for pictures and links (Default: false)
463 ### statuses/replies (*; AUTH)
467 * count: Items per page (default: 20)
469 * since_id: minimum id
471 * include_entities: "true" shows entities for pictures and links (Default: false)
473 #### Unsupported parameters
477 * contributor_details
481 ### statuses/retweet (POST,PUT; AUTH)
486 * include_entities: "true" shows entities for pictures and links (Default: false)
488 #### Unsupported parameters
494 ### statuses/show (*; AUTH)
499 * conversation: if set to "1" show all messages of the conversation with the given id
500 * include_entities: "true" shows entities for pictures and links (Default: false)
502 #### Unsupported parameters
509 ### statuses/update, statuses/update_with_media
513 * title: Title of the status
514 * status: Status in text format
515 * htmlstatus: Status in HTML format
516 * in_reply_to_status_id
520 * source: Application name
526 * include_entities: "true" shows entities for pictures and links (Default: false)
527 * media_ids: (By now only a single value, no array)
529 #### Unsupported parameters
533 * display_coordinates
537 ### statuses/user_timeline (*; AUTH)
541 * user_id: id of the user
542 * screen_name: screen name (for technical reasons, this value is not unique!)
543 * count: Items per page (default: 20)
545 * since_id: minimum id
547 * exclude_replies: don't show replies (default: false)
548 * conversation_id: Shows all statuses of a given conversation.
549 * include_entities: "true" shows entities for pictures and links (Default: false)
551 #### Unsupported parameters
555 * contributor_details
559 ### statusnet/config (*)
563 ### statusnet/conversation (*; AUTH)
565 It shows all direct answers (excluding the original post) to a given id.
570 * count: Items per page (default: 20)
572 * since_id: minimum id
574 * include_entities: "true" shows entities for pictures and links (Default: false)
578 ### statusnet/version (*)
580 #### Unsupported parameters
586 Friendica doesn't allow showing followers of other users.
595 * page: the page number (starting at 1) to return
596 * rpp: the number of statuses to return per page
597 * count: alias for the rpp parameter
598 * since_id: returns statuses with ids greater than the given id
599 * max_id: returns statuses with ids lower or equal to the given id
601 #### Unsupported parameters
612 ### search/tweets (*; AUTH)
614 This is an alias for `search`.
622 * q: name of the user
624 #### Unsupported parameters
636 * user_id: id of the user
637 * screen_name: screen name (for technical reasons, this value is not unique!)
638 * include_entities: "true" shows entities for pictures and links (Default: false)
640 #### Unsupported parameters
646 Friendica doesn't allow showing friends of other users.
650 ### users/lookup (*; AUTH)
654 * user_id: list of ids to lookup
656 #### Unsupported parameters
663 ### account/update_profile_image (POST; AUTH)
667 * image: image data as base64 (Twitter has a limit of 700kb, Friendica allows more)
668 * profile_id (optional): id of the profile for which the image should be used, default is changing the default profile
670 uploads a new profile image (scales 4-6) to database, changes default or specified profile to the new photo
676 * JSON return: returns the updated user details (see account/verify_credentials)
680 * 403 FORBIDDEN: if not authenticated
681 * 400 BADREQUEST: "no media data submitted", "profile_id not available"
682 * 500 INTERNALSERVERERROR: "image size exceeds PHP config settings, file was rejected by server",
683 "image size exceeds Friendica Config setting (uploaded size: x)",
684 "unable to process image data",
685 "image upload failed"
689 ### friendships/incoming (*; AUTH)
691 #### Unsupported parameters
696 ## Implemented API calls (not compatible with other APIs)
700 ### friendica/activity/[verb]
706 Add or remove an activity from an item.
707 'verb' can be one of:
715 To remove an activity, prepend the verb with "un", eg. "unlike" or "undislike"
716 Attend verbs disable eachother: that means that if "attendyes" was added to an item, adding "attendno" remove previous "attendyes".
717 Attend verbs should be used only with event-related items (there is no check at the moment)
735 ### friendica/group_show (*; AUTH)
737 Return all or a specified group of the user with the containing contacts as array.
741 * gid: optional, if not given, API returns all groups of the user
747 * name: name of the group
748 * gid: id of the group
749 * user: array of group members (return from api_get_user() function for each member)
753 ### friendica/group_delete (POST,DELETE; AUTH)
755 delete the specified group of contacts; API call need to include the correct gid AND name of the group to be deleted.
759 * gid: id of the group to be deleted
760 * name: name of the group to be deleted
766 * success: true if successfully deleted
767 * gid: gid of the deleted group
768 * name: name of the deleted group
769 * status: „deleted“ if successfully deleted
770 * wrong users: empty array
774 ### friendica/group_create (POST,PUT; AUTH)
776 Create the group with the posted array of contacts as members.
780 * name: name of the group to be created
784 JSON data as Array like the result of "users/group_show":
794 * success: true if successfully created or reactivated
795 * gid: gid of the created group
796 * name: name of the created group
797 * status: „missing user“ | „reactivated“ | „ok“
798 * wrong users: array of users, which were not available in the contact table
802 ### friendica/group_update (POST)
804 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).
808 * gid: id of the group to be changed
809 * name: name of the group to be changed
813 JSON data as array like the result of „users/group_show“:
823 * success: true if successfully updated
824 * gid: gid of the changed group
825 * name: name of the changed group
826 * status: „missing user“ | „ok“
827 * wrong users: array of users, which were not available in the contact table
831 ### friendica/notifications (GET)
833 Return last 50 notification for current user, ordered by date with unseen item on top
844 * type: type of notification as int (see NOTIFY_* constants in boot.php)
845 * name: full name of the contact subject of the note
846 * url: contact's profile url
847 * photo: contact's profile photo
848 * date: datetime string of the note
849 * timestamp: timestamp of the node
850 * date_rel: relative date of the note (eg. "1 hour ago")
851 * msg: note message in bbcode
852 * msg_html: note message in html
853 * msg_plain: note message in plain text
855 * seen: seen state: 0 or 1
859 ### friendica/notifications/seen (POST)
861 Set note as seen, returns item object if possible
865 id: id of the note to set seen
869 If the note is linked to an item, the item is returned, just like one of the "statuses/*_timeline" api.
871 If the note is not linked to an item, a success status is returned:
873 * `success` (json) | `<status>success</status>` (xml)
877 ### friendica/photo (*; AUTH)
881 * photo_id: Resource id of a photo.
882 * scale: (optional) scale value of the photo
884 Returns data of a picture with the given resource.
885 If 'scale' isn't provided, returned data include full url to each scale of the photo.
886 If 'scale' is set, returned data include image data base64 encoded.
888 possibile scale value are:
890 * 0: original or max size by server settings
891 * 1: image with or height at <= 640
892 * 2: image with or height at <= 320
893 * 3: thumbnail 160x160
894 * 4: Profile image at 175x175
895 * 5: Profile image at 80x80
896 * 6: Profile image at 48x48
898 An image used as profile image has only scale 4-6, other images only 0-3
907 "created": "date(YYYY-MM-DD HH:MM:SS)",
908 "edited": "date(YYYY-MM-DD HH:MM:SS)",
909 "title": "photo title",
910 "desc": "photo description",
911 "album": "album name",
912 "filename": "original file name",
916 "profile": "1 if is profile photo",
918 "<scale>": "url to image"
922 "datasize": "size in byte",
923 "data": "base64 encoded image data"
932 <created>date(YYYY-MM-DD HH:MM:SS)</created>
933 <edited>date(YYYY-MM-DD HH:MM:SS)</edited>
934 <title>photo title</title>
935 <desc>photo description</desc>
936 <album>album name</album>
937 <filename>original file name</filename>
938 <type>mime type</type>
939 <height>number</height>
940 <width>number</width>
941 <profile>1 if is profile photo</profile>
943 <link type="mime type" scale="scale number" href="image url"/>
951 ### friendica/photos/list (*; AUTH)
953 Returns a list of all photo resources of the logged in user.
964 filename: "original file name",
965 type: "image mime type",
966 thumb: "url to thumb sized image"
975 <photos type="array">
976 <photo id="resource_id"
978 filename="original file name"
979 type="image mime type">
980 "url to thumb sized image"
988 ### friendica/photoalbum/delete (POST,DELETE; AUTH)
992 * album: name of the album to be deleted
994 deletes all images with the specified album name, is not reversible -> ensure that client is asking user for being sure to do this
1000 * JSON return {"result":"deleted","message":"album 'xyz' with all containing photos has been deleted."}
1004 * 403 FORBIDDEN: if not authenticated
1005 * 400 BADREQUEST: "no albumname specified", "album not available"
1006 * 500 INTERNALSERVERERROR: "problem with deleting item occured", "unknown error - deleting from database failed"
1010 ### friendica/photoalbum/update (POST,PUT; AUTH)
1014 * album: name of the album to be updated
1015 * album_new: new name of the album
1017 changes the album name to album_new for all photos in album
1023 * JSON return {"result":"updated","message":"album 'abc' with all containing photos has been renamed to 'xyz'."}
1027 * 403 FORBIDDEN: if not authenticated
1028 * 400 BADREQUEST: "no albumname specified", "no new albumname specified", "album not available"
1029 * 500 INTERNALSERVERERROR: "unknown error - updating in database failed"
1033 ### friendica/photo/create (POST; AUTH)
1035 ### friendica/photo/update (POST; AUTH)
1039 * photo_id (optional): if specified the photo with this id will be updated
1040 * media (optional): image data as base64, only optional if photo_id is specified (new upload must have media)
1041 * desc (optional): description for the photo, updated when photo_id is specified
1042 * album: name of the album to be deleted (always necessary)
1043 * album_new (optional): can be used to change the album of a single photo if photo_id is specified
1044 * allow_cid/allow_gid/deny_cid/deny_gid (optional): on create: empty string or omitting = public photo, specify in format '```<x><y><z>```' for private photo;
1045 on update: keys need to be present with empty values for changing a private photo to public
1047 both calls point to one function for creating AND updating photos.
1048 Saves data for the scales 0-2 to database (see above for scale description).
1049 Call adds non-visible entries to items table to enable authenticated contacts to comment/like the photo.
1050 Client should pay attention to the fact that updated access rights are not transferred to the contacts. i.e. public photos remain publicly visible if they have been commented/liked before setting visibility back to a limited group.
1051 Currently it is best to inform user that updating rights is not the right way to do this, and offer a solution to add photo as a new photo with the new rights instead.
1057 * new photo uploaded: JSON return with photo data (see friendica/photo)
1058 * photo updated - changed photo data: JSON return with photo data (see friendica/photo)
1059 * photo updated - changed info: JSON return {"result":"updated","message":"Image id 'xyz' has been updated."}
1060 * photo updated - nothing changed: JSON return {"result":"cancelled","message":"Nothing to update for image id 'xyz'."}
1064 * 403 FORBIDDEN: if not authenticated
1065 * 400 BADREQUEST: "no albumname specified", "no media data submitted", "photo not available", "acl data invalid"
1066 * 500 INTERNALSERVERERROR: "image size exceeds PHP config settings, file was rejected by server",
1067 "image size exceeds Friendica Config setting (uploaded size: x)",
1068 "unable to process image data",
1069 "image upload failed",
1070 "unknown error - uploading photo failed, see Friendica log for more information",
1071 "unknown error - update photo entry in database failed",
1072 "unknown error - this error on uploading or updating a photo should never happen"
1076 ### friendica/photo/delete (DELETE; AUTH)
1080 * photo_id: id of the photo to be deleted
1082 deletes a single image with the specified id, is not reversible -> ensure that client is asking user for being sure to do this
1083 Sets item table entries for this photo to deleted = 1
1089 * JSON return {"result":"deleted","message":"photo with id 'xyz' has been deleted from server."}
1093 * 403 FORBIDDEN: if not authenticated
1094 * 400 BADREQUEST: "no photo_id specified", "photo not available"
1095 * 500 INTERNALSERVERERROR: "unknown error on deleting photo", "problem with deleting items occurred"
1099 ### friendica/direct_messages_setseen (GET; AUTH)
1103 * id: id of the message to be updated as seen
1109 * JSON return {"result":"ok","message":"message set to seen"}
1113 * different JSON returns {"result":"error","message":"xyz"}
1117 ### friendica/direct_messages_search (GET; AUTH)
1121 * searchstring: string for which the API call should search as '%searchstring%' in field 'body' of all messages of the authenticated user (caption ignored)
1125 Returns only tested with JSON, XML might work as well.
1129 * JSON return {"success":"true","search_results": array of found messages}
1130 * JSOn return {"success":"false","search_results":"nothing found"}
1134 * different JSON returns {"result":"error","message":"searchstring not specified"}
1138 ### friendica/profile/show (GET; AUTH)
1140 show data of all profiles or a single profile of the authenticated user
1144 * profile_id: id of the profile to be returned (optional, if omitted all profiles are returned by default)
1148 On success: Array of:
1150 * multi_profiles: true if user has activated multi_profiles
1151 * global_dir: URL of the global directory set in server settings
1152 * friendica_owner: user data of the authenticated user
1153 * profiles: array of the profile data
1156 HTTP 403 Forbidden: when no authentication was provided
1157 HTTP 400 Bad Request: if given profile_id is not in the database or is not assigned to the authenticated user
1159 General description of profile data in API returns:
1163 * is_default: true if this is the public profile
1164 * hide_friends: true if friends are hidden
1167 * publish: true if published on the server's local directory
1168 * net_publish: true if published to global_dir
1169 * description ... homepage: different data fields from 'profile' table in database
1170 * users: array with the users allowed to view this profile (empty if is_default=true)
1174 ## Not Implemented API calls
1176 The following API calls are implemented in GNU Social but not in Friendica: (incomplete)
1178 * statuses/retweets_of_me
1179 * friendships/create
1180 * friendships/destroy
1181 * friendships/exists
1183 * account/update_profile_background_image
1187 The following API calls from the Twitter API are not implemented in either Friendica or GNU Social:
1189 * statuses/mentions_timeline
1190 * statuses/retweets/:id
1192 * statuses/retweeters/ids
1194 * direct_messages/show
1195 * friendships/no_retweets/ids
1196 * friendships/outgoing
1197 * friendships/update
1199 * friendships/lookup
1201 * account/update_delivery_device
1202 * account/update_profile
1203 * account/update_profile_background_image
1207 * account/remove_profile_banner
1208 * account/update_profile_banner
1209 * users/profile_banner
1210 * mutes/users/create
1211 * mutes/users/destroy
1214 * users/suggestions/:slug
1216 * users/suggestions/:slug/members
1220 * lists/members/destroy
1223 * lists/subscribers/create
1224 * lists/subscribers/show
1225 * lists/subscribers/destroy
1226 * lists/members/create_all
1227 * lists/members/show
1229 * lists/members/create
1234 * lists/subscriptions
1235 * lists/members/destroy_all
1237 * saved_searches/list
1238 * saved_searches/show/:id
1239 * saved_searches/create
1240 * saved_searches/destroy/:id
1242 * geo/reverse_geocode
1247 * help/configuration
1263 /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"
1268 The [RSStoFriendika](https://github.com/pafcu/RSStoFriendika) code can be used as an example of how to use the API with python.
1269 The lines for posting are located at [line 21](https://github.com/pafcu/RSStoFriendika/blob/master/RSStoFriendika.py#L21) and following.
1271 def tweet(server, message, group_allow=None):
1272 url = server + '/api/statuses/update'
1273 urllib2.urlopen(url, urllib.urlencode({'status': message,'group_allow[]':group_allow}, doseq=True))
1275 There is also a [module for python 3](https://bitbucket.org/tobiasd/python-friendica) for using the API.