Facebook API

Get Facebook data as clean JSON with one key: 29 endpoints, 2 to 3 credits per call, the same response shape as every other platform.

What you get#

Onekey exposes Facebook as 29 endpoints behind one API key: 9 endpoints return one record (data is an object) and 20 endpoints return a list (data is an array). Every answer uses the same envelope (success, data, metadata, error), the cost is reported in metadata.credits_charged, and fields are mapped onto the unified schema so the code you write for Facebook also works for the rest of the social networks category.

Endpoints#

EndpointWhat it doesParametersCreditsStatus
ad_librarySearch the Facebook/Instagram Ad Library (public political/issue and EU ads) by keyword.q*, country2beta
adlibrary_adGet Facebook Ad Library ad details.url, id2beta needs a pack
adlibrary_ad_transcriptGet a Facebook Ad Library video ad transcript.url*2beta needs a pack
adlibrary_company_adsList Facebook Ad Library company ads.company_name, page_id, cursor3beta needs a pack
adlibrary_search_companiesSearch Facebook Ad Library companies.query*3beta needs a pack
event_detailsGet details for a Facebook event.url, id2beta needs a pack
eventsList Facebook events for a city.url*, cursor2beta needs a pack
events_searchSearch Facebook events by keyword.query*, cursor2beta needs a pack
groupGet a Facebook group.url, group_id2beta needs a pack
group_postsList Facebook group posts.url*, cursor2beta needs a pack
marketplace_itemGet a Facebook Marketplace item.url, id2beta needs a pack
marketplace_location_searchSearch Facebook Marketplace locations.query*2beta needs a pack
marketplace_searchSearch Facebook Marketplace listings.query*, lat*, lng*, cursor2beta needs a pack
pageFacebook page: name, about, category, followers, likes, link, picture.page*2beta may need a pack
page_eventsEvents of a Facebook page.page*, cursor2beta may need a pack
page_photosPhotos uploaded by a Facebook page.page*, cursor2beta may need a pack
page_postsRecent public posts of a Facebook page.page*, cursor2beta may need a pack
page_videosVideos published by a Facebook page.page*2beta
postA single Facebook post with reaction/comment/share counts.post_id*2beta may need a pack
post_comment_repliesList replies to a Facebook post comment.feedback_id*, expansion_token*, cursor2beta needs a pack
post_commentsComments on a Facebook post.post_id*, cursor2beta may need a pack
post_transcriptGet Facebook video transcript.url*2beta needs a pack
profile_fullFacebook profile, recent posts, and computed analytics in one call.url*2beta needs a pack
profile_reels_fullFacebook profile reels with exact views, likes, comments, and shares merged in, in one call.url*3beta needs a pack
search_groupsSearch Facebook groups by keyword.query*, cursor2beta needs a pack
search_pagesSearch public Facebook pages by name (Pages Search, needs Page Public Metadata Access).q*2beta
search_peopleSearch Facebook people by keyword.query*, cursor2beta needs a pack
search_postsSearch Facebook posts by keyword.query*, cursor2beta needs a pack
search_videosSearch Facebook videos by keyword.query*, cursor2beta needs a pack

A * marks a required parameter. Each endpoint name links to its reference page with the full parameter table, caching window and a recorded response.

Make a request#

This calls facebook.adlibrary_ad (2 credits, beta). Replace YOUR_API_KEY with your key; sign up, no card. 1,000 free credits cover the open-platform endpoints. Hard-to-reach platforms (X, TikTok, Instagram, Reddit, and others marked on their page) need a verified email and a purchased pack.

curl "https://api.onekey.dev/v1/facebook/adlibrary_ad?url=https%3A%2F%2Fwww.facebook.com%2Fnasa" \
  -H "x-api-key: YOUR_API_KEY"

Fields you get back#

These unified fields come back from Facebook, with the same names as on every other platform. The count is how many of its 29 mapped endpoints return the field; a field the source lacks is null, never missing. 12 platform-specific fields (ext.<name>) come on top, documented on each endpoint page.

FieldTypeEndpoints
content.textstring17
content.createdAtISO 8601 date14
content.idstring12
engagement.likesinteger11
entity.idstring11
media.thumbnailUrlURL11
entity.urlURL10
content.urlURL9
entity.namestring9
author.displayNamestring8
engagement.commentsinteger8
author.usernamestring7
content.titlestring7
engagement.viewsinteger7
entity.descriptionstring7
author.idstring6
engagement.sharesinteger6
entity.locationstring5
author.avatarUrlURL4
author.followersinteger3
author.urlURL3
event.endDateISO 8601 date3
event.startDateISO 8601 date3
media.durationSecondsnumber3
author.verifiedboolean2
content.languagestring2
entity.createdAtISO 8601 date2
entity.statusstring2
listing.currencystring2
listing.pricenumber2
listing.sellerstring2
media.urlURL2
author.biostring1
author.contentCountinteger1
author.followinginteger1
author.websiteURL1
entity.categorystring1
place.addressstring1
place.citystring1
place.latnumber1
place.lonnumber1

The full schema is in Unified schema.

Pricing#

Facebook calls cost 2 to 3 credits, flat per endpoint. Free when served from cache (0.2 credit for a cached response over 100 KB). Invalid, failed or not-found calls are not charged. See pricing for credit packs.