diff --git a/PyCrowdTangle/PyCrowdTangle.py b/PyCrowdTangle/PyCrowdTangle.py index 5a62515..e95219d 100644 --- a/PyCrowdTangle/PyCrowdTangle.py +++ b/PyCrowdTangle/PyCrowdTangle.py @@ -92,4 +92,28 @@ def ct_get_posts(count=100, start_date="", end_date="", api_token=""): # sending get request and saving the response as response object r = requests.get(url=URL_BASE, params=PARAMS) # status = r.status_code - return r.json() \ No newline at end of file + return r.json() + +def ct_get_lists(api_token=""): + """Retrieve the lists, saved searches and saved post lists of the dashboard associated with the token sent in + + Args: + api_token (str, optional): you can locate your API token via your crowdtangle dashboard + under Settings > API Access. + Returns: + [dict]: The Response contains both a status code and a result. The status will always + be 200 if there is no error. The result contains an array of a lists objects + + Example: + ct_get_lists(api_token="AKJHXDFYTGEBKRJ6535") + """ + + # api-endpoint + URL_BASE = "https://api.crowdtangle.com/lists" + # defining a params dict for the parameters to be sent to the API + PARAMS = {'token': api_token} + + # sending get request and saving the response as response object + r = requests.get(url=URL_BASE, params=PARAMS) + # status = r.status_code + return r.json() \ No newline at end of file diff --git a/PyCrowdTangle/__init__.py b/PyCrowdTangle/__init__.py index 810dcfd..4fd7c31 100644 --- a/PyCrowdTangle/__init__.py +++ b/PyCrowdTangle/__init__.py @@ -1,6 +1,7 @@ """Top-level package for PyCrowdTangle""" __author__ = """Jose R. Zapata""" -__version__ = '0.0.4' +__version__ = '0.1.0' from .PyCrowdTangle import ct_get_posts -from .PyCrowdTangle import ct_get_links \ No newline at end of file +from .PyCrowdTangle import ct_get_links +from .PyCrowdTangle import ct_get_lists \ No newline at end of file diff --git a/README.md b/README.md index f5e27c1..a8bdaae 100644 --- a/README.md +++ b/README.md @@ -52,3 +52,18 @@ df = pd.DataFrame(data['result']['posts']) #show results df.head() ``` + +### ct_get_lists +```python +import PyCrowdTangle as pct + +#retrieve data from CrowdTangle +# get the api_token from https://apps.crowdtangle.com/ +# you can locate your API token via your crowdtangle dashboard +# under Settings > API Access. + +data = pct.ct_get_lists(api_token="AKJHXDFYTGEBKRJ6535") + +#show results +print(data) +``` \ No newline at end of file diff --git a/setup.py b/setup.py index 08ed0fe..320c267 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="PyCrowdTangle", packages = find_packages(include=['PyCrowdTangle']), - version="0.0.4", + version="0.1.0", author="Jose R. Zapata", author_email="jjrzg@hotmail.com", description="A Python Wrapper To Retrieve Data From The CrowdTangle API",