|
| 1 | +# Facebook Pages API examples for SocQ |
| 2 | + |
| 3 | +[](https://socq.ai/apis/facebook/pages?utm_source=github&utm_medium=repository&utm_campaign=facebook-pages-api) |
| 4 | +[](https://docs.socq.ai/api-manual/facebook/pages) |
| 5 | +[](LICENSE) |
| 6 | +[](https://github.com/SocQAPI/facebook-pages-api/actions/workflows/check.yml) |
| 7 | + |
| 8 | +Collect public Facebook Page profile details, contact fields, visible follower and like counts, and page metadata from one or more Page URLs. |
| 9 | + |
| 10 | +[Try Facebook Pages API](https://socq.ai/apis/facebook/pages?utm_source=github&utm_medium=repository&utm_campaign=facebook-pages-api) |
| 11 | +· [Get an API key](https://socq.ai/dashboard/api-key?utm_source=github&utm_medium=repository&utm_campaign=facebook-pages-api) |
| 12 | +· [Documentation](https://docs.socq.ai/api-manual/facebook/pages) |
| 13 | +· [All SocQ examples](https://github.com/SocQAPI/socq-examples) |
| 14 | + |
| 15 | +## Use cases |
| 16 | + |
| 17 | +- **Brand page monitoring:** Collect public Page identity, category, contact, and audience metrics for owned or competitor Page tracking. |
| 18 | +- **Content performance research:** Compare public Page categories, descriptions, contact coverage, follower counts, ratings, and visible audience signals. |
| 19 | +- **Reporting and BI pipelines:** Send normalized public Page records into dashboards, spreadsheets, warehouses, or product review tools. |
| 20 | +- **Media archive workflows:** Store Page URLs, images, descriptions, contact fields, and visible metrics for later review or reporting. |
| 21 | + |
| 22 | +## API behavior |
| 23 | + |
| 24 | +- Submit one or more publicly accessible Facebook Page URLs. |
| 25 | +- Each accessible Page can produce one normalized record. |
| 26 | +- Contact fields, ratings, reviews, images, and audience metrics are optional public fields. |
| 27 | +- Restricted, removed, or login-only Page content is outside the endpoint scope. |
| 28 | + |
| 29 | +All requests use the shared asynchronous flow: |
| 30 | + |
| 31 | +```text |
| 32 | +submit -> task_id -> poll task -> read every cursor page -> save results |
| 33 | +``` |
| 34 | + |
| 35 | +## Quick start |
| 36 | + |
| 37 | +```bash |
| 38 | +cp .env.example .env |
| 39 | +export SOCQ_API_KEY="your-api-key" |
| 40 | +``` |
| 41 | + |
| 42 | +Run the complete Node.js workflow: |
| 43 | + |
| 44 | +```bash |
| 45 | +cd node |
| 46 | +npm start |
| 47 | +``` |
| 48 | + |
| 49 | +Run the complete Python workflow: |
| 50 | + |
| 51 | +```bash |
| 52 | +python3 -m pip install -r python/requirements.txt |
| 53 | +python3 python/main.py |
| 54 | +``` |
| 55 | + |
| 56 | +Both examples load `payload.example.json`, retry transient API responses, wait |
| 57 | +for task completion, read every cursor page, and save a public Page directory with identity, contact, and audience fields to |
| 58 | +`output/results.json`. |
| 59 | + |
| 60 | +Never expose `SOCQ_API_KEY` in browser code, mobile apps, public repositories, |
| 61 | +screenshots, fixtures, or logs. |
| 62 | + |
| 63 | +## Request |
| 64 | + |
| 65 | +```http |
| 66 | +POST https://api.socq.ai/v1/facebook/pages |
| 67 | +Authorization: Bearer <SOCQ_API_KEY> |
| 68 | +Content-Type: application/json |
| 69 | +``` |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "urls": [ |
| 74 | + "https://www.facebook.com/example-page" |
| 75 | + ] |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +The submit response contains `data.task_id`. Poll the task endpoint until |
| 80 | +`data.status` becomes `succeeded` or `failed`, then continue with |
| 81 | +`data.results.next_cursor` while `data.results.has_more` is `true`. |
| 82 | + |
| 83 | +## Complete workflow example |
| 84 | + |
| 85 | +The Node.js and Python programs implement the production-shaped happy path: |
| 86 | + |
| 87 | +1. Load and validate configuration. |
| 88 | +2. Submit the endpoint-specific payload. |
| 89 | +3. Retry rate-pressure and transient server responses with bounded backoff. |
| 90 | +4. Poll the asynchronous task with a ten-minute application timeout. |
| 91 | +5. Stop cleanly on a failed task and surface the public error message. |
| 92 | +6. Read all cursor pages instead of silently returning only the first page. |
| 93 | +7. Write a stable JSON artifact containing task metadata and normalized records. |
| 94 | + |
| 95 | +Use the synthetic files in `fixtures/` for tests and documentation. They do |
| 96 | +not contain customer, account, or production data. |
| 97 | + |
| 98 | +## Production notes |
| 99 | + |
| 100 | +See [`docs/production-notes.md`](docs/production-notes.md) for validation, |
| 101 | +retry, timeout, pagination, deduplication, logging, and endpoint-specific |
| 102 | +guidance. |
| 103 | + |
| 104 | +## Responsible use and platform scope |
| 105 | + |
| 106 | +- Use only publicly accessible Facebook Pages, posts, comments, and fields supported by the selected endpoint. |
| 107 | +- Do not use the examples to access private profiles, closed groups, restricted content, login-only surfaces, or authentication controls. |
| 108 | +- SocQ is not an official API of the represented social platform and is not affiliated with or endorsed by that platform. |
| 109 | +- Before production use, assess the laws, platform terms, privacy obligations, and retention requirements that apply to your organization and use case. |
| 110 | +- Collect only the fields needed for a defined purpose, restrict access, set retention periods, and support correction or deletion workflows where required. |
| 111 | +- Platform names and trademarks belong to their respective owners. |
| 112 | + |
| 113 | +This section describes the public-data boundary; it is not legal advice or a |
| 114 | +guarantee that every use case is permitted in every jurisdiction. |
| 115 | + |
| 116 | +## Repository contents |
| 117 | + |
| 118 | +| Path | Purpose | |
| 119 | +| --- | --- | |
| 120 | +| [`curl/request.md`](curl/request.md) | Copy-paste submit, poll, and pagination requests | |
| 121 | +| [`node/index.mjs`](node/index.mjs) | Complete Node.js workflow | |
| 122 | +| [`python/main.py`](python/main.py) | Complete Python workflow | |
| 123 | +| [`payload.example.json`](payload.example.json) | Safe endpoint-specific request body | |
| 124 | +| [`fixtures/`](fixtures) | Synthetic submit and task response shapes | |
| 125 | +| [`docs/production-notes.md`](docs/production-notes.md) | Production integration guidance | |
0 commit comments