{"id":15372933,"url":"https://github.com/smaeda-ks/twitter-python-ads-sdk-v2","last_synced_at":"2025-03-27T21:49:50.395Z","repository":{"id":62585746,"uuid":"233199758","full_name":"smaeda-ks/twitter-python-ads-sdk-v2","owner":"smaeda-ks","description":"Twitter Ads API SDK for Python.","archived":false,"fork":false,"pushed_at":"2020-01-11T17:36:57.000Z","size":5859,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T06:17:33.315Z","etag":null,"topics":["python","sdk","sdk-python","twitter","twitter-ads","twitter-api"],"latest_commit_sha":null,"homepage":"https://smaeda-ks.github.io/twitter-python-ads-sdk-v2/","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/smaeda-ks.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":"2020-01-11T08:24:15.000Z","updated_at":"2020-01-11T10:09:42.000Z","dependencies_parsed_at":"2022-11-03T20:20:16.671Z","dependency_job_id":null,"html_url":"https://github.com/smaeda-ks/twitter-python-ads-sdk-v2","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smaeda-ks%2Ftwitter-python-ads-sdk-v2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smaeda-ks%2Ftwitter-python-ads-sdk-v2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smaeda-ks%2Ftwitter-python-ads-sdk-v2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smaeda-ks%2Ftwitter-python-ads-sdk-v2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smaeda-ks","download_url":"https://codeload.github.com/smaeda-ks/twitter-python-ads-sdk-v2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245931760,"owners_count":20695961,"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":["python","sdk","sdk-python","twitter","twitter-ads","twitter-api"],"created_at":"2024-10-01T13:53:43.127Z","updated_at":"2025-03-27T21:49:50.371Z","avatar_url":"https://github.com/smaeda-ks.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/smaeda-ks/twitter-python-ads-sdk-v2.svg?branch=master)](https://travis-ci.org/smaeda-ks/twitter-python-ads-sdk-v2)\n[![PyPI](https://img.shields.io/pypi/v/twitter-ads-v2.svg)](https://pypi.python.org/pypi/twitter-ads-v2)\n[![PyPI version](https://img.shields.io/pypi/pyversions/twitter-ads-v2.svg)](https://pypi.python.org/pypi/twitter-ads-v2)\n\n# Getting Started\n\n## Installation\n\n```sh\n# install the latest release\npip install twitter-ads-v2\n```\n\n## Quick Start\n\n```py\nimport twitter_ads_v2\n\nCONSUMER_KEY = 'your consumer key'\nCONSUMER_SECRET = 'your consumer secret'\nACCESS_TOKEN = 'access token'\nACCESS_TOKEN_SECRET = 'access token secret'\nACCOUNT_ID = 'account id'\n\nclient = twitter_ads_v2.Client(\n    ACCOUNT_ID,\n    CONSUMER_KEY,\n    CONSUMER_SECRET,\n    ACCESS_TOKEN,\n    ACCESS_TOKEN_SECRET,\n    options={\n        'handle_rate_limit': True\n    }\n)\n\n# index\ndata = client.campaigns('all')\nprint(data.headers)\nprint(data.body)\n\n# show\ndata = client.campaigns('load', id='campaign_id')\nprint(data.headers)\nprint(data.body)\n\ntweets = client.promoted_tweets('all')\n# iterate over until the cursor (\"next_cursor\") is exhausted\nfor i in tweets:\n    print(i.headers)\n    print(i.body)\n```\n\n### Types of `endpoint_type`\n\nTo provide a consistent interface, the first parameter of each API method is always `endpoint_type`:\n\n```py\ndata = client.campaigns('load', id='campaign_id')\n```\n\nin the above example, `load` is the `endpoint_type` of this call. The terms of each `endpoint_type` are described below.\n\n|`endpoint_type`|description|HTTP method|\n|---|---|---|\n| `all` | Retrieve _**all**_ or _**some**_ of the entities’ details depends on the request parameters from an index endpoint (i.e., most index endpoints have a parameter that can scope the results). | GET |\n| `load` | Retrieve a _**specific**_ entity details from a show endpoint (i.e., most show endpoints require an entity id to retrieve as part of resource URI). | GET |\n| `create` | Create a new entity. | POST |\n| `update` | Update a specific entity. | PUT |\n| `delete` | Delete a specific entity. | DELETE |\n| `batch` | Create/Update/Delete entities depends on the POST body data (normally a JSON object). | POST |\n\n### Request Parameters\n\nAll request parameters except `endpoint_type` as mentioned above should be passed as keyword arguments.\n\n### Rate-limit handling and request retry\n\n```py\nclient = twitter_ads_v2.Client(\n    ACCOUNT_ID,\n    CONSUMER_KEY,\n    CONSUMER_SECRET,\n    ACCESS_TOKEN,\n    ACCESS_TOKEN_SECRET,\n    options={\n        'handle_rate_limit': True,\n        'retry_max': 3,\n        'retry_delay': 5000,\n        'retry_on_status': [404, 500, 503]\n    })\n```\n\n|parameter|default|description|\n|---|:---:|---|\n|`handle_rate_limit`|`False` (boolean)|Set `True` will check the rate-limit response header and sleep if the request reached the limit (429).|\n|`retry_max`|`0` (int)|The number of times you want to retry when response code is found in `retry_on_status`.|\n|`retry_delay`|`1500` (int)|The number of **milliseconds** you want to sleep before retry.|\n|`retry_on_status`|`[500, 503]` (list)|The response codes you want to retry on. You can only set \u003e= 400 status codes.|\n\n## Compatibility \u0026 Versioning\n\nThis project is designed to work with Python 3.5 or greater. While it may work on other versions of Python, below are the platform and runtime versions we officially support and regularly test against.\n\n| Platform | Versions |\n| -- | -- |\n| CPython | 3.5, 3.6, 3.7 |\n| PyPy | 7.x |\n\nAll releases adhere to strict semantic versioning. For Example, major.minor.patch-pre (aka. stick.carrot.oops-peek).\n\n## Development\n\nIf you’d like to contribute to the project or try an unreleased development version of this project locally, you can do so quite easily by following the examples below.\n\n```sh\n# clone the repository\ngit clone git@github.com:smaeda-ks/twitter-python-ads-sdk-v2.git\ncd twitter-python-ads-sdk-v2\n\n# installing a local unsigned release\npip install -e .\n```\n\n### Tests\n\n```sh\n$ python setup.py flake8 \u0026\u0026 python setup.py test\n```\n\n### Documentation\n\nIf you’d like to contribute to the project's documentation, you need to setup Sphinx and build pages by the following steps.\n\n```sh\n# install dependencies\n$ pip install -e .[doc]\n\n# build pages\n$ cd sphinx/\n$ make clean \u0026\u0026 make html\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmaeda-ks%2Ftwitter-python-ads-sdk-v2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmaeda-ks%2Ftwitter-python-ads-sdk-v2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmaeda-ks%2Ftwitter-python-ads-sdk-v2/lists"}