API
From Facebook Developer Wiki
The article contains extended documentation about the Facebook API. With the API, you can add social context to your application by utilizing profile, friend, Page, group, photo, and event data.
Contents |
REST Interface
The API uses a REST-like interface. This means that our Facebook method calls are made over the internet by sending HTTP GET or POST requests to the Facebook API REST server . Nearly any computer language can be used to communicate over HTTP with the REST server.
Note: If you manually form your HTTP POST requests to Facebook, you must include the request data in the POST body. In addition, you should include a Content-Type: header of application/x-www-form-urlencoded.
API Methods
- admin.getAllocation
- Returns the current allocation limit for your application for the specified integration point.
- admin.getAppProperties
- Returns values of properties for your applications from the Facebook Developer application.
- admin.getMetrics
- Returns specified metrics for your application, given a time period.
- admin.getRestrictionInfo
- Returns the demographic restrictions for the application.
- admin.setAppProperties
- Sets values for properties for your applications in the Facebook Developer application.
- admin.setRestrictionInfo
- Sets the demographic restrictions for the application.
- admin.banUsers
- Prevents users from accessing an application's canvas page and its forums.
- admin.unbanUsers
- Unbans users previously banned with admin.banUsers.
- admin.getBannedUsers
- Returns the list of users who have been banned from the application.
- application.getPublicInfo
- Returns public information about a given application (not necessarily your own).
- auth.createToken
- Creates an
auth_tokento be passed in as a parameter to login.php and then to auth.getSession after the user has logged in. - auth.expireSession
- Expires the session indicated in the API call, for your application.
- auth.getSession
- Returns the session key bound to an auth_token, as returned by auth.createToken or in the callback URL.
- auth.promoteSession
- Returns a temporary session secret associated to the current existing session, for use in a client-side component to an application.
- auth.revokeAuthorization
- If this method is called for the logged in user, then no further API calls can be made on that user's behalf until the user decides to authorize the application again.
- auth.revokeExtendedPermission
- Removes a specific extended permission that a user explicitly granted to your application.
- batch.run
- Execute a list of individual API calls in a single batch.
- comments.add (BETA)
- Adds a comment for a given
xidon behalf of a user. Calls with a session secret may only act on behalf of the session user. - comments.get
- Returns all comments for a given
xidposted through fb:comments. This method is a wrapper for the FQL query on the comment FQL table. - comments.remove (BETA)
- Removed a comment for a given
xidby comment_id. Calls with a session secret may only act on behalf of the session user. - data.getCookies (BETA)
- Returns all cookies for a given user and application.
- data.setCookie (BETA)
- Sets a cookie for a given user and application.
- events.cancel
- Cancels an event. The application must be an admin of the event.
- events.create
- Creates an event on behalf of the user if the application has an active session; otherwise it creates an event on behalf of the application.
- events.edit
- Edits an existing event. The application must be an admin of the event.
- events.get
- Returns all visible events according to the filters specified.
- events.getMembers
- Returns membership list data associated with an event.
- events.rsvp
- Sets the attendance option for the current user.
- fbml.deleteCustomTags
- Deletes one or more custom tags you previously registered for the calling application with fbml.registerCustomTags.
- fbml.getCustomTags
- Returns the custom tag definitions for tags that were previously defined using fbml.registerCustomTags.
- fbml.refreshImgSrc
- Fetches and re-caches the image stored at the given URL.
- fbml.refreshRefUrl
- Fetches and re-caches the content stored at the given URL.
- fbml.registerCustomTags
- Registers custom tags you can include in your that applications' FBML markup. Custom tags consist of FBML snippets that are rendered during parse time on the containing page that references the custom tag.
- fbml.setRefHandle
- Associates a given "handle" with FBML markup so that the handle can be used within the fb:ref FBML tag.
- fbml.uploadNativeStrings
- Lets you insert text strings into the Facebook Translations database so they can be translated.
- feed.deactivateTemplateBundleByID
- Deactivates a previously registered template bundle.
- feed.getRegisteredTemplateBundleByID
- Retrieves information about a specified template bundle previously registered by the requesting application.
- feed.getRegisteredTemplateBundles
- Retrieves the full list of all the template bundles registered by the requesting application.
- feed.publishTemplatizedAction
- Publishes a Mini-Feed story to the Facebook Page corresponding to the
page_actor_idparameter. - Note: This method is deprecated for actions taken by users only; it still works for actions taken by Facebook Pages.
- feed.publishUserAction
- Publishes a story on behalf of the user owning the session, using the specified template bundle.
- feed.registerTemplateBundle
- Builds a template bundle around the specified templates, registers them on Facebook, and responds with a template bundle ID that can be used to identify your template bundle to other Feed-related API calls.
- fql.query
- Evaluates an FQL (Facebook Query Language) query.
- fql.multiquery
- Evaluates a series of FQL (Facebook Query Language) queries in one call and returns the data at one time.
- friends.areFriends
- Returns whether or not each pair of specified users is friends with each other.
- friends.get
- Returns the identifiers for the current user's Facebook friends.
- friends.getAppUsers
- Returns the identifiers for the current user's Facebook friends who have authorized the specific calling application.
- friends.getLists
- Returns the identifiers for the current user's Facebook friend lists.
- friends.getMutualFriends
- Returns the identifiers for the requested users' Mutual Facebook friends.
- groups.get
- Returns all visible groups according to the filters specified.
- groups.getMembers
- Returns membership list data associated with a group.
- intl.getTranslations (BETA)
- Returns an array of strings from your application that you submitted for translation. This call returns the original native strings, the best (or all) translations of native strings into a given locale, whether the string has been approved, and by whom.
- links.get (BETA)
- Returns all links the user has posted on their profile through your application.
- links.post (BETA)
- Lets a user post a link on their Wall through your application.
- liveMessage.send (BETA)
- Sends a "message" directly to a user's browser, which can be handled in FBJS.
- notes.create (BETA)
- Lets a user write a Facebook note through your application.
- notes.delete (BETA)
- Lets a user delete a Facebook note that was written through your application.
- notes.edit (BETA)
- Lets a user edit a Facebook note through your application.
- notes.get (BETA)
- Returns a list of all of the visible notes written by the specified user.
- notifications.get
- Returns information on outstanding Facebook notifications for current session user.
- notifications.send
- Sends a notification to a set of users.
- notifications.sendEmail
- Sends an email to the specified users who have the application.
- pages.getInfo
- Returns all visible pages to the filters specified.
- pages.isAdmin
- Checks whether the logged-in user is the admin for a given Page.
- pages.isAppAdded
- Checks whether the Page has added the application.
- pages.isFan
- Checks whether a user is a fan of a given Page.
- photos.addTag
- Adds a tag with the given information to a photo.
- photos.createAlbum
- Creates and returns a new album owned by the current session user.
- photos.get
- Returns all visible photos according to the filters specified.
- photos.getAlbums
- Returns metadata about all of the photo albums uploaded by the specified user.
- photos.getTags
- Returns the set of user tags on all photos specified.
- photos.upload
- Uploads a photo owned by the current session user and returns the new photo.
- profile.getFBML
- Gets the FBML that is currently set for a user's profile.
- profile.getInfo
- Returns the specified user's application info section for the calling application.
- profile.getInfoOptions
- Returns the options associated with the specified field for an application info section.
- profile.setFBML
- Sets the FBML for a user's profile, including the content for both the profile box and the profile actions.
- profile.setInfo
- Configures an application info section that the specified user can install on the Info tab of her profile.
- profile.setInfoOptions
- Specifies the objects for a field for an application info section.
- status.get (BETA)
- Returns the user's current and most recent statuses.
- status.set (BETA)
- Updates a user's Facebook status through your application. This is a streamlined version of users.setStatus.
- stream.addComment (BETA)
- This method adds a comment to a post that was already published to a user's Wall.
- stream.addLike (BETA)
- This method lets a user add a like to any post the user can see. A user can like each post only once.
- stream.get (BETA)
- This method returns an object (in JSON-encoded or XML format) that contains the stream from the perspective of a specific viewer -- a user or a Facebook Page.
- stream.getComments (BETA)
- This method returns all comments associated with a post in a user's stream. This method returns comments only if the user who owns the post (that is, the user published the post to his or her profile) has authorized your application.
- stream.getFilters (BETA)
- This method returns any filters a user has specified for his or her home page stream.
- stream.publish (BETA)
- This method publishes a post into the stream on the user's Wall and News Feed. This post also appears in the user's friends' streams (their News Feeds).
- stream.remove (BETA)
- This method removes a post from a user's Wall. The post also gets removed from the user's and the user's friends' News Feeds. Your application may only remove posts that were created through it.
- stream.removeComment (BETA)
- This method removes a comment from a post.
- stream.removeLike (BETA)
- This method removes a like a user added to a post.
- users.getInfo
- Returns a wide array of user-specific information for each user identifier passed, limited by the view of the current user.
- users.getLoggedInUser
- Gets the user ID (
uid) associated with the current session. - users.getStandardInfo
- Returns an array of user-specific information for use by the application itself.
- users.hasAppPermission
- Checks whether the user has opted in to an extended application permission.
- users.isAppUser
- Returns whether the user (either the session user or user specified by UID) has authorized the calling application.
- users.isVerified (BETA)
- Returns whether the user is a verified Facebook user.
- users.setStatus
- Updates a user's Facebook status.
- video.getUploadLimits (BETA)
- Returns the file size and length limits for a video that the current user can upload through your application.
- video.upload
- Uploads a video owned by the current session user and returns the video.
Batching API
Data Store API BETA
Facebook Connect API Methods
You can use most any Platform API call Facebook Connect. In addition, here are the API methods specific to Connect:
- connect.getUnconnectedFriendsCount
- This method returns the number of friends of the current user who have accounts on your site, but have not yet connected their accounts.
- connect.registerUsers
- This method is used to create an association between an external user account and a Facebook user account.
- connect.unregisterUsers
- This method allows a site to unregister a previously registered account (using connect.registerUsers).
Permissions API BETA
Facebook Platform for Mobile
The following methods apply to Facebook Platform for Mobile:
Deprecated API Methods
- Admin.getDailyMetrics
- This method is deprecated. Please use Admin.getMetrics instead.
- feed.publishActionOfUser
- This method is deprecated. Please use feed.publishUserAction instead.
- feed.publishStoryToUser
- This method is deprecated. Please use feed.publishUserAction instead.
- marketplace.createListing
- This method is deprecated. Create or modify a listing in Marketplace.
- marketplace.getCategories
- This method is deprecated. Returns all the Marketplace categories.
- marketplace.getListings
- This method is deprecated. Return all Marketplace listings either by listing ID or by user.
- marketplace.getSubCategories
- This method is deprecated. Returns the Marketplace subcategories for a particular category.
- marketplace.removeListing
- This method is deprecated. Remove a listing from Marketplace.
- marketplace.search
- This method is deprecated. Search Marketplace for listings filtering by category, subcategory and a query string.
- users.isAppAdded
- This method is deprecated. Please use users.isAppUser instead.
Additional Documentation
- Authorizing Applications
- Error codes
- Extended permissions
- Photo uploads
- Marketplace Listing Attributes
- Post-Remove URL
- Storable Information
