]> git.mxchange.org Git - friendica.git/blob - doc/api.md
Add table of content in aside of help pages
[friendica.git] / doc / api.md
1 Friendica API\r
2 ===\r
3 The Friendica API aims to be compatible to the [GNU Social API](http://skilledtests.com/wiki/Twitter-compatible_API) and the [Twitter API](https://dev.twitter.com/rest/public).\r
4 \r
5 Please refer to the linked documentation for further information.\r
6 \r
7 ## Implemented API calls\r
8 \r
9 ### General\r
10 #### Unsupported parameters\r
11 * cursor: Not implemented in GNU Social\r
12 * trim_user: Not implemented in GNU Social\r
13 * contributor_details: Not implemented in GNU Social\r
14 * place_id: Not implemented in GNU Social\r
15 * display_coordinates: Not implemented in GNU Social\r
16 * include_rts: To-Do\r
17 * include_my_retweet: Retweets in Friendica are implemented in a different way\r
18 \r
19 #### Different behaviour\r
20 * 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
21 * include_entities: Default is "false". If set to "true" then the plain text is formatted so that links are having descriptions.\r
22 \r
23 #### Return values\r
24 * cid: Contact id of the user (important for "contact_allow" and "contact_deny")\r
25 * network: network of the user\r
26 \r
27 #### Errors\r
28 When an error occour in API call, an HTTP error code is returned, with an error message\r
29 Usually:\r
30 - 400 Bad Request: if parameter are missing or items can't be found\r
31 - 403 Forbidden: if authenticated user is missing\r
32 - 405 Method Not Allowed: if API was called with invalid method, eg. GET when API require POST\r
33 - 501 Not Implemented: if requested API doesn't exists\r
34 - 500 Internal Server Error: on other error contitions\r
35 \r
36 Error body is\r
37 \r
38 json:\r
39 ```\r
40         {\r
41           "error": "Specific error message",\r
42           "request": "API path requested",\r
43           "code": "HTTP error code"\r
44         }\r
45 ```\r
46 \r
47 xml:\r
48 ```\r
49         <status>\r
50                 <error>Specific error message</error>\r
51                 <request>API path requested</request>\r
52                 <code>HTTP error code</code>\r
53         </status>\r
54 ```\r
55 \r
56 ---\r
57 ### account/rate_limit_status\r
58 \r
59 ---\r
60 ### account/verify_credentials\r
61 #### Parameters\r
62 * skip_status: Don't show the "status" field. (Default: false)\r
63 * include_entities: "true" shows entities for pictures and links (Default: false)\r
64 \r
65 ---\r
66 ### conversation/show\r
67 Unofficial Twitter command. It shows all direct answers (excluding the original post) to a given id.\r
68 \r
69 #### Parameters\r
70 * id: id of the post\r
71 * count: Items per page (default: 20)\r
72 * page: page number\r
73 * since_id: minimal id\r
74 * max_id: maximum id\r
75 * include_entities: "true" shows entities for pictures and links (Default: false)\r
76 \r
77 #### Unsupported parameters\r
78 * include_rts\r
79 * trim_user\r
80 * contributor_details\r
81 \r
82 ---\r
83 ### direct_messages\r
84 #### Parameters\r
85 * count: Items per page (default: 20)\r
86 * page: page number\r
87 * since_id: minimal id\r
88 * max_id: maximum id\r
89 * getText: Defines the format of the status field. Can be "html" or "plain"\r
90 * include_entities: "true" shows entities for pictures and links (Default: false)\r
91 \r
92 #### Unsupported parameters\r
93 * skip_status\r
94 \r
95 ---\r
96 ### direct_messages/all\r
97 #### Parameters\r
98 * count: Items per page (default: 20)\r
99 * page: page number\r
100 * since_id: minimal id\r
101 * max_id: maximum id\r
102 * getText: Defines the format of the status field. Can be "html" or "plain"\r
103 \r
104 ---\r
105 ### direct_messages/conversation\r
106 Shows all direct messages of a conversation\r
107 #### Parameters\r
108 * count: Items per page (default: 20)\r
109 * page: page number\r
110 * since_id: minimal id\r
111 * max_id: maximum id\r
112 * getText: Defines the format of the status field. Can be "html" or "plain"\r
113 * uri: URI of the conversation\r
114 \r
115 ---\r
116 ### direct_messages/new\r
117 #### Parameters\r
118 * user_id: id of the user\r
119 * screen_name: screen name (for technical reasons, this value is not unique!)\r
120 * text: The message\r
121 * replyto: ID of the replied direct message\r
122 * title: Title of the direct message\r
123 \r
124 ---\r
125 ### direct_messages/sent\r
126 #### Parameters\r
127 * count: Items per page (default: 20)\r
128 * page: page number\r
129 * since_id: minimal id\r
130 * max_id: maximum id\r
131 * getText: Defines the format of the status field. Can be "html" or "plain"\r
132 * include_entities: "true" shows entities for pictures and links (Default: false)\r
133 \r
134 ---\r
135 ### favorites\r
136 #### Parameters\r
137 * count: Items per page (default: 20)\r
138 * page: page number\r
139 * since_id: minimal id\r
140 * max_id: maximum id\r
141 * include_entities: "true" shows entities for pictures and links (Default: false)\r
142 \r
143 #### Unsupported parameters\r
144 * user_id\r
145 * screen_name\r
146 \r
147 Favorites aren't displayed to other users, so "user_id" and "screen_name". So setting this value will result in an empty array.\r
148 \r
149 ---\r
150 ### favorites/create\r
151 #### Parameters\r
152 * id\r
153 * include_entities: "true" shows entities for pictures and links (Default: false)\r
154 \r
155 ---\r
156 ### favorites/destroy\r
157 #### Parameters\r
158 * id\r
159 * include_entities: "true" shows entities for pictures and links (Default: false)\r
160 \r
161 ---\r
162 ### followers/ids\r
163 #### Parameters\r
164 * stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)\r
165 \r
166 #### Unsupported parameters\r
167 * user_id\r
168 * screen_name\r
169 * cursor\r
170 \r
171 Friendica doesn't allow showing followers of other users.\r
172 \r
173 ---\r
174 ### friendica/activity/<verb>\r
175 #### parameters\r
176 * id: item id\r
177 \r
178 Add or remove an activity from an item.\r
179 'verb' can be one of:\r
180 - like\r
181 - dislike\r
182 - attendyes\r
183 - attendno\r
184 - attendmaybe\r
185 \r
186 To remove an activity, prepend the verb with "un", eg. "unlike" or "undislike"\r
187 Attend verbs disable eachother: that means that if "attendyes" was added to an item,\r
188 adding "attendno" remove previous "attendyes".\r
189 Attend verbs should be used only with event-related items (there is no check at the moment)\r
190 \r
191 #### Return values\r
192 \r
193 On success:\r
194 json\r
195 ```"ok"```\r
196 \r
197 xml\r
198 ```<ok>true</ok>```\r
199 \r
200 On error:\r
201 HTTP 400 BadRequest\r
202 \r
203 ---\r
204 ### friendica/photo\r
205 #### Parameters\r
206 * photo_id: Resource id of a photo.\r
207 * scale: (optional) scale value of the photo\r
208 \r
209 Returns data of a picture with the given resource.\r
210 If 'scale' isn't provided, returned data include full url to each scale of the photo.\r
211 If 'scale' is set, returned data include image data base64 encoded.\r
212 \r
213 possibile scale value are:\r
214 0: original or max size by server settings\r
215 1: image with or height at <= 640\r
216 2: image with or height at <= 320\r
217 3: thumbnail 160x160\r
218 \r
219 4: Profile image at 175x175\r
220 5: Profile image at 80x80\r
221 6: Profile image at 48x48\r
222 \r
223 An image used as profile image has only scale 4-6, other images only 0-3\r
224 \r
225 #### Return values\r
226 \r
227 json\r
228 ```\r
229         {\r
230           "id": "photo id"\r
231           "created": "date(YYYY-MM-GG HH:MM:SS)",\r
232           "edited": "date(YYYY-MM-GG HH:MM:SS)",\r
233           "title": "photo title",\r
234           "desc": "photo description",\r
235           "album": "album name",\r
236           "filename": "original file name",\r
237           "type": "mime type",\r
238           "height": "number",\r
239           "width": "number",\r
240           "profile": "1 if is profile photo",\r
241           "link": {\r
242                 "<scale>": "url to image"\r
243                 ...\r
244           },\r
245           // if 'scale' is set\r
246           "datasize": "size in byte",\r
247           "data": "base64 encoded image data"\r
248         }\r
249 ```\r
250 \r
251 xml\r
252 ```\r
253         <photo>\r
254                 <id>photo id</id>\r
255                 <created>date(YYYY-MM-GG HH:MM:SS)</created>\r
256                 <edited>date(YYYY-MM-GG HH:MM:SS)</edited>\r
257                 <title>photo title</title>\r
258                 <desc>photo description</desc>\r
259                 <album>album name</album>\r
260                 <filename>original file name</filename>\r
261                 <type>mime type</type>\r
262                 <height>number</height>\r
263                 <width>number</width>\r
264                 <profile>1 if is profile photo</profile>\r
265                 <links type="array">\r
266                         <link type="mime type" scale="scale number" href="image url"/>\r
267                         ...\r
268                 </links>\r
269         </photo>\r
270 ```\r
271 \r
272 ### friendica/photos/list\r
273 \r
274 Returns a list of all photo resources of the logged in user.\r
275 \r
276 #### Return values\r
277 \r
278 json\r
279 ```\r
280         [\r
281                 {\r
282                         id: "resource_id",\r
283                         album: "album name",\r
284                         filename: "original file name",\r
285                         type: "image mime type",\r
286                         thumb: "url to thumb sized image"\r
287                 },\r
288                 ...\r
289         ]\r
290 ```\r
291 \r
292 xml\r
293 ```\r
294         <photos type="array">\r
295                 <photo id="resource_id"\r
296                         album="album name"\r
297                         filename="original file name"\r
298                         type="image mime type">\r
299                                 "url to thumb sized image"\r
300                 </photo>\r
301                 ...\r
302         </photos>\r
303 ```\r
304 \r
305 ---\r
306 ### friends/ids\r
307 #### Parameters\r
308 * stringify_ids: Should the id numbers be sent as text (true) or number (false)? (default: false)\r
309 \r
310 #### Unsupported parameters\r
311 * user_id\r
312 * screen_name\r
313 * cursor\r
314 \r
315 Friendica doesn't allow showing friends of other users.\r
316 \r
317 ---\r
318 ### help/test\r
319 \r
320 ---\r
321 ### media/upload\r
322 #### Parameters\r
323 * media: image data\r
324 \r
325 ---\r
326 ### oauth/request_token\r
327 #### Parameters\r
328 * oauth_callback\r
329 \r
330 #### Unsupported parameters\r
331 * x_auth_access_type\r
332 \r
333 ---\r
334 ### oauth/access_token\r
335 #### Parameters\r
336 * oauth_verifier\r
337 \r
338 #### Unsupported parameters\r
339 * x_auth_password\r
340 * x_auth_username\r
341 * x_auth_mode\r
342 \r
343 ---\r
344 ### statuses/destroy\r
345 #### Parameters\r
346 * id: message number\r
347 * include_entities: "true" shows entities for pictures and links (Default: false)\r
348 \r
349 #### Unsupported parameters\r
350 * trim_user\r
351 \r
352 ---\r
353 ### statuses/followers\r
354 * include_entities: "true" shows entities for pictures and links (Default: false)\r
355 \r
356 ---\r
357 ### statuses/friends\r
358 * include_entities: "true" shows entities for pictures and links (Default: false)\r
359 \r
360 ---\r
361 ### statuses/friends_timeline\r
362 #### Parameters\r
363 * count: Items per page (default: 20)\r
364 * page: page number\r
365 * since_id: minimal id\r
366 * max_id: maximum id\r
367 * exclude_replies: don't show replies (default: false)\r
368 * conversation_id: Shows all statuses of a given conversation.\r
369 * include_entities: "true" shows entities for pictures and links (Default: false)\r
370 \r
371 #### Unsupported parameters\r
372 * include_rts\r
373 * trim_user\r
374 * contributor_details\r
375 \r
376 ---\r
377 ### statuses/home_timeline\r
378 #### Parameters\r
379 * count: Items per page (default: 20)\r
380 * page: page number\r
381 * since_id: minimal id\r
382 * max_id: maximum id\r
383 * exclude_replies: don't show replies (default: false)\r
384 * conversation_id: Shows all statuses of a given conversation.\r
385 * include_entities: "true" shows entities for pictures and links (Default: false)\r
386 \r
387 #### Unsupported parameters\r
388 * include_rts\r
389 * trim_user\r
390 * contributor_details\r
391 \r
392 ---\r
393 ### statuses/mentions\r
394 #### Parameters\r
395 * count: Items per page (default: 20)\r
396 * page: page number\r
397 * since_id: minimal id\r
398 * max_id: maximum id\r
399 * include_entities: "true" shows entities for pictures and links (Default: false)\r
400 \r
401 #### Unsupported parameters\r
402 * include_rts\r
403 * trim_user\r
404 * contributor_details\r
405 \r
406 ---\r
407 ### statuses/public_timeline\r
408 #### Parameters\r
409 * count: Items per page (default: 20)\r
410 * page: page number\r
411 * since_id: minimal id\r
412 * max_id: maximum id\r
413 * exclude_replies: don't show replies (default: false)\r
414 * conversation_id: Shows all statuses of a given conversation.\r
415 * include_entities: "true" shows entities for pictures and links (Default: false)\r
416 \r
417 #### Unsupported parameters\r
418 * trim_user\r
419 \r
420 ---\r
421 ### statuses/replies\r
422 #### Parameters\r
423 * count: Items per page (default: 20)\r
424 * page: page number\r
425 * since_id: minimal id\r
426 * max_id: maximum id\r
427 * include_entities: "true" shows entities for pictures and links (Default: false)\r
428 \r
429 #### Unsupported parameters\r
430 * include_rts\r
431 * trim_user\r
432 * contributor_details\r
433 \r
434 ---\r
435 ### statuses/retweet\r
436 #### Parameters\r
437 * id: message number\r
438 * include_entities: "true" shows entities for pictures and links (Default: false)\r
439 \r
440 #### Unsupported parameters\r
441 * trim_user\r
442 \r
443 ---\r
444 ### statuses/show\r
445 #### Parameters\r
446 * id: message number\r
447 * conversation: if set to "1" show all messages of the conversation with the given id\r
448 * include_entities: "true" shows entities for pictures and links (Default: false)\r
449 \r
450 #### Unsupported parameters\r
451 * include_my_retweet\r
452 * trim_user\r
453 \r
454 ---\r
455 ### statuses/update, statuses/update_with_media\r
456 #### Parameters\r
457 * title: Title of the status\r
458 * status: Status in text format\r
459 * htmlstatus: Status in HTML format\r
460 * in_reply_to_status_id\r
461 * lat: latitude\r
462 * long: longitude\r
463 * media: image data\r
464 * source: Application name\r
465 * group_allow\r
466 * contact_allow\r
467 * group_deny\r
468 * contact_deny\r
469 * network\r
470 * include_entities: "true" shows entities for pictures and links (Default: false)\r
471 * media_ids: (By now only a single value, no array)\r
472 \r
473 #### Unsupported parameters\r
474 * trim_user\r
475 * place_id\r
476 * display_coordinates\r
477 \r
478 ---\r
479 ### statuses/user_timeline\r
480 #### Parameters\r
481 * user_id: id of the user\r
482 * screen_name: screen name (for technical reasons, this value is not unique!)\r
483 * count: Items per page (default: 20)\r
484 * page: page number\r
485 * since_id: minimal id\r
486 * max_id: maximum id\r
487 * exclude_replies: don't show replies (default: false)\r
488 * conversation_id: Shows all statuses of a given conversation.\r
489 * include_entities: "true" shows entities for pictures and links (Default: false)\r
490 \r
491 #### Unsupported parameters\r
492 * include_rts\r
493 * trim_user\r
494 * contributor_details\r
495 \r
496 ---\r
497 ### statusnet/config\r
498 \r
499 ---\r
500 ### statusnet/version\r
501 \r
502 #### Unsupported parameters\r
503 * user_id\r
504 * screen_name\r
505 * cursor\r
506 \r
507 Friendica doesn't allow showing followers of other users.\r
508 \r
509 ---\r
510 ### users/search\r
511 #### Parameters\r
512 * q: name of the user\r
513 \r
514 #### Unsupported parameters\r
515 * page\r
516 * count\r
517 * include_entities\r
518 \r
519 ---\r
520 ### users/show\r
521 #### Parameters\r
522 * user_id: id of the user\r
523 * screen_name: screen name (for technical reasons, this value is not unique!)\r
524 * include_entities: "true" shows entities for pictures and links (Default: false)\r
525 \r
526 #### Unsupported parameters\r
527 * user_id\r
528 * screen_name\r
529 * cursor\r
530 \r
531 Friendica doesn't allow showing friends of other users.\r
532 \r
533 \r
534 ## Implemented API calls (not compatible with other APIs)\r
535 \r
536 ---\r
537 ### friendica/group_show\r
538 Return all or a specified group of the user with the containing contacts as array.\r
539 \r
540 #### Parameters\r
541 * gid: optional, if not given, API returns all groups of the user\r
542 \r
543 #### Return values\r
544 Array of:\r
545 * name: name of the group\r
546 * gid: id of the group\r
547 * user: array of group members (return from api_get_user() function for each member)\r
548 \r
549 \r
550 ---\r
551 ### friendica/group_delete\r
552 delete the specified group of contacts; API call need to include the correct gid AND name of the group to be deleted.\r
553 \r
554 ---\r
555 ### Parameters\r
556 * gid: id of the group to be deleted\r
557 * name: name of the group to be deleted\r
558 \r
559 #### Return values\r
560 Array of:\r
561 * success: true if successfully deleted\r
562 * gid: gid of the deleted group\r
563 * name: name of the deleted group\r
564 * status: „deleted“ if successfully deleted\r
565 * wrong users: empty array\r
566 \r
567 \r
568 ---\r
569 ### friendica/group_create\r
570 Create the group with the posted array of contacts as members.\r
571 #### Parameters\r
572 * name: name of the group to be created\r
573 \r
574 #### POST data\r
575 JSON data as Array like the result of „users/group_show“:\r
576 * gid\r
577 * name\r
578 * array of users\r
579 \r
580 #### Return values\r
581 Array of:\r
582 * success: true if successfully created or reactivated\r
583 * gid: gid of the created group\r
584 * name: name of the created group\r
585 * status: „missing user“ | „reactivated“ | „ok“\r
586 * wrong users: array of users, which were not available in the contact table\r
587 \r
588 \r
589 ---\r
590 ### friendica/group_update\r
591 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
592 #### Parameters\r
593 * gid: id of the group to be changed\r
594 * name: name of the group to be changed\r
595 \r
596 #### POST data\r
597 JSON data as array like the result of „users/group_show“:\r
598 * gid\r
599 * name\r
600 * array of users\r
601 \r
602 #### Return values\r
603 Array of:\r
604 * success: true if successfully updated\r
605 * gid: gid of the changed group\r
606 * name: name of the changed group\r
607 * status: „missing user“ | „ok“\r
608 * wrong users: array of users, which were not available in the contact table\r
609 \r
610 ---\r
611 ## Not Implemented API calls\r
612 The following API calls are implemented in GNU Social but not in Friendica: (incomplete)\r
613 \r
614 * statuses/retweets_of_me\r
615 * friendships/create\r
616 * friendships/destroy\r
617 * friendships/exists\r
618 * friendships/show\r
619 * account/update_profile_background_image\r
620 * account/update_profile_image\r
621 * blocks/create\r
622 * blocks/destroy\r
623 \r
624 The following API calls from the Twitter API aren't implemented neither in Friendica nor in GNU Social:\r
625 \r
626 * statuses/mentions_timeline\r
627 * statuses/retweets/:id\r
628 * statuses/oembed\r
629 * statuses/retweeters/ids\r
630 * statuses/lookup\r
631 * direct_messages/show\r
632 * search/tweets\r
633 * direct_messages/destroy\r
634 * friendships/no_retweets/ids\r
635 * friendships/incoming\r
636 * friendships/outgoing\r
637 * friendships/update\r
638 * friends/list\r
639 * friendships/lookup\r
640 * account/settings\r
641 * account/update_delivery_device\r
642 * account/update_profile\r
643 * account/update_profile_background_image\r
644 * account/update_profile_image\r
645 * blocks/list\r
646 * blocks/ids\r
647 * users/lookup\r
648 * users/show\r
649 * users/search\r
650 * account/remove_profile_banner\r
651 * account/update_profile_banner\r
652 * users/profile_banner\r
653 * mutes/users/create\r
654 * mutes/users/destroy\r
655 * mutes/users/ids\r
656 * mutes/users/list\r
657 * users/suggestions/:slug\r
658 * users/suggestions\r
659 * users/suggestions/:slug/members\r
660 * favorites/list\r
661 * lists/list\r
662 * lists/statuses\r
663 * lists/members/destroy\r
664 * lists/memberships\r
665 * lists/subscribers\r
666 * lists/subscribers/create\r
667 * lists/subscribers/show\r
668 * lists/subscribers/destroy\r
669 * lists/members/create_all\r
670 * lists/members/show\r
671 * lists/members\r
672 * lists/members/create\r
673 * lists/destroy\r
674 * lists/update\r
675 * lists/create\r
676 * lists/show\r
677 * lists/subscriptions\r
678 * lists/members/destroy_all\r
679 * lists/ownerships\r
680 * saved_searches/list\r
681 * saved_searches/show/:id\r
682 * saved_searches/create\r
683 * saved_searches/destroy/:id\r
684 * geo/id/:place_id\r
685 * geo/reverse_geocode\r
686 * geo/search\r
687 * geo/place\r
688 * trends/place\r
689 * trends/available\r
690 * help/configuration\r
691 * help/languages\r
692 * help/privacy\r
693 * help/tos\r
694 * trends/closest\r
695 * users/report_spam\r
696 \r
697 ---\r
698 \r
699 ---\r
700 \r
701 ## Usage Examples\r
702 ### BASH / cURL\r
703 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
704 \r
705     /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
706 \r
707 ### Python\r
708 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
709 \r
710     def tweet(server, message, group_allow=None):\r
711         url = server + '/api/statuses/update'\r
712         urllib2.urlopen(url, urllib.urlencode({'status': message,'group_allow[]':group_allow}, doseq=True))\r
713 \r
714 There is also a [module for python 3](https://bitbucket.org/tobiasd/python-friendica) for using the API.\r