> For the complete documentation index, see [llms.txt](https://docs.scrapingdog.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scrapingdog.com/facebook-scraper-api/facebook-posts-scraper-api.md).

# Facebook Posts Scraper API

Each successful request will cost you **`5`** API credits.

You have to send a GET request to **`http://api.scrapingdog.com/facebook/posts`** with the below-given parameters.

### Parameters

#### Scrapingdog Parameters

| Parameter                                                          | Description                                                                                              |
| ------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| <p>api\_key<br></p><p><mark style="color:red;">required</mark></p> | <p>Your personal API key. Available on your dashboard <br><br>Type: <em><strong>String</strong></em></p> |

#### Search Query

| Parameter                                                 | Description                                                                                                                                                                                    |
| --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>id<br><br><mark style="color:red;">required</mark></p> | <p>This is the internal user ID of the Facebook profile, which you can get from Facebook Profile Scraper API from the <code>id</code> field.<br><br>Type: <em><strong>String</strong></em></p> |

#### Pagination

| Parameter         | Description                                                                                                 |
| ----------------- | ----------------------------------------------------------------------------------------------------------- |
| next\_page\_token | <p>The next\_page\_token is used to get the next page of results. <br><br>Type: <strong>String</strong></p> |

### API Example

{% tabs %}
{% tab title="cURL" %}

```bash
cURL "https://api.scrapingdog.com/facebook/posts?api_key=APIKEY&id=100044541544829"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

api_key = 'APIKEY'
id = '100044541544829'


params = {
    'api_key': api_key,
    'id': id
}

response = requests.get('https://api.scrapingdog.com/facebook/posts', params=params)

if response.status_code == 200:
    # Parse the JSON response using response.json()
    response_data = response.json()
    
    # Now you can work with the response_data as a Python dictionary
    print(response_data)
else:
    print(f'Request failed with status code: {response.status_code}')

```

{% endtab %}

{% tab title="Node JS" %}

```javascript
const axios = require('axios');

const api_key = 'APIKEY';
const id = '100044541544829';


const params = {
  api_key,
  id
};

axios
  .get('https://api.scrapingdog.com/facebook/posts', { params })
  .then((response) => {
    if (response.status === 200) {
      // Parse the JSON response
      const responseData = response.data;
      console.log(responseData);
    } else {
      console.error(`Request failed with status code: ${response.status}`);
    }
  })
  .catch((error) => {
    console.error('An error occurred:', error);
  });

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'httparty'
require 'json'

api_key = 'APIKEY'
id = '100044541544829'


# Define the API endpoint
endpoint = 'https://api.scrapingdog.com/facebook/posts'

# Create a hash with the query parameters
params = {
  api_key: api_key,
  id : id
}

# Make the GET request
response = HTTParty.get(endpoint, query: params)

# Check the HTTP response code
if response.code == 200
  # Parse the JSON response
  parsed_response = JSON.parse(response.body)
  puts parsed_response
else
  puts "Request failed with status code: #{response.code}"
end

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$api_key = 'APIKEY';
$id = '100044541544829';


// Create an array with the query parameters
$params = array(
    'api_key' => $api_key,
    'id' => $id
);

// Initialize cURL session
$ch = curl_init('https://api.scrapingdog.com/facebook/posts?' . http_build_query($params));

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the cURL request
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($httpCode === 200) {
        // Parse the JSON response
        $responseData = json_decode($response, true);
        print_r($responseData);
    } else {
        echo 'Request failed with status code: ' . $httpCode;
    }
}

// Close cURL session
curl_close($ch);
?>

```

{% endtab %}

{% tab title="Java" %}

```java
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.json.JSONObject;

public class TwitterApiExample {
    public static void main(String[] args) {
        String api_key = "APIKEY";
        String id = "100044541544829";


        String endpoint = "https://api.scrapingdog.com/facebook/posts";
        
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(endpoint + "?api_key=" + api_key + "&id=" + id)
                .get()
                .build();

        try {
            Response response = client.newCall(request).execute();
            ResponseBody responseBody = response.body();

            if (response.isSuccessful() && responseBody != null) {
                String jsonString = responseBody.string();
                JSONObject jsonResponse = new JSONObject(jsonString);
                System.out.println(jsonResponse.toString(4)); // Pretty print the JSON response
            } else {
                System.err.println("Request failed with status code: " + response.code());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

```

{% endtab %}
{% endtabs %}

### API Response

```json
{
    "pagination": {
        "has_next_page": true,
        "next_page_token": "Cg8Ob3JnYW5pY19jdXJzb3IJAAACb0FRSFN0YWNmcU50c3hZbWo3WHZjRUhyR2xiOTlBV29td2E0MDlWanJHMDhrNUZITGg2RUFrQ21FejBIclpBLTRnS0s1bFg4ZlNOYlpkQWs4N1B2eXFaQk5kcDBUZEdWN2NoRV82V2hPYmJSeE91RDUxNHFiMENSZ05nblZETENRaGFwRDZXbmpBdjR0NFptazMzSDJldmZWU0w0cThrM3NPOGd1dDRlbTVHRFNaSVlaOXNQc2Zzb2xYRllWTWdYWFYyNWQtMnN1REcyU1dCci1uaEVJbTYtNlhVbUtod3BUTmZtU1ZGSmI5V1Izdm9GaG8zalZfeC0wYXFTY2VZRjdCN2wxOWgzRGhqNHU0c1dmVmtYcUZwMExJMzBYX3dqSVRFdlVVcG9ZZl9KY0cwcmhLSUxXR3NNa1FER3o3UFA0Vzhxci1NRmR0VlVMV19TbWw0YnFPUmlpemhWYmdtbkpZd3ZSNFZ5VE1Kc1poR1RzQ2tSN1plcHZ0emlzeDdoclJ1SklpSG02X19HUzZ4R1dLOWlza21BOVpwUm1Sc0FMS3Y2bUFUUVh4SWh3eTJUVVZMVDZsRGVNWmFSVFBUUXBxRXg3bnRlTDNzc2tIMWs4VF9aMXN4Zmd0Q0tRY0FZYXdkOThYdXZyUUtzRWx3a2lIVC1SbTlEU25DM3ljalc3TlFCeG5YMkhOZkVCYW1KeXpMTmQ3Q1RKdnpaSEhSQUZfRFU0ZTlFcEVzbVI0Y05YNW1iMzRSYUplRTlReXF5WlJwdWxhS1ZKSnVSM2NpS3hBeDlaSDB3dlA0WE1qcFdZWTRpcGxoT3ZyRUpUYVEwDwlhZF9jdXJzb3IODw9nbG9iYWxfcG9zaXRpb24CAA8Gb2Zmc2V0AgAPEGxhc3RfYWRfcG9zaXRpb24C/wE="
    },
    "posts_data": [
        {
            "cache_id": "8051191019963556713",
            "post_id": "1393461115481927",
            "url": "https://www.facebook.com/reel/2166091230582141/",
            "likes": 6071,
            "shares": 941,
            "comments": 1874,
            "timestamp": 1757952119,
            "media": [
                {
                    "type": "Video",
                    "is_playable": false,
                    "url": "https://www.facebook.com/reel/2166091230582141/",
                    "image": "https://scontent-lax7-1.cdninstagram.com/v/t51.82787-10/549104239_18565912819020081_2330706867671026439_n.jpg?stp=dst-jpg_p565x565_tt6&_nc_cat=101&ccb=7-5&_nc_sid=c44d43&_nc_ohc=ZAW4lcZWvQIQ7kNvwGJMmay&_nc_oc=Adox_T58V_2KyssrrJv90IOFLV-6w5u3YHolkStQph--01UIaHUgWtQXTGbgPFTsxD4&_nc_ad=z-m&_nc_cid=0&_nc_zt=23&_nc_ht=scontent-lax7-1.cdninstagram.com&_nc_gid=HqxEmQM55KBrXMZ3MLc1yw&_nc_ss=7039b&oh=00_Af7dhJ6bG_EA7K_6I2w-IAc1GuP_cvv1tBdFWbn4KeOmSQ&oe=6A1D2FA4",
                    "viewer_image": null,
                    "id": "2166091230582141",
                    "accessibility_caption": null
                }
            ],
            "message": "Leave your limits at the surface. #JustDoIt",
            "actors": [
                {
                    "profile_picture": {
                        "uri": "https://scontent-lax3-2.cdninstagram.com/v/t39.30808-1/284964043_10159903868513445_7696353984967674128_n.jpg?stp=cp0_dst-jpg_s50x50_tt6&_nc_cat=1&ccb=7-5&_nc_sid=2d3e12&_nc_ohc=hsrXiQCvxVsQ7kNvwFx9Qc8&_nc_oc=AdqFFZBL_Riq6H2QcioP1UTjB67ooXA3c9vcjoFNSoIImuNBRpP2Y1EvbuOWmPmjDfo&_nc_ad=z-m&_nc_cid=0&_nc_zt=24&_nc_ht=scontent-lax3-2.cdninstagram.com&_nc_gid=HqxEmQM55KBrXMZ3MLc1yw&_nc_ss=7039b&oh=00_Af79r6G7BaeveHDCY5yfS8C_GDu9UtsE5qsUZGX4gpAn_A&oe=6A1D1A70"
                    },
                    "__typename": "User",
                    "id": "100044541544829",
                    "name": "Nike",
                    "__isEntity": "User",
                    "url": "https://www.facebook.com/nike"
                }
            ],
            "entities": [
                {
                    "entity": {
                        "__typename": "Hashtag",
                        "__isEntity": "Hashtag",
                        "url": "https://www.facebook.com/hashtag/justdoit",
                        "mobileUrl": "https://m.facebook.com/hashtag/justdoit",
                        "__isNode": "Hashtag",
                        "id": "363339373780672"
                    },
                    "entity_is_weak_reference": false,
                    "length": 9,
                    "offset": 34
                }
            ]
        },
        {
            "cache_id": "-7914302619487003160",
            "post_id": "1392071868954185",
            "url": "https://www.facebook.com/reel/752115997659579/",
            "likes": 4045,
            "shares": 500,
            "comments": 585,
            "timestamp": 1757807583,
            "media": [
                {
                    "type": "Video",
                    "is_playable": false,
                    "url": "https://www.facebook.com/reel/752115997659579/",
                    "image": "https://scontent-lax3-1.cdninstagram.com/v/t51.82787-10/548838919_18565615666020081_158902364425729178_n.jpg?stp=dst-jpg_p565x565_tt6&_nc_cat=104&ccb=7-5&_nc_sid=c44d43&_nc_ohc=AjG952bXWDcQ7kNvwGNgDO1&_nc_oc=AdoD_qPHbc0IrHUcxLlZtbzgt6PjW3J-VZaFQ-KAUfm1T45_AxRY-Jwdm-XUB_TLNT4&_nc_ad=z-m&_nc_cid=0&_nc_zt=23&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_gid=HqxEmQM55KBrXMZ3MLc1yw&_nc_ss=7039b&oh=00_Af7avuRONkcydCLlPd2-YJbngVqGP0wq7wYiesgbGtpZKw&oe=6A1D110D",
                    "viewer_image": null,
                    "id": "752115997659579",
                    "accessibility_caption": null
                }
            ],
            "message": "The longest jump is the one you didn’t doubt. #JustDoIt",
            "actors": [
                {
                    "profile_picture": {
                        "uri": "https://scontent-lax3-2.cdninstagram.com/v/t39.30808-1/284964043_10159903868513445_7696353984967674128_n.jpg?stp=cp0_dst-jpg_s50x50_tt6&_nc_cat=1&ccb=7-5&_nc_sid=2d3e12&_nc_ohc=hsrXiQCvxVsQ7kNvwFx9Qc8&_nc_oc=AdqFFZBL_Riq6H2QcioP1UTjB67ooXA3c9vcjoFNSoIImuNBRpP2Y1EvbuOWmPmjDfo&_nc_ad=z-m&_nc_cid=0&_nc_zt=24&_nc_ht=scontent-lax3-2.cdninstagram.com&_nc_gid=HqxEmQM55KBrXMZ3MLc1yw&_nc_ss=7039b&oh=00_Af79r6G7BaeveHDCY5yfS8C_GDu9UtsE5qsUZGX4gpAn_A&oe=6A1D1A70"
                    },
                    "__typename": "User",
                    "id": "100044541544829",
                    "name": "Nike",
                    "__isEntity": "User",
                    "url": "https://www.facebook.com/nike"
                }
            ],
            "entities": [
                {
                    "entity": {
                        "__typename": "Hashtag",
                        "__isEntity": "Hashtag",
                        "url": "https://www.facebook.com/hashtag/justdoit",
                        "mobileUrl": "https://m.facebook.com/hashtag/justdoit",
                        "__isNode": "Hashtag",
                        "id": "363339373780672"
                    },
                    "entity_is_weak_reference": false,
                    "length": 9,
                    "offset": 46
                }
            ]
        },
        {
            "cache_id": "-3786931348888444351",
            "post_id": "1388501259311246",
            "url": "https://www.facebook.com/reel/1168298751995880/",
            "likes": 2891,
            "shares": 341,
            "comments": 375,
            "timestamp": 1757462067,
            "media": [
                {
                    "type": "Video",
                    "is_playable": false,
                    "url": "https://www.facebook.com/reel/1168298751995880/",
                    "image": "https://scontent-lax3-2.cdninstagram.com/v/t51.71878-10/544903342_1488127749039210_7715950054603424720_n.jpg?stp=dst-jpg_p565x565_tt6&_nc_cat=111&ccb=7-5&_nc_sid=c44d43&_nc_ohc=hPvBB7oGgdQQ7kNvwFegvfF&_nc_oc=AdpSiRBBMiHHfxFZ8z627AW-NTfVDg4QiE761kn2VQz9lWzXohbdmAScK2p6LZQMetg&_nc_ad=z-m&_nc_cid=0&_nc_zt=23&_nc_ht=scontent-lax3-2.cdninstagram.com&_nc_gid=HqxEmQM55KBrXMZ3MLc1yw&_nc_ss=7039b&oh=00_Af61Fe2fs60AH4qrH5jHqqgoKqsqRknW7XDHvWiB_K_rkQ&oe=6A1D2A77",
                    "viewer_image": null,
                    "id": "1168298751995880",
                    "accessibility_caption": null
                }
            ],
            "message": "Two thoughts, you’re out. #justdoit",
            "actors": [
                {
                    "profile_picture": {
                        "uri": "https://scontent-lax3-2.cdninstagram.com/v/t39.30808-1/284964043_10159903868513445_7696353984967674128_n.jpg?stp=cp0_dst-jpg_s50x50_tt6&_nc_cat=1&ccb=7-5&_nc_sid=2d3e12&_nc_ohc=hsrXiQCvxVsQ7kNvwFx9Qc8&_nc_oc=AdqFFZBL_Riq6H2QcioP1UTjB67ooXA3c9vcjoFNSoIImuNBRpP2Y1EvbuOWmPmjDfo&_nc_ad=z-m&_nc_cid=0&_nc_zt=24&_nc_ht=scontent-lax3-2.cdninstagram.com&_nc_gid=HqxEmQM55KBrXMZ3MLc1yw&_nc_ss=7039b&oh=00_Af79r6G7BaeveHDCY5yfS8C_GDu9UtsE5qsUZGX4gpAn_A&oe=6A1D1A70"
                    },
                    "__typename": "User",
                    "id": "100044541544829",
                    "name": "Nike",
                    "__isEntity": "User",
                    "url": "https://www.facebook.com/nike"
                }
            ],
            "entities": [
                {
                    "entity": {
                        "__typename": "Hashtag",
                        "__isEntity": "Hashtag",
                        "url": "https://www.facebook.com/hashtag/justdoit",
                        "mobileUrl": "https://m.facebook.com/hashtag/justdoit",
                        "__isNode": "Hashtag",
                        "id": "363339373780672"
                    },
                    "entity_is_weak_reference": false,
                    "length": 9,
                    "offset": 26
                }
            ]
        }
    ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.scrapingdog.com/facebook-scraper-api/facebook-posts-scraper-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
