{"id":19640151,"url":"https://github.com/gearplug/facebookmarketing-python","last_synced_at":"2025-04-28T11:31:03.859Z","repository":{"id":57428091,"uuid":"101198138","full_name":"GearPlug/facebookmarketing-python","owner":"GearPlug","description":"Facebook Marketing API wrapper written in python","archived":false,"fork":false,"pushed_at":"2023-03-27T21:21:33.000Z","size":75,"stargazers_count":24,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-18T06:54:04.951Z","etag":null,"topics":["api","facebook","facebook-api","facebook-marketing-api","facebook-marketing-automation","marketing","python","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GearPlug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-23T15:48:05.000Z","updated_at":"2024-12-21T00:43:31.000Z","dependencies_parsed_at":"2022-09-19T04:20:25.857Z","dependency_job_id":null,"html_url":"https://github.com/GearPlug/facebookmarketing-python","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Ffacebookmarketing-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Ffacebookmarketing-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Ffacebookmarketing-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GearPlug%2Ffacebookmarketing-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GearPlug","download_url":"https://codeload.github.com/GearPlug/facebookmarketing-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304791,"owners_count":21567939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","facebook","facebook-api","facebook-marketing-api","facebook-marketing-automation","marketing","python","wrapper"],"created_at":"2024-11-11T14:04:49.373Z","updated_at":"2025-04-28T11:31:03.451Z","avatar_url":"https://github.com/GearPlug.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# facebookmarketing-python\n\nfacebookmarketing is an API wrapper for Facebook and Instagram written in Python.\n\n## Installing\n```\npip install facebookmarketing-python\n```\n\n## Facebook Usage\n\n#### Client instantiation\n```\nfrom facebookmarketing.client import Client\n\nclient = Client('APP_ID', 'APP_SECRET', 'v4.0')\n```\n\n### OAuth 2.0\n\nFor more information: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/\n\n#### Get authorization url\n```\nurl = client.authorization_url('REDIRECT_URL', 'STATE', ['pages_manage_ads', 'pages_manage_metadata', 'pages_read_engagement', 'leads_retrieval'])\n```\n\n#### Exchange the code for an access token\n```\nresponse = client.exchange_code('REDIRECT_URL', 'CODE')\naccess_token = response['access_token']\n```\n\n#### Extend a short-lived access token for a long-lived access token\n```\nresponse = client.extend_token(access_token)  # From previous step\naccess_token = response['access_token']\n```\n\n#### Get app token\n```\nresponse = client.get_app_token()\napp_access_token = response['access_token']\n```\n\n#### Inspect a token\n```\nresponse = client.inspect_token(access_token, app_access_token)  # From previous step\n```\n\n#### Set the access token in the library\n```\nclient.set_access_token(access_token)  # From previous step\n```\n\n### User\n\nFor more information: https://developers.facebook.com/docs/graph-api/reference/user/\n\n#### Get account information\n```\nresponse = client.get_account()\n```\n\n#### Get account pages\n```\nresponse = client.get_pages()\n```\n\n#### Get page token\n```\npage_access_token = client.get_page_token('PAGE_ID')  # From previous step\n```\n\n### Page\n\nFor more information: https://developers.facebook.com/docs/graph-api/reference/page/\n\n#### Get lead generation forms given the page\n```\nresponse = client.get_ad_account_leadgen_forms('PAGE_ID', page_access_token)  # From previous step\n```\n#### Get leads info given the lead generation form\n```\nresponse = client.get_ad_leads('LEADGEN_FORM_ID')\n```\n\n#### Get a sigle lead info\n```\nresponse = client.get_leadgen('LEADGEN_ID')\n```\n\n### Webhooks\n\nFor more information: https://developers.facebook.com/docs/graph-api/webhooks\n\nThe following methods cover Step 2 and 4 of the Webhook lead retrieval guide:\nWebhooks: https://developers.facebook.com/docs/marketing-api/guides/lead-ads/retrieving/\n\n#### Create a webhook for leads retrieval\n```\nresponse = client.create_app_subscriptions('page', 'callback_url', 'leadgen', 'abc123', app_access_token)  # You get app_access_token from get_app_token() method\n\nresponse = client.create_page_subscribed_apps('PAGE_ID', page_access_token, params={'subscribed_fields': 'leadgen'})  # You get page_access_token from get_page_token() method\n```\n\n## Instagram Usage\n\n#### Client instantiation\n```\nfrom facebookmarketing.client import Client\n\nclient = Client('APP_ID', 'APP_SECRET', 'v12.0')\n```\n\n### OAuth 2.0\n\nFor more information: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/\n\n#### Get authorization url\n```\nurl = client.authorization_url('REDIRECT_URL', 'STATE', ['instagram_basic', 'pages_show_list'])\n```\n\n#### Exchange the code for an access token\n```\nresponse = client.exchange_code('REDIRECT_URL', 'CODE')\naccess_token = response['access_token']\n```\n\n### Page\n\n#### Get page id\n```\nresponse = client.get_instagram(page_id, ['instagram_business_account'])\npage_id = response['instagram_business_account']['id']\n```\n\n### Media\n\n#### Get media\n```\nresponse = client.get_instagram_media(page_id)\n```\n\n#### Get media object\n```\nresponse = client.get_instagram_media_object(media_id, fields=['id','media_type','media_url','owner','timestamp'])\n```\n\n### Hashtag\n\n#### Search hashtag\n```\nresponse = (client.get_instagram_hashtag_search(page_id, 'coke'))\n```\n\n#### Get hashtag object\n```\nresponse = client.get_instagram_hashtag_object(hashtag_id, fields=['id', 'name']) \n```\n\n#### Get hashtag top media\n```\nresponse = client.get_instagram_hashtag_top_media(hashtag_id, instagram_id, ['id','media_type','comments_count','like_count', 'caption'])\n```\n\n## Requirements\n- requests\n\n## Contributing\nWe are always grateful for any kind of contribution including but not limited to bug reports, code enhancements, bug fixes, and even functionality suggestions.\n\n#### You can report any bug you find or suggest new functionality with a new [issue](https://github.com/GearPlug/facebookmarketing-python/issues).\n\n#### If you want to add yourself some functionality to the wrapper:\n1. Fork it ( https://github.com/GearPlug/facebookmarketing-python )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Adds my new feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgearplug%2Ffacebookmarketing-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgearplug%2Ffacebookmarketing-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgearplug%2Ffacebookmarketing-python/lists"}