In this example, we’ll demonstrate how to leverage our Facebook Marketplace API to extract a product details from the marketplace.

Requirements

  • MrScraper console account.
  • MrScraper API token that you can get by following the steps here.

Facebook Example

In this example, we’ll retrieve a product from Facebook Marketplace, returning results based on the defined schema.

Follow the steps below to use our Facebook Marketplace API to extract a product:

You can define the category based on your preferences.

  1. Use the request body below:
curl --request POST \
  --url https://app.mrscraper.com/api/scrapers/fb-marketplace/create-and-run \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<name>",
  "urls": [
    "https://www.facebook.com/marketplace"
  ],
  "webhook_url": "<your_webhook_url>",
  "zip_codes": "<your_location_zip_code>",
  "categories": [
    {
      "name": "<category_name>",
      "url": "<category_facebook_url>"
    }
  ]
}'
  1. Replace Authorization with your API token and Set the URL to Facebook marketplace and the category URL to your preferences.
  2. The above request body will return a JSON response based on the specified schema and category.
To use this endpoint for your use case, please refer to this section.

Use Cases

You can use our Facebook API to scrape a product data for the following use cases:

In this example, we’ll retrieve a product data. Follow the steps below:

  1. Use the request body below:
curl --request POST \
  --url https://app.mrscraper.com/api/scrapers/fb-marketplace/create-and-run \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "Test Latest",
  "urls": [
    "https://www.facebook.com/marketplace"
  ],
  "webhook_url": "https://vnctkevin.com",
  "zip_codes": "80004",
  "categories": [
    {
      "name": "Air Conditioners",
      "url": "https://www.facebook.com/marketplace/category/air-conditioners/"
    }
  ]
}'
  1. Replace Authorization with your API token.
  2. The above request body will return the following JSON response:
{
    "results": [
        {
            "scraping_run_id": 371688,
            "user_id": 5573,
            "scraper_name": "Test Latest",
            "scrapped_url": "80004",
            "scraped_url": "80004",
            "scraper_id": 3273,
            "status": "running",
            "updated_at": "2024-10-02T08:36:44.000000Z",
            "created_at": "2024-10-02T08:36:43.000000Z",
            "id": 1161412,
            "scraper": {
                "id": 3273,
                "user_id": 5573,
                "sharing": false,
                "share_uuid": null,
                "name": "Test Latest",
                "type": "fb_marketplace",
                "urls": "https://www.facebook.com/marketplace",
                "pdf_urls": "Default",
                "ai_prompt": null,
                "ai_scope": null,
                "headers": null,
                "cookies": null,
                "user_agent": null,
                "disabled_resources": null,
                "delay": 0,
                "html_wanted": false,
                "screenshot_wanted": false,
                "screenshot_type": null,
                "locale": null,
                "scheduled": false,
                "cron": null,
                "cron_timezone": "UTC",
                "paginate": 0,
                "pagination_type": null,
                "infinite_pagination_type": null,
                "infinite_pagination_seconds": null,
                "infinite_pagination_text": null,
                "infinite_pagination_css_selector": null,
                "infinite_pagination_n_selector": null,
                "load_more_selector": null,
                "pagination_query_parameter": null,
                "pagination_next_page_selector": null,
                "pagination_limit_type": null,
                "pagination_max_page": null,
                "max_next_page": null,
                "pagination_max_variable": null,
                "created_at": "2024-10-02T08:36:43.000000Z",
                "updated_at": "2024-10-02T08:36:43.000000Z",
                "cron_minutes": "*",
                "cron_minutes_n_detail": null,
                "cron_minutes_x_detail": null,
                "cron_hours": "*",
                "cron_hours_n_detail": null,
                "cron_hours_x_detail": null,
                "cron_day_of_month": "*",
                "cron_day_of_month_x_detail": null,
                "cron_month": "*",
                "cron_month_x_detail": null,
                "cron_day_of_week": "*",
                "cron_day_of_week_x_detail": null,
                "click_action_enabled": false,
                "click_action_selector": null,
                "click_action_wait": "no",
                "workflow": [
                    {
                        "type": "options",
                        "data": {
                            "webhook_url": "https://vnctkevin.com",
                            "zip_codes": "80004",
                            "categories": [
                                {
                                    "type": "category",
                                    "data": {
                                        "name": "Air Conditioners",
                                        "url": "https://www.facebook.com/marketplace/category/air-conditioners/"
                                    }
                                }
                            ]
                        }
                    }
                ],
                "version": 2,
                "proxy_type": "rotation",
                "proxy_host": null,
                "proxy_port": null,
                "proxy_username": null,
                "proxy_password": null,
                "parsers": null,
                "deleted_at": null
            }
        }
    ]
}