friendica/doc/api.md

1371 lines
30 KiB
Markdown
Raw Normal View History

2017-12-19 12:07:31 +01:00
# Friendica API
<!-- markdownlint-disable MD010 MD013 MD024 -->
* [Home](help)
2017-05-19 22:37:45 +02:00
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).
Please refer to the linked documentation for further information.
## Implemented API calls
### General
2017-12-19 12:07:31 +01:00
#### HTTP Method
API endpoints can restrict the method used to request them.
Using an invalid method results in HTTP error 405 "Method Not Allowed".
In this document, the required method is listed after the endpoint name. "*" means every method can be used.
#### Auth
Friendica supports basic http auth and OAuth 1 to authenticate the user to the api.
OAuth settings can be added by the user in web UI under /settings/oauth/
In this document, endpoints which requires auth are marked with "AUTH" after endpoint name
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* cursor: Not implemented in GNU Social
* trim_user: Not implemented in GNU Social
* contributor_details: Not implemented in GNU Social
* place_id: Not implemented in GNU Social
* display_coordinates: Not implemented in GNU Social
* include_rts: To-Do
* include_my_retweet: Retweets in Friendica are implemented in a different way
#### Different behaviour
2017-12-19 12:07:31 +01:00
* 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.
* include_entities: Default is "false". If set to "true" then the plain text is formatted so that links are having descriptions.
#### Return values
2017-12-19 12:07:31 +01:00
* cid: Contact id of the user (important for "contact_allow" and "contact_deny")
* network: network of the user
#### Errors
2017-12-19 12:07:31 +01:00
2017-05-19 22:37:45 +02:00
When an error occurs in API call, an HTTP error code is returned, with an error message
Usually:
2017-12-19 12:07:31 +01:00
* 400 Bad Request: if parameters are missing or items can't be found
* 403 Forbidden: if the authenticated user is missing
* 405 Method Not Allowed: if API was called with an invalid method, eg. GET when API require POST
* 501 Not Implemented: if the requested API doesn't exist
* 500 Internal Server Error: on other error conditions
Error body is
json:
2017-12-19 12:07:31 +01:00
```json
{
"error": "Specific error message",
"request": "API path requested",
"code": "HTTP error code"
}
```
xml:
2017-12-19 12:07:31 +01:00
```xml
<status>
<error>Specific error message</error>
<request>API path requested</request>
<code>HTTP error code</code>
</status>
```
---
2017-12-19 12:07:31 +01:00
### account/rate_limit_status (*; AUTH)
---
2017-12-19 12:07:31 +01:00
### account/verify_credentials (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
* skip_status: Don't show the "status" field. (Default: false)
* include_entities: "true" shows entities for pictures and links (Default: false)
---
2017-12-19 12:07:31 +01:00
### conversation/show (*; AUTH)
2017-12-19 12:07:31 +01:00
Unofficial Twitter command. It shows all direct answers (excluding the original post) to a given id.
#### Parameter
2017-12-19 12:07:31 +01:00
* id: id of the post
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* include_rts
* trim_user
* contributor_details
---
2017-12-19 12:07:31 +01:00
### direct_messages (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* getText: Defines the format of the status field. Can be "html" or "plain"
* include_entities: "true" shows entities for pictures and links (Default: false)
* friendica_verbose: "true" enables different error returns (default: "false")
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* skip_status
---
2017-12-19 12:07:31 +01:00
### direct_messages/all (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* getText: Defines the format of the status field. Can be "html" or "plain"
* friendica_verbose: "true" enables different error returns (default: "false")
---
2017-12-19 12:07:31 +01:00
### direct_messages/conversation (*; AUTH)
2017-12-19 12:07:31 +01:00
Shows all direct messages of a conversation
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* getText: Defines the format of the status field. Can be "html" or "plain"
* uri: URI of the conversation
* friendica_verbose: "true" enables different error returns (default: "false")
---
2017-12-19 12:07:31 +01:00
### direct_messages/sent (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* getText: Defines the format of the status field. Can be "html" or "plain"
* include_entities: "true" shows entities for pictures and links (Default: false)
* friendica_verbose: "true" enables different error returns (default: "false")
---
2017-12-19 12:07:31 +01:00
### direct_messages/new (POST,PUT; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* user_id: id of the user
* screen_name: screen name (for technical reasons, this value is not unique!)
* text: The message
* replyto: ID of the replied direct message
* title: Title of the direct message
---
2017-12-19 12:07:31 +01:00
### direct_messages/destroy (POST,DELETE; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id: id of the message to be deleted
* include_entities: optional, currently not yet implemented
* friendica_parenturi: optional, can be used for increased safety to delete only intended messages
* friendica_verbose: "true" enables different error returns (default: "false")
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* JSON return as defined for Twitter API not yet implemented
* on friendica_verbose=true: JSON return {"result":"ok","message":"message deleted"}
On error:
HTTP 400 BadRequest
2017-12-19 12:07:31 +01:00
* on friendica_verbose=true: different JSON returns {"result":"error","message":"xyz"}
---
2017-12-19 12:07:31 +01:00
### externalprofile/show (*)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* profileurl: profile url
---
2017-12-19 12:07:31 +01:00
### favorites (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* user_id
* screen_name
Favorites aren't displayed to other users, so "user_id" and "screen_name" are unsupported.
Set this values will result in an empty array.
---
2017-12-19 12:07:31 +01:00
### favorites/create (POST,PUT; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id
* include_entities: "true" shows entities for pictures and links (Default: false)
---
2017-12-19 12:07:31 +01:00
### favorites/destroy (POST,DELETE; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id
* include_entities: "true" shows entities for pictures and links (Default: false)
---
2017-12-19 12:07:31 +01:00
### followers/ids (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
2017-05-19 22:37:45 +02:00
* stringify_ids: Send id numbers as text (true) or integers (false)? (default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* user_id
* screen_name
* cursor
2017-05-19 22:37:45 +02:00
Friendica doesn't allow showing the followers of other users.
---
2017-12-19 12:07:31 +01:00
### friends/ids (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
2017-05-19 22:37:45 +02:00
* stringify_ids: Send the id numbers as text (true) or integers (false)? (default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* user_id
* screen_name
* cursor
2017-05-19 22:37:45 +02:00
Friendica doesn't allow showing the friends of other users.
---
2017-12-19 12:07:31 +01:00
### help/test (*)
---
2017-12-19 12:07:31 +01:00
### lists/ownerships (*; AUTH)
#### Parameters
* list_id: ID of the list
* count: Items per page
* page: Page number
* since_id: Minimum ID
* max_id: Maximum ID
#### Unsupported parameters
* slug
* owner_screen_name
* owner_id
* include_entities
* include_rts
---
### lists/destroy (POST; AUTH)
#### Parameters
* list_id: ID of the list
#### Unsupported parameters
* owner_screen_name
* owner_id
* slug
---
### lists/create (POST; AUTH)
#### Parameters
* name: name of the list
#### Unsupported parameters
* mode
* description
---
### lists/update (POST; AUTH)
#### Parameters
* list_id: ID of the list
* name: name of the list
#### Unsupported parameters
* slug
* name
* mode
* description
* owner_screen_name
* owner_id
---
### lists/statuses (*; AUTH)
#### Parameters
* user_id: ID of the user for whom to return results.
#### Unsupported parameters
* screen_name
* count
* cursor
---
### media/upload (POST,PUT; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* media: image data
---
2017-12-19 12:07:31 +01:00
### oauth/request_token (*)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* oauth_callback
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* x_auth_access_type
---
2017-12-19 12:07:31 +01:00
### oauth/access_token (*)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* oauth_verifier
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* x_auth_password
* x_auth_username
* x_auth_mode
---
2017-12-19 12:07:31 +01:00
### statuses/destroy (POST,DELETE; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id: message number
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* trim_user
---
2017-12-19 12:07:31 +01:00
### statuses/followers (*; AUTH)
#### Parameters
* include_entities: "true" shows entities for pictures and links (Default: false)
---
2017-12-19 12:07:31 +01:00
### statuses/friends (*; AUTH)
#### Parameters
* include_entities: "true" shows entities for pictures and links (Default: false)
2018-05-06 12:25:23 +02:00
* count: how many items should be shown (Default: 20)
2017-12-18 15:18:31 +01:00
---
2017-12-19 12:07:31 +01:00
2017-12-18 15:18:31 +01:00
### blocks/list (*; AUTH)
#### Parameters
* include_entities: "true" shows entities for pictures and links (Default: false)
* count: Items per page (default: 20).
* page: page number
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
2017-12-18 15:18:31 +01:00
* cursor
* skip_status
---
2017-12-19 12:07:31 +01:00
### statuses/friends_timeline (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* exclude_replies: don't show replies (default: false)
* conversation_id: Shows all statuses of a given conversation.
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* include_rts
* trim_user
* contributor_details
---
2017-12-19 12:07:31 +01:00
### statuses/home_timeline (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* exclude_replies: don't show replies (default: false)
* conversation_id: Shows all statuses of a given conversation.
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* include_rts
* trim_user
* contributor_details
---
2017-12-19 12:07:31 +01:00
### statuses/mentions (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* include_rts
* trim_user
* contributor_details
---
2017-12-19 12:07:31 +01:00
### statuses/public_timeline (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* exclude_replies: don't show replies (default: false)
* conversation_id: Shows all statuses of a given conversation.
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* trim_user
---
2017-12-19 12:07:31 +01:00
### statuses/networkpublic_timeline (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
---
2017-12-19 12:07:31 +01:00
### statuses/replies (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* include_rts
* trim_user
* contributor_details
---
2017-12-19 12:07:31 +01:00
### statuses/retweet (POST,PUT; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id: message number
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* trim_user
---
2017-12-19 12:07:31 +01:00
### statuses/show (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id: message number
* conversation: if set to "1" show all messages of the conversation with the given id
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* include_my_retweet
* trim_user
---
2017-12-19 12:07:31 +01:00
### statuses/update, statuses/update_with_media
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* title: Title of the status
* status: Status in text format
* htmlstatus: Status in HTML format
* in_reply_to_status_id
* lat: latitude
* long: longitude
* media: image data
* source: Application name
* group_allow
* contact_allow
* group_deny
* contact_deny
* network
* include_entities: "true" shows entities for pictures and links (Default: false)
* media_ids: (By now only a single value, no array)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* trim_user
* place_id
* display_coordinates
---
2017-12-19 12:07:31 +01:00
### statuses/user_timeline (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* user_id: id of the user
* screen_name: screen name (for technical reasons, this value is not unique!)
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* exclude_replies: don't show replies (default: false)
* conversation_id: Shows all statuses of a given conversation.
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
* include_rts
* trim_user
* contributor_details
---
2017-12-19 12:07:31 +01:00
### statusnet/config (*)
---
2017-12-19 12:07:31 +01:00
### statusnet/conversation (*; AUTH)
2017-12-19 12:07:31 +01:00
It shows all direct answers (excluding the original post) to a given id.
#### Parameter
2017-12-19 12:07:31 +01:00
* id: id of the post
* count: Items per page (default: 20)
* page: page number
2017-05-19 22:37:45 +02:00
* since_id: minimum id
* max_id: maximum id
* include_entities: "true" shows entities for pictures and links (Default: false)
---
2017-12-19 12:07:31 +01:00
### statusnet/version (*)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* user_id
* screen_name
* cursor
Friendica doesn't allow showing followers of other users.
2017-12-18 02:59:11 +01:00
---
2017-12-19 12:07:31 +01:00
2017-12-18 02:59:11 +01:00
### search (*; AUTH)
2017-12-19 12:07:31 +01:00
2017-12-18 02:59:11 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
2017-12-18 02:59:11 +01:00
* q: search query
* page: the page number (starting at 1) to return
* rpp: the number of statuses to return per page
* count: alias for the rpp parameter
* since_id: returns statuses with ids greater than the given id
* max_id: returns statuses with ids lower or equal to the given id
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
2017-12-18 02:59:11 +01:00
* geocode
* lang
* locale
* result_type
* until
* include_entities
---
2017-12-19 12:07:31 +01:00
### search/tweets (*; AUTH)
This is an alias for `search`.
---
2017-12-19 14:20:32 +01:00
### saved_searches/list (*; AUTH)
This call does not have any parameter.
---
### users/search (*)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* q: name of the user
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* page
* count
* include_entities
---
2017-12-19 12:07:31 +01:00
### users/show (*)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* user_id: id of the user
* screen_name: screen name (for technical reasons, this value is not unique!)
* include_entities: "true" shows entities for pictures and links (Default: false)
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* user_id
* screen_name
* cursor
Friendica doesn't allow showing friends of other users.
---
2017-12-19 12:07:31 +01:00
### users/lookup (*; AUTH)
#### Parameters
2017-12-19 12:07:31 +01:00
* user_id: list of ids to lookup
#### Unsupported parameters
2017-12-19 12:07:31 +01:00
* screen_name
* include_entities
---
2017-12-19 12:07:31 +01:00
### account/update_profile_image (POST; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* image: image data as base64 (Twitter has a limit of 700kb, Friendica allows more)
* profile_id (optional): id of the profile for which the image should be used, default is changing the default profile
uploads a new profile image (scales 4-6) to database, changes default or specified profile to the new photo
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* JSON return: returns the updated user details (see account/verify_credentials)
On error:
2017-12-19 12:07:31 +01:00
* 403 FORBIDDEN: if not authenticated
* 400 BADREQUEST: "no media data submitted", "profile_id not available"
* 500 INTERNALSERVERERROR: "image size exceeds PHP config settings, file was rejected by server",
"image size exceeds Friendica Config setting (uploaded size: x)",
"unable to process image data",
"image upload failed"
2017-12-19 12:07:31 +01:00
---
### account/update_profile (POST; AUTH)
#### Parameters
* name (optional): full name of the user
* description (optional): a description of the user
#### Unsupported parameters
* url
* location
* profile_link_color
* include_entities
* skip_status
---
2017-12-19 12:07:31 +01:00
### friendships/incoming (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Unsupported parameters
* cursor
* stringify_ids
## Implemented API calls (not compatible with other APIs)
---
2017-12-19 12:07:31 +01:00
### friendica/activity/[verb]
#### parameters
2017-12-19 12:07:31 +01:00
* id: item id
Add or remove an activity from an item.
'verb' can be one of:
2017-12-19 12:07:31 +01:00
* like
* dislike
* attendyes
* attendno
* attendmaybe
To remove an activity, prepend the verb with "un", eg. "unlike" or "undislike"
Attend verbs disable eachother: that means that if "attendyes" was added to an item, adding "attendno" remove previous "attendyes".
Attend verbs should be used only with event-related items (there is no check at the moment)
#### Return values
On success:
2017-12-19 12:07:31 +01:00
json:
```"ok"```
2017-12-19 12:07:31 +01:00
xml:
```<ok>true</ok>```
On error:
HTTP 400 BadRequest
---
2017-12-19 12:07:31 +01:00
### friendica/group_show (*; AUTH)
2017-12-19 12:07:31 +01:00
Return all or a specified group of the user with the containing contacts as array.
#### Parameters
2017-12-19 12:07:31 +01:00
* gid: optional, if not given, API returns all groups of the user
#### Return values
2017-12-19 12:07:31 +01:00
Array of:
* name: name of the group
* gid: id of the group
* user: array of group members (return from api_get_user() function for each member)
---
2017-12-19 12:07:31 +01:00
### friendica/group_delete (POST,DELETE; AUTH)
2017-12-19 12:07:31 +01:00
delete the specified group of contacts; API call need to include the correct gid AND name of the group to be deleted.
#### Parameters
2017-12-19 12:07:31 +01:00
* gid: id of the group to be deleted
* name: name of the group to be deleted
#### Return values
2017-12-19 12:07:31 +01:00
Array of:
* success: true if successfully deleted
* gid: gid of the deleted group
* name: name of the deleted group
* status: „deleted“ if successfully deleted
* wrong users: empty array
---
2017-12-19 12:07:31 +01:00
### friendica/group_create (POST,PUT; AUTH)
2017-12-19 12:07:31 +01:00
Create the group with the posted array of contacts as members.
#### Parameters
2017-12-19 12:07:31 +01:00
* name: name of the group to be created
#### POST data
2017-12-19 12:07:31 +01:00
JSON data as Array like the result of "users/group_show":
* gid
* name
* array of users
#### Return values
2017-12-19 12:07:31 +01:00
Array of:
* success: true if successfully created or reactivated
* gid: gid of the created group
* name: name of the created group
* status: „missing user“ | „reactivated“ | „ok“
* wrong users: array of users, which were not available in the contact table
---
2017-12-19 12:07:31 +01:00
### friendica/group_update (POST)
2017-12-19 12:07:31 +01:00
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).
#### Parameters
2017-12-19 12:07:31 +01:00
* gid: id of the group to be changed
* name: name of the group to be changed
#### POST data
2017-12-19 12:07:31 +01:00
JSON data as array like the result of „users/group_show“:
* gid
* name
* array of users
#### Return values
2017-12-19 12:07:31 +01:00
Array of:
* success: true if successfully updated
* gid: gid of the changed group
* name: name of the changed group
* status: „missing user“ | „ok“
* wrong users: array of users, which were not available in the contact table
---
2017-12-19 12:07:31 +01:00
### friendica/notifications (GET)
2017-12-19 12:07:31 +01:00
Return last 50 notification for current user, ordered by date with unseen item on top
#### Parameters
2017-12-19 12:07:31 +01:00
none
#### Return values
2017-12-19 12:07:31 +01:00
Array of:
* id: id of the note
* type: type of notification as int (see NOTIFY_* constants in boot.php)
* name: full name of the contact subject of the note
* url: contact's profile url
* photo: contact's profile photo
* date: datetime string of the note
* timestamp: timestamp of the node
* date_rel: relative date of the note (eg. "1 hour ago")
* msg: note message in bbcode
* msg_html: note message in html
* msg_plain: note message in plain text
* link: link to note
* seen: seen state: 0 or 1
---
2017-12-19 12:07:31 +01:00
### friendica/notifications/seen (POST)
2017-12-19 12:07:31 +01:00
Set note as seen, returns item object if possible
#### Parameters
2017-12-19 12:07:31 +01:00
id: id of the note to set seen
#### Return values
2017-12-19 12:07:31 +01:00
If the note is linked to an item, the item is returned, just like one of the "statuses/*_timeline" api.
If the note is not linked to an item, a success status is returned:
2017-12-19 12:07:31 +01:00
* `success` (json) | `<status>success</status>` (xml)
---
2017-12-19 12:07:31 +01:00
### friendica/photo (*; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* photo_id: Resource id of a photo.
* scale: (optional) scale value of the photo
Returns data of a picture with the given resource.
If 'scale' isn't provided, returned data include full url to each scale of the photo.
If 'scale' is set, returned data include image data base64 encoded.
possibile scale value are:
* 0: original or max size by server settings
* 1: image with or height at <= 640
* 2: image with or height at <= 320
* 3: thumbnail 160x160
* 4: Profile image at 175x175
* 5: Profile image at 80x80
* 6: Profile image at 48x48
An image used as profile image has only scale 4-6, other images only 0-3
#### Return values
2017-12-19 12:07:31 +01:00
json:
```json
{
"id": "photo id"
2017-05-19 22:37:45 +02:00
"created": "date(YYYY-MM-DD HH:MM:SS)",
"edited": "date(YYYY-MM-DD HH:MM:SS)",
"title": "photo title",
"desc": "photo description",
"album": "album name",
"filename": "original file name",
"type": "mime type",
"height": "number",
"width": "number",
"profile": "1 if is profile photo",
"link": {
"<scale>": "url to image"
...
},
// if 'scale' is set
"datasize": "size in byte",
"data": "base64 encoded image data"
}
```
2017-12-19 12:07:31 +01:00
xml:
```xml
<photo>
<id>photo id</id>
2017-05-19 22:37:45 +02:00
<created>date(YYYY-MM-DD HH:MM:SS)</created>
<edited>date(YYYY-MM-DD HH:MM:SS)</edited>
<title>photo title</title>
<desc>photo description</desc>
<album>album name</album>
<filename>original file name</filename>
<type>mime type</type>
<height>number</height>
<width>number</width>
<profile>1 if is profile photo</profile>
<links type="array">
<link type="mime type" scale="scale number" href="image url"/>
...
</links>
</photo>
```
---
2017-12-19 12:07:31 +01:00
### friendica/photos/list (*; AUTH)
Returns a list of all photo resources of the logged in user.
#### Return values
2017-12-19 12:07:31 +01:00
json:
```json
[
{
id: "resource_id",
album: "album name",
filename: "original file name",
type: "image mime type",
thumb: "url to thumb sized image"
},
...
]
```
2017-12-19 12:07:31 +01:00
xml:
```xml
<photos type="array">
<photo id="resource_id"
album="album name"
filename="original file name"
type="image mime type">
"url to thumb sized image"
</photo>
...
</photos>
```
---
2017-12-19 12:07:31 +01:00
### friendica/photoalbum/delete (POST,DELETE; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* album: name of the album to be deleted
deletes all images with the specified album name, is not reversible -> ensure that client is asking user for being sure to do this
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* JSON return {"result":"deleted","message":"album 'xyz' with all containing photos has been deleted."}
On error:
2017-12-19 12:07:31 +01:00
* 403 FORBIDDEN: if not authenticated
* 400 BADREQUEST: "no albumname specified", "album not available"
* 500 INTERNALSERVERERROR: "problem with deleting item occured", "unknown error - deleting from database failed"
---
2017-12-19 12:07:31 +01:00
### friendica/photoalbum/update (POST,PUT; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* album: name of the album to be updated
* album_new: new name of the album
changes the album name to album_new for all photos in album
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* JSON return {"result":"updated","message":"album 'abc' with all containing photos has been renamed to 'xyz'."}
On error:
2017-12-19 12:07:31 +01:00
* 403 FORBIDDEN: if not authenticated
* 400 BADREQUEST: "no albumname specified", "no new albumname specified", "album not available"
* 500 INTERNALSERVERERROR: "unknown error - updating in database failed"
---
2017-12-19 12:07:31 +01:00
### friendica/photo/create (POST; AUTH)
2017-12-19 12:07:31 +01:00
### friendica/photo/update (POST; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* photo_id (optional): if specified the photo with this id will be updated
* media (optional): image data as base64, only optional if photo_id is specified (new upload must have media)
* desc (optional): description for the photo, updated when photo_id is specified
* album: name of the album to be deleted (always necessary)
* album_new (optional): can be used to change the album of a single photo if photo_id is specified
* 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;
2017-05-19 22:37:45 +02:00
on update: keys need to be present with empty values for changing a private photo to public
both calls point to one function for creating AND updating photos.
Saves data for the scales 0-2 to database (see above for scale description).
Call adds non-visible entries to items table to enable authenticated contacts to comment/like the photo.
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.
2017-05-19 22:37:45 +02:00
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.
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* new photo uploaded: JSON return with photo data (see friendica/photo)
* photo updated - changed photo data: JSON return with photo data (see friendica/photo)
* photo updated - changed info: JSON return {"result":"updated","message":"Image id 'xyz' has been updated."}
* photo updated - nothing changed: JSON return {"result":"cancelled","message":"Nothing to update for image id 'xyz'."}
On error:
2017-12-19 12:07:31 +01:00
* 403 FORBIDDEN: if not authenticated
* 400 BADREQUEST: "no albumname specified", "no media data submitted", "photo not available", "acl data invalid"
* 500 INTERNALSERVERERROR: "image size exceeds PHP config settings, file was rejected by server",
"image size exceeds Friendica Config setting (uploaded size: x)",
"unable to process image data",
"image upload failed",
"unknown error - uploading photo failed, see Friendica log for more information",
"unknown error - update photo entry in database failed",
"unknown error - this error on uploading or updating a photo should never happen"
---
2017-12-19 12:07:31 +01:00
### friendica/photo/delete (DELETE; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* photo_id: id of the photo to be deleted
deletes a single image with the specified id, is not reversible -> ensure that client is asking user for being sure to do this
Sets item table entries for this photo to deleted = 1
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* JSON return {"result":"deleted","message":"photo with id 'xyz' has been deleted from server."}
On error:
2017-12-19 12:07:31 +01:00
* 403 FORBIDDEN: if not authenticated
* 400 BADREQUEST: "no photo_id specified", "photo not available"
* 500 INTERNALSERVERERROR: "unknown error on deleting photo", "problem with deleting items occurred"
---
2017-12-19 12:07:31 +01:00
### friendica/direct_messages_setseen (GET; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* id: id of the message to be updated as seen
#### Return values
On success:
2017-12-19 12:07:31 +01:00
* JSON return {"result":"ok","message":"message set to seen"}
On error:
2017-12-19 12:07:31 +01:00
* different JSON returns {"result":"error","message":"xyz"}
---
2017-12-19 12:07:31 +01:00
### friendica/direct_messages_search (GET; AUTH)
2017-12-19 12:07:31 +01:00
#### Parameters
2017-12-19 12:07:31 +01:00
* searchstring: string for which the API call should search as '%searchstring%' in field 'body' of all messages of the authenticated user (caption ignored)
#### Return values
2017-12-19 12:07:31 +01:00
Returns only tested with JSON, XML might work as well.
On success:
2017-12-19 12:07:31 +01:00
* JSON return {"success":"true","search_results": array of found messages}
* JSOn return {"success":"false","search_results":"nothing found"}
On error:
2017-12-19 12:07:31 +01:00
* different JSON returns {"result":"error","message":"searchstring not specified"}
---
2017-12-19 12:07:31 +01:00
### friendica/profile/show (GET; AUTH)
2017-12-19 12:07:31 +01:00
show data of all profiles or a single profile of the authenticated user
#### Parameters
2017-12-19 12:07:31 +01:00
* profile_id: id of the profile to be returned (optional, if omitted all profiles are returned by default)
#### Return values
2017-12-19 12:07:31 +01:00
On success: Array of:
* multi_profiles: true if user has activated multi_profiles
* global_dir: URL of the global directory set in server settings
* friendica_owner: user data of the authenticated user
* profiles: array of the profile data
On error:
2017-05-19 22:37:45 +02:00
HTTP 403 Forbidden: when no authentication was provided
HTTP 400 Bad Request: if given profile_id is not in the database or is not assigned to the authenticated user
General description of profile data in API returns:
2017-12-19 12:07:31 +01:00
* profile_id
* profile_name
* is_default: true if this is the public profile
* hide_friends: true if friends are hidden
* profile_photo
* profile_thumb
* publish: true if published on the server's local directory
* net_publish: true if published to global_dir
* description ... homepage: different data fields from 'profile' table in database
* users: array with the users allowed to view this profile (empty if is_default=true)
---
## Not Implemented API calls
2017-12-19 12:07:31 +01:00
The following API calls are implemented in GNU Social but not in Friendica: (incomplete)
* statuses/retweets_of_me
* friendships/create
* friendships/destroy
* friendships/exists
* friendships/show
* account/update_profile_background_image
* blocks/create
* blocks/destroy
2017-05-19 22:37:45 +02:00
The following API calls from the Twitter API are not implemented in either Friendica or GNU Social:
* statuses/mentions_timeline
* statuses/retweets/:id
* statuses/oembed
* statuses/retweeters/ids
* statuses/lookup
* direct_messages/show
* friendships/no_retweets/ids
* friendships/outgoing
* friendships/update
* friends/list
* friendships/lookup
* account/settings
* account/update_delivery_device
* blocks/ids
* users/show
* users/search
* account/remove_profile_banner
* account/update_profile_banner
* users/profile_banner
* mutes/users/create
* mutes/users/destroy
* mutes/users/ids
* mutes/users/list
* users/suggestions/:slug
* users/suggestions
* users/suggestions/:slug/members
* favorites/list
* lists/list
* lists/members/destroy
* lists/memberships
* lists/subscribers
* lists/subscribers/create
* lists/subscribers/show
* lists/subscribers/destroy
* lists/members/create_all
* lists/members/show
* lists/members
* lists/members/create
* lists/show
* lists/subscriptions
* lists/members/destroy_all
* saved_searches/show/:id
* saved_searches/create
* saved_searches/destroy/:id
* geo/id/:place_id
* geo/reverse_geocode
* geo/search
* geo/place
* trends/place
* trends/available
* help/configuration
* help/languages
* help/privacy
* help/tos
* trends/closest
* users/report_spam
---
---
## Usage Examples
2017-12-19 12:07:31 +01:00
### BASH / cURL
2017-12-19 12:07:31 +01:00
```bash
/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"
2017-12-19 12:07:31 +01:00
```
### Python
2017-12-19 12:07:31 +01:00
The [RSStoFriendika](https://github.com/pafcu/RSStoFriendika) code can be used as an example of how to use the API with python.
2017-09-24 12:05:28 +02:00
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))
There is also a [module for python 3](https://bitbucket.org/tobiasd/python-friendica) for using the API.