{ "info": { "author": "sloev", "author_email": "johannes.valbjorn@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "Natural Language :: English", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# trustpilot\n\n[![Build Status](https://travis-ci.org/trustpilot/python-trustpilot.svg?branch=master)](https://travis-ci.org/trustpilot/python-trustpilot) [![Latest Version](https://img.shields.io/pypi/v/trustpilot.svg)](https://pypi.python.org/pypi/trustpilot) [![Python Support](https://img.shields.io/pypi/pyversions/trustpilot.svg)](https://pypi.python.org/pypi/trustpilot)\n\nPython HTTP client for [Trustpilot](https://developers.trustpilot.com/).\n\n### Features\n\n* Extends the [`requests.Session`](http://docs.python-requests.org/en/master/api/#requests.Session) class with automatic authentication for public and private endpoints\n* GET, POST, PUT, DELETE, HEAD, OPTIONS and PATCH methods are exposed on module level\n* Implements session factory and default singleton session\n* Provides a simple hook system\n* CLI tool with basic HTTP commands\n\n## Installation\n\nInstall the package from [PyPI](http://pypi.python.org/pypi/) using [pip](https://pip.pypa.io/):\n\n```\npip install trustpilot\n```\n\n## Getting Started\n\nThis client is using the [Requests](http://docs.python-requests.org/en/master/) library. Responses are standard [`requests.Response`](http://docs.python-requests.org/en/master/api/#requests.Response) objects. You can use it as a factory or as a singleton.\n\n### Use the singleton session\n\nUse the built-in `default session` to instantiate a globally accessible session.\n\n```python\nfrom trustpilot import client\nclient.default_session.setup(\n api_host=\"https://api.trustpilot.com\",\n api_version=\"v1\",\n api_key=\"YOUR_API_KEY\",\n api_secret=\"YOUR_API_SECRET\",\n username=\"YOUR_TRUSTPILOT_BUSINESS_USERNAME\",\n password=\"YOUR_TRUSTPILOT_BUSINESS_PASSWORD\"\n)\nresponse = client.get(\"/foo/bar\")\n```\n\nYou can rely on environment variables for the setup of sessions so\n\n```bash\n$ env\nTRUSTPILOT_API_HOST=foobar.com\nTRUSTPILOT_API_VERSION=v1\nTRUSTPILOT_API_KEY=foo\nTRUSTPILOT_API_SECRET=bar\nTRUSTPILOT_USERNAME=username\nTRUSTPILOT_PASSWORD=password\n```\n\nWill work with the implicit `default_session` and the `TrustpilotSession.setup` method.\n\n```python\nfrom trustpilot import client\nclient.get(\"/foo/bar\")\n```\n\n### Instantiate your own session\n\nYou can create as many sessions as you like, as long as you pass them around yourself.\n\n```python\nfrom trustpilot import client\nsession = client.TrustpilotSession(\n api_host=\"https://api.trustpilot.com\",\n api_version=\"v1\",\n api_key=\"YOUR_API_KEY\",\n api_secret=\"YOUR_API_SECRET\",\n username=\"YOUR_TRUSTPILOT_BUSINESS_USERNAME\",\n password=\"YOUR_TRUSTPILOT_BUSINESS_PASSWORD\"\n)\nresponse = session.get(\"/foo/bar\")\n```\n\n## Async client\n\nSince version `3.0.0` you are able to use the `async_client` for `asyncio` usecases.\n\nTo use the default `async_client` session, using `env-vars` for settings, import is as following:\n\n```python\nimport asyncio\nfrom trustpilot import async_client\nloop = asyncio.get_event_loop()\n\nasync def get_response():\n response = await async_client.get('/foo/bar')\n response_json = await response.json()\n\nloop.run_until_complete(get_response())\n```\n\nOr instantiate the session yourself with:\n\n```python\nimport asyncio\nfrom trustpilot import async_client\nloop = asyncio.get_event_loop()\n\nsession = async_client.TrustpilotAsyncSession(\n api_host=\"https://api.trustpilot.com\",\n api_version=\"v1\",\n api_key=\"YOUR_API_KEY\",\n api_secret=\"YOUR_API_SECRET\",\n username=\"YOUR_TRUSTPILOT_BUSINESS_USERNAME\",\n password=\"YOUR_TRUSTPILOT_BUSINESS_PASSWORD\"\n)\n\nasync def get_response():\n response = await session.get('/foo/bar')\n response_json = await response.json()\n\nloop.run_until_complete(get_response())\n```\n\n## Setup User Agent\n\nA UserAgent header can be specified in two ways:\n\n1. By populating the `TRUSTPILOT_USER_AGENT` environment var\n2. By creating your own (async/sync)-client instance, or calling `setup` on the `default_session`, and supplying the kwargs `user_agent=foobar`\n\nIf no user-agent is given it will autopopulate using the function in `get_user_agent` function in [auth.py](./trustpilot/auth.py)\n\n## CLI\n\nA command line tool `trustpilot_api_client` is bundled with the module. To invoke it, use:\n\n```bash\nUsage: trustpilot_api_client [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --host TEXT host name\n --version TEST api version\n --key TEXT api key\n --secret TEXT api secret\n --token_issuer_host TEXT token issuer host name\n --username TEXT Trustpilot username\n --password TEXT Trustpilot password\n -c TEXT json config file name\n -v, --verbose verbosity level\n --help Show this message and exit.\n\nCommands:\n create_access_token Get an access token\n delete Send a DELETE request\n get Send a GET request\n post Send a POST request with specified data\n put Send a PUT request with specified data\n```\n\nIn order to use the **-c** option please supply the filename of a JSON in the following format:\n\n```json\n{\n \"TRUSTPILOT_API_HOST\": \"foo\",\n \"TRUSTPILOT_API_VERSION\": \"v1\",\n \"TRUSTPILOT_API_KEY\": \"bar\",\n \"TRUSTPILOT_API_SECRET\": \"baz\",\n \"TRUSTPILOT_USERNAME\": \"username\",\n \"TRUSTPILOT_PASSWORD\": \"password\"\n}\n```\n\n## Tests\n\nYou can use pytest to run tests against your current Python version. \n\nSee [`setup.py`](setup.py) for test dependencies.\n\n\n## History\n\n### 0.1.0 (2016-11-09)\n\n- First release on gemfury\n\n### 0.1.1 (2016-11-09)\n\n- change names\n\n### 0.1.2 (2016-11-09)\n\n- fix issue with 401-retry\n\n### 0.1.3 (2016-11-10)\n\n- add dependencies to setup.py\n\n### 0.1.4 (2016-11-11)\n\n- cli tool\n\n### 0.1.5 (2016-11-11)\n\n- fix apikey url query param error\n\n### 0.1.6 (2016-11-11)\n\n- introduce different token_issuer_host thatn api_host\n\n### 0.1.7 (2016-12-06)\n\n- Introduce context_getter on session object, defaulted to holding\n CorrelationId=random_uuid\n\n### 1.0.0 (2017-02-01)\n\n- first release as oss, major refactoring of inner machinery (session\n objects, retry policies, cli, tests etc)\n\n### 1.1.0 (2017-06-12)\n\n- fixed logging so it does not use root logger. according to best\n practices mentioned in\n \n- removed dependency on httpretty since it is not supporting py3\n\n### 2.0.0 (2017-09-29)\n\n- DEPRECATED: create_session is getting deprecated, use\n trustpilot.client.default_session.setup instead\n- now able to query public endpoints without being authenticated\n\n### 2.1.0 (2017-10-05)\n\n- fixed issue in cli.post & cli.put where 'content_type' should be\n 'content-type'\n\n### 3.0.0 (2018-01-18)\n\nDELETED DO NOT USE\\!\\!\n\n- add async-client\n\n### 3.0.1 (2018-01-18)\n\n- removed prints\n- made async_client retry on unauthorized\n\n### 4.0.0 (2018-06-06)\n\n- drop support for Python 3.3\n\n### 4.0.1 (2018-06-06)\n\n- Switch to non-deprecated session object for utility method calls\n\n### 4.0.2 (2018-10-30)\n\n- Upgrade requests to 2.20.0\n\n### 5.0.0 (2019-01-04)\n\n- Update to authentication methods\n\n### 5.0.1 (2019-02-04)\n\n- Fix documentation formatting\n\n### 6.0.0 (2019-02-06)\n\n- reorganize code\n- add user-agent header\n- get access_token with async call in async_client\n\n### 6.0.3 (2019-08-15)\n\n- Added support for 'API Version' parameter for Client initialisation.\n\n### 6.0.4 (2019-08-15)\n\n- Remove auto-deploy to travis\n\n### 6.0.5 (2019-08-15)\n\n- allow newer version of requests dependency\n\n### 6.0.6 (2019-09-18)\n\n- specify user agent through env-var or kwarg\n\n### 6.0.8 (2019-09-19)\n\n- pass user_agent property down to session correctly\n- handle duplicate api version properly\n\n### 6.0.9 (2019-09-19)\n\n- fix: transmit user-agent on all requests\n\n### 6.0.10 (2019-09-20)\n\n- fix: handle duplicate api version for both sync and async clients", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/trustpilot/python-trustpilot", "keywords": "trustpilot api client", "license": "", "maintainer": "", "maintainer_email": "", "name": "trustpilot", "package_url": "https://pypi.org/project/trustpilot/", "platform": "", "project_url": "https://pypi.org/project/trustpilot/", "project_urls": { "Homepage": "https://github.com/trustpilot/python-trustpilot" }, "release_url": "https://pypi.org/project/trustpilot/6.0.10/", "requires_dist": null, "requires_python": "", "summary": "trustpilot api client including cli tool", "version": "6.0.10" }, "last_serial": 5860822, "releases": { "5.0.1": [ { "comment_text": "", "digests": { "md5": "67d40d243b138933be52c9b62856d14c", "sha256": "f833584f8640fe05753a482db0e3ddc03061ff752a1dc384dd5a31020893b438" }, "downloads": -1, "filename": "trustpilot-5.0.1.tar.gz", "has_sig": false, "md5_digest": "67d40d243b138933be52c9b62856d14c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13133, "upload_time": "2019-02-04T14:45:09", "url": "https://files.pythonhosted.org/packages/3d/f9/58c220b08250390fed5109c7809530908df30ddcf9ea796335995f1dad5f/trustpilot-5.0.1.tar.gz" } ], "6.0.1": [ { "comment_text": "", "digests": { "md5": "f692cad1f03d877a13008412e555f108", "sha256": "0ea13444ac8b88983dc3c73e8fa1a57bb1e0bbd08a1a387f8a5e163b388aa400" }, "downloads": -1, "filename": "trustpilot-6.0.1.tar.gz", "has_sig": false, "md5_digest": "f692cad1f03d877a13008412e555f108", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14293, "upload_time": "2019-02-07T12:40:41", "url": "https://files.pythonhosted.org/packages/1d/d4/1556aec7936e4c42526165822771b6ae9a1ea1841ebfdc6d108dd9db03ff/trustpilot-6.0.1.tar.gz" } ], "6.0.10": [ { "comment_text": "", "digests": { "md5": "e4bdd9d5f84ea1258386d292527090f2", "sha256": "655a1e0d4dc5fce4fd3159cf4eb688ab8d355b2504e6fb32db8d9d3de2bbe92d" }, "downloads": -1, "filename": "trustpilot-6.0.10.tar.gz", "has_sig": false, "md5_digest": "e4bdd9d5f84ea1258386d292527090f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15058, "upload_time": "2019-09-20T08:47:51", "url": "https://files.pythonhosted.org/packages/0b/2a/2e6773922fad0231250818a77e2773e755fbae0324f2487111597b450163/trustpilot-6.0.10.tar.gz" } ], "6.0.2": [ { "comment_text": "", "digests": { "md5": "756afc825ed27654c8bdcd8801205c0d", "sha256": "de16ec4fc12cfb577e1a76b0ca57840a88118770288acc391fcbccfad473265b" }, "downloads": -1, "filename": "trustpilot-6.0.2.tar.gz", "has_sig": false, "md5_digest": "756afc825ed27654c8bdcd8801205c0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14285, "upload_time": "2019-02-07T12:45:57", "url": "https://files.pythonhosted.org/packages/30/32/c18d4bc6c490ef27835cd37e7aaefbe57f16a54064d224273153d4ebedd8/trustpilot-6.0.2.tar.gz" } ], "6.0.4": [ { "comment_text": "", "digests": { "md5": "64670b96aff490ef7d7399e1fe621de0", "sha256": "7057ce6785d858313b45451ace5907f158d82915820bfc3c178597ca99c4ae74" }, "downloads": -1, "filename": "trustpilot-6.0.4.tar.gz", "has_sig": false, "md5_digest": "64670b96aff490ef7d7399e1fe621de0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14579, "upload_time": "2019-08-15T09:56:00", "url": "https://files.pythonhosted.org/packages/74/0c/3d1249d96555724409512b70dbed7ca5a8cd623def72275942ea0bce8ea6/trustpilot-6.0.4.tar.gz" } ], "6.0.5": [ { "comment_text": "", "digests": { "md5": "9b91e3e8500269f47fb178d42aea97c7", "sha256": "d81a64635e212416a7eb784a88beaeb86b3421b7f696823a7f6f21636029bc34" }, "downloads": -1, "filename": "trustpilot-6.0.5.tar.gz", "has_sig": false, "md5_digest": "9b91e3e8500269f47fb178d42aea97c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14676, "upload_time": "2019-08-15T10:01:06", "url": "https://files.pythonhosted.org/packages/a5/93/b8c78542bc0e5acd28a31e30eaa0e2ddbd8c53f25007b3ef1234640fd5fb/trustpilot-6.0.5.tar.gz" } ], "6.0.6": [ { "comment_text": "", "digests": { "md5": "78b7cabdb35cce8cec3d6a02737bb042", "sha256": "3839a5d1e6a20f87cc65a07377cd2de3adcf48f1824712c9d1ba2d80c42a19ce" }, "downloads": -1, "filename": "trustpilot-6.0.6.tar.gz", "has_sig": false, "md5_digest": "78b7cabdb35cce8cec3d6a02737bb042", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14640, "upload_time": "2019-09-18T08:26:02", "url": "https://files.pythonhosted.org/packages/c1/9b/f78301f762cd01dfbacbdcd0ac590b8e0ea79187fb88a9225d70500a2038/trustpilot-6.0.6.tar.gz" } ], "6.0.7": [ { "comment_text": "", "digests": { "md5": "02597de1fe74e822f9e31fb67729bdae", "sha256": "a3df07884c6834deaedf90735cead5d5e3b95f6576f59d3be9f4b3a4b8c92bfa" }, "downloads": -1, "filename": "trustpilot-6.0.7.tar.gz", "has_sig": false, "md5_digest": "02597de1fe74e822f9e31fb67729bdae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14661, "upload_time": "2019-09-18T08:54:50", "url": "https://files.pythonhosted.org/packages/01/66/c63fa713fa0dd93f9196855ebd8ac944447c5d00602d361bd50152b6cf47/trustpilot-6.0.7.tar.gz" } ], "6.0.8": [ { "comment_text": "", "digests": { "md5": "0432548b7261707e04693361d82c2dd2", "sha256": "c81f340f942080e07981a5d90df0e5099645e121c488d81996f616fb722828bd" }, "downloads": -1, "filename": "trustpilot-6.0.8.tar.gz", "has_sig": false, "md5_digest": "0432548b7261707e04693361d82c2dd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14814, "upload_time": "2019-09-19T08:31:28", "url": "https://files.pythonhosted.org/packages/49/f3/51f8b4b047f20c5c2682394c6525708fd34bf307191ae7d90c263bc5e849/trustpilot-6.0.8.tar.gz" } ], "6.0.9": [ { "comment_text": "", "digests": { "md5": "1eff6c21561a78458ab186d31c383096", "sha256": "7a2dae665df81ba3383f916e0c60dcc1c231cc4e8a4808e066813a93bdd8a5e1" }, "downloads": -1, "filename": "trustpilot-6.0.9.tar.gz", "has_sig": false, "md5_digest": "1eff6c21561a78458ab186d31c383096", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14881, "upload_time": "2019-09-19T09:24:18", "url": "https://files.pythonhosted.org/packages/5a/d8/377f100c803b061ac73bc87e2907fc3763e40e119ebf37acac5c2b1aee8e/trustpilot-6.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e4bdd9d5f84ea1258386d292527090f2", "sha256": "655a1e0d4dc5fce4fd3159cf4eb688ab8d355b2504e6fb32db8d9d3de2bbe92d" }, "downloads": -1, "filename": "trustpilot-6.0.10.tar.gz", "has_sig": false, "md5_digest": "e4bdd9d5f84ea1258386d292527090f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15058, "upload_time": "2019-09-20T08:47:51", "url": "https://files.pythonhosted.org/packages/0b/2a/2e6773922fad0231250818a77e2773e755fbae0324f2487111597b450163/trustpilot-6.0.10.tar.gz" } ] }