{ "info": { "author": "Kristian Berg", "author_email": "eve.vittoros@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Games/Entertainment" ], "description": "# Introduction\n\n[![Build Status](https://travis-ci.org/kriberg/esy.svg?branch=master)](https://travis-ci.org/kriberg/esy)\n[![Coverage Status](https://coveralls.io/repos/github/kriberg/esy/badge.svg?branch=master)](https://coveralls.io/github/kriberg/esy?branch=master)\n[![Documentation Status](https://readthedocs.org/projects/esy/badge/?version=latest)](https://esy.readthedocs.io/en/latest/?badge=latest)\n\nThere are many options for consuming the ESI web services. ESY aims to be an easy-to-use library with the nuts and \nbolts of dealing with an OpenAPI interface abstracted away. \n\nESY is inspired by Entity's gloriously pythonic [eveapi](https://github.com/ntt/eveapi/) library. \n\n# Installation\n\nThe latest stable version of ESY is available from PyPI:\n```bash\n$ pip install esy\n```\n\n# Documentation\n\nDocumentation is available at [esy.readthedocs.io](https://esy.readthedocs.io/en/latest/).\n\nFor documentation of the various ESI routes, ESY also provides a \n[terse list](https://esy.readthedocs.io/en/latest/source/esi.html) of their parameters and return types. Further\ninformation can be explored at the main [ESI documentation site](https://esi.evetech.net/ui)\n\n# Usage\n\nESY comes with two interfaces to ESI:\n\n- An interface generated by [Bravado](https://github.com/Yelp/bravado), with some added sugar for dealing with pagination.\n- A semantic wrapper generated through pythonic voodoo.\n\nThe two interfaces caters different needs. The Bravado interface is an OpenAPI wrapper around the ESI that will \nbe familiar for most developers familiar working with swagger. The semantic wrapper, on the other hand, generates \nclasses for various entities in ESI like Character, Corporation and Alliance. Neither interface is mutual exclusive and \nfor many use cases, it makes sense using both.\n\nRegardless of interface, to use ESY, you must first initialize a client:\n\n```python\nfrom esy.client import ESIClient\nclient = ESIClient.get_client(user_agent='my-user-agent')\n```\n\nThe client can take a second or two to initialize, as the swagger specification is downloaded and parsed. To speed this\nup, you can download the specification locally:\n\n```bash\n$ curl https://esi.evetech.net/latest/swagger.json -o swagger.json\n```\n\nThen initialize the client using the local file:\n\n```python\nimport json\nfrom esy.client import ESIClient\n\nwith open('swagger.json', 'r') as spec_file:\n spec = json.load(spec_file)\nclient = ESIClient.get_client('my-user-agent', spec=spec)\n```\n\nFor production instances, keeping the spec in [Redis](https://redis.io) or some other cache is highly recommended.\n\n## Pagination\n\nFor ESI routes which are paginated, ESY will return a [ESIPageGenerator](source/modules.html#esy.client.ESIPageGenerator) which is a generator yielding the \nnative data type of the route.\n\n## Using the semantic wrapper\n\n```python\nfrom esy.entities import Character, Corporation, Alliance, Entity\n\n\n# You can initialize entities using their IDs\nvittoros = Character(941287462)\nevolution = Corporation(144749962)\nccp = Alliance(434243723)\n\n\n# To speed up initialization, it's recommended to create and share an ESIClient among instances. If no client is \n# supplied, a new one will be created for each entity instance.\nfrom esy.client import ESIClient\nclient = ESIClient.get_client(user_agent='my-user-agent')\n\nvittoros = Character(941287462, _client=client)\n\n# You can also initialize instances just using the entity names\n\nvittoros = Character.from_name('Vittoros', _client=client)\nevolution = Corporation.from_name('Evolution', _client=client)\n\n# or speed things up by initializing many entites at the same time\n\nentities = Entity.from_names('Vittoros', 'Evolution', 'Northern Coalition.', _client=client)\nprint(entities)\n\n{'Northern Coalition.': , \n 'Vittoros': , \n 'Evolution': }\n```\n\nAny initialized entity will allow you to access the various public information. To access the private services, you need\nto supply an authorization token first.\n\n```python\n\nvittoros = Character.from_name('Vittoros', _client=client, _token='hunter2')\n\n# or you can set the token after initialization\n\nvittoros.set_token('hunter2')\n```\n\nAfter this, you can access all the private services:\n\n```python\nfor asset_page in vittoros.get_assets():\n print(asset_page)\n\nfor contract_page in vittoros.get_contracts():\n for contract in contract_page:\n for bid in vittoros.get_contracts_contract_bids(contract_id=contract.get('contract_id')):\n print(bid.get('bidder_id'), bid.get('amount'), bid.get('date_bid'))\n\n```\n\nCheck out the [entities API](source/entities.html) for a more extensive list of available services.\n\n## Using the Bravado interface \n\nThe Bravado interface is available from the ESIClient instance. \n\n```python\nfrom esy.client import ESIClient\nclient = ESIClient.get_client(user_agent='my-user-agent')\n\n# Get list of alliances\nalliances = client.Alliance.get_alliances()\n\n# Get info on a corporation\nevolution = client.Corporation.get_corporations_corporation_id(corporation_id=144749962)\nprint(evolution)\n\n{'alliance_id': 1727758877, \n 'ceo_id': 144509256, \n 'creator_id': 144509256, \n 'date_founded': datetime.datetime(2003, 7, 30, 8, 33, tzinfo=tzutc()), \n 'description': 'Those who cannot adapt become victims of Evolution.', \n 'home_station_id': 60013843, \n 'member_count': 316, \n 'name': 'Evolution', \n 'shares': 1000, \n 'tax_rate': 0.5, \n 'ticker': 'EVOL', \n 'url': 'http://www.eve-evol.com', \n 'faction_id': None}\n```\n\n```python\n# Get paginated asset list\nswag = client.Corporation.get_corporations_corporation_id_assets(corporation_id=144749962,\n _token='esi token')\n# swag is an ESIPageGenerator, implementing the generator interface\n# Loop through it to get the asset pages\nfor page in swag: # Returns a list of assets\n for asset in page: # Asset dict \n print(asset.get('type_id'),\n asset.get('location_id'))\n # 22457\n # 16074150552\n```\n\n## Caching\n\nESY does not implement caching itself, but supports using a cache through a cache proxy object. The proxy needs\nto implement the following interface:\n\n```python\nclass Cache(object): \n def get(self, key: int) -> object: \n pass\n\n def set(self, key: int, data: object, cached_until: datetime.datetime):\n pass\n\n def __contains__(self, item: object) -> bool:\n pass\n```\n\n## Authentication and devel mode\n\nESY can handle the authentication flow for you:\n\n```python\nfrom esy.auth import ESIAuthenticator\n\nauth = ESIAuthenticator()\nrefresh_token, access_token = auth.verify_authorization_code('authorization code from esi',\n 'your client ID',\n 'your secret key')\n\nauth.verify_access_token(access_token)\n{'CharacterID': 941287462,\n 'CharacterName': 'Vittoros',\n 'ExpiresOn': '2018-06-11T19:01:15.182864Z',\n 'Scopes': ' ',\n 'TokenType': 'Character',\n 'CharacterOwnerHash': '**********'}\n\nnew_access_token = auth.get_access_token(refresh_token, \n 'your client ID', \n 'your secret key')\n\nauth.revoke_token(refresh_token,\n 'your client ID', \n 'your secret key')\n\nauth.revoke_token(access_token,\n 'your client ID', \n 'your secret key',\n token_type='access_token')\n```\n\nTo help developers getting started without having to implement the entire authentication\nworkflow, ESY also implements an ad-hoc web server to get you refresh tokens. You can use\nit directly in the python prompt to do some API exploration or you can use it in your tests\nto produce refresh or access tokens for testing your ESI calls.\n\nFirst, create a new application at [https://developers.eveonline.com/](https://developers.eveonline.com/)\nwith callback URL set to http://localhost:8000 or whichever address and port you'll be \nrunning the devel server.\n\n```python\nimport esy.devel\n\n# get_authorization_code has many parameters, but for basic usage:\n\nauth_code = esy.devel.get_authorization_code(client_id='your client ID',\n callback_url='your callback URL', \n scopes='your space-delimited scopes')\n\n# This will start the web server in the background (per-default listening on localhost:8000)\n# and print the login URL on stdout. After authenticating in your browser, the web server \n# will get redirect from the SSO with the authorization code, then return that.\n\n# For situations where you are not able to reach the network where you are running ESY, \n# you can also use CLI login: \n\nauth_code = esy.devel.get_authorization_code(cli_login=True,\n client_id='your client ID',\n callback_url='your callback URL', \n scopes='your space-delimited scopes')\n\n# This will prompt for username and password, then let you pick a character.\n# If you are running tests, you can also supply username, password and character_id as \n# keyword arguments to get_authorization_code, in addition to cli_login=True. This will\n# automate the entire flow. Remember to revoke your tokens afterwards and for bob's sake; \n# don't display your username and/or password!\n\n# After getting the authorization code, you can get the tokens:\n\nrefresh_token, access_token = esy.devel.verify_authorization_code(auth_code,\n client_id='your client ID',\n secret_key='your secret key')\n# Character info\n\nchar_info = esy.devel.verify_access_token(access_token)\n\n# Get your swag\nfrom esy.client import ESIClient\nclient = ESIClient.get_client(user_agent='your-user-agent')\nassets = client.Assets.get_characters_character_id_assets(\n character_id=char_info.get('CharacterId'), _token=access_token)\n\nfor page in assets:\n print(page)\n```\n\nThe devel mode will use parameters from environment settings, if present:\n\nParameter | Environment setting | Default\n---| --- | ---\nCLIENT_ID | ESY_CLIENT_ID | None\nSECRET_KEY | ESY_SECRET_KEY | None\nSCOPES | ESY_SCOPES | None\nCALLBACK_URL | ESY_CALLBACK_URL | http://localhost:8000\nSERVER_ADDRESS | ESY_SERVER_ADDRESS | localhost\nSERVER_PORT | ESY_SERVER_PORT | 8000\n\n\n# Development\n\nESY uses the [Bravado](https://github.com/Yelp/bravado-core) OpenAPI library to parse the ESI swagger schema and create\nan usable interface. The purpose of creating a custom wrapper of Bravado for ESI, is to make the interface a bit more \nuser friendly. Pagination is handled automatically by returning generators for any route which accepts a page \nparameter, while non-paginated data is handled in their native data type. Tokens can be set per-call, instead of \nper-client, allowing for using headers and still getting data for many tokens without the ned to reinitialize the client.\n\nThe authentication flow uses [requests-oauthlib](https://github.com/requests/requests-oauthlib).\n\n\n", "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/kriberg/esy.git", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "esy", "package_url": "https://pypi.org/project/esy/", "platform": "", "project_url": "https://pypi.org/project/esy/", "project_urls": { "Homepage": "https://github.com/kriberg/esy.git" }, "release_url": "https://pypi.org/project/esy/1.2.0/", "requires_dist": [ "bravado", "requests", "requests-oauthlib", "requests-html", "swagger-spec-validator", "bravado-core", "pytz" ], "requires_python": ">=3.6.0", "summary": "ESY is an ESI wrapper aiming to be simple and pythonic.", "version": "1.2.0" }, "last_serial": 4284839, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "69d5effdf262f1e1b58ef2f6c7b2e3bf", "sha256": "9407d19f42fe5eaa0ff5fa8a63ae611218e80fc853478fce97dd2f773275163c" }, "downloads": -1, "filename": "esy-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "69d5effdf262f1e1b58ef2f6c7b2e3bf", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 10222, "upload_time": "2018-06-06T20:13:10", "url": "https://files.pythonhosted.org/packages/dd/c8/82e41d56c8e932d1086580ae8f32f950a97391ade69c3107f8a2a205dc62/esy-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2cffff6f20c95bb19ceaf79074ee1d28", "sha256": "872adf4d926a9bb0e25629a94bc4c9dbbf27350194b6526557093da939fa83e7" }, "downloads": -1, "filename": "esy-1.0.0.tar.gz", "has_sig": false, "md5_digest": "2cffff6f20c95bb19ceaf79074ee1d28", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 10410, "upload_time": "2018-06-06T20:13:11", "url": "https://files.pythonhosted.org/packages/3b/0e/71de6ebdcfc92c147baf6750ca9ab35e1694c0d9730687892cdc910ab3d6/esy-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "ac69b4834303a22b069ed7e635d27184", "sha256": "7607ac8a78226266546b2d401fe83bb74633207bfc53138bc02642547ad991e9" }, "downloads": -1, "filename": "esy-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ac69b4834303a22b069ed7e635d27184", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 16423, "upload_time": "2018-06-11T21:33:12", "url": "https://files.pythonhosted.org/packages/1d/21/a0c30c342725a8f108041e30f7997cc7ec50ee769c5144e68a16a666ecc7/esy-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "aaf70917dbf3290e72b5a045fc587ae1", "sha256": "bdc53c8ccd97582bd56fd8240f272bc50791ac40bc1d67aba3e0d91a90bafdd5" }, "downloads": -1, "filename": "esy-1.1.0.tar.gz", "has_sig": false, "md5_digest": "aaf70917dbf3290e72b5a045fc587ae1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 14963, "upload_time": "2018-06-11T21:33:14", "url": "https://files.pythonhosted.org/packages/be/8f/8a5dccf237037e0788eeb0146890458981821eb17be74234b0f39721f1fa/esy-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "5b2c313e6eb4f857ceb668191ceb03ef", "sha256": "9564400ed27fb1235f641516b345a25fe2558258efdc0f34a3036c623ebfcaed" }, "downloads": -1, "filename": "esy-1.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5b2c313e6eb4f857ceb668191ceb03ef", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 12136, "upload_time": "2018-07-19T18:49:46", "url": "https://files.pythonhosted.org/packages/2d/c9/d0cc2630fe7d5a4bb34dcf018a31043a69291eb822a26df87cc74e2d37a4/esy-1.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0cbcc4460be5d3d422b135bf0499f3c0", "sha256": "2ea615933abfde04b25b1f996c2e2351f8849b0ffde07e47cdaf71b7f6d6a7f7" }, "downloads": -1, "filename": "esy-1.1.1.tar.gz", "has_sig": false, "md5_digest": "0cbcc4460be5d3d422b135bf0499f3c0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 15049, "upload_time": "2018-07-19T18:49:47", "url": "https://files.pythonhosted.org/packages/11/6c/66c074f9b8123897652881b60abbf2a3fd483624807ef355e5f3e1a12331/esy-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "e6f6f2a4c44f64870f6079fb0355b8c6", "sha256": "5ea201e7223750a14977b8452eb14542e06da0ce44f2b38bab2bc2221061135e" }, "downloads": -1, "filename": "esy-1.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e6f6f2a4c44f64870f6079fb0355b8c6", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 12228, "upload_time": "2018-07-21T19:33:27", "url": "https://files.pythonhosted.org/packages/84/22/01fb0e1b3339d2e91f6651345811b3bc0771b3a83b5db6c8dffcce3dae76/esy-1.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e37c8a8f98947dd68fdd1f13ab393a69", "sha256": "82b2e95eadc98d96f7ef4b21b86ad079daa9cb45a61cba5d4d0d15c986333b27" }, "downloads": -1, "filename": "esy-1.1.2.tar.gz", "has_sig": false, "md5_digest": "e37c8a8f98947dd68fdd1f13ab393a69", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 15001, "upload_time": "2018-07-21T19:33:28", "url": "https://files.pythonhosted.org/packages/72/16/a087bc564a0333d6a681f311c96f6a99f36f747bbc5f9daf5faeb07b45cf/esy-1.1.2.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "1d8bb531c2ea57a886436818cca9e5b8", "sha256": "00d3e079e6c21b282ffa6e83632d804ceefe8649beee96f0b02de3d45b276a40" }, "downloads": -1, "filename": "esy-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1d8bb531c2ea57a886436818cca9e5b8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 15348, "upload_time": "2018-09-18T18:49:17", "url": "https://files.pythonhosted.org/packages/5f/54/3435b25c836394b83b458128699689d62f5b505fc128998b0f1e695cc165/esy-1.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7cbd30afc74cdd5978366e3811584885", "sha256": "5f0d992ca1f042d80074d084eb6d6f68aec1ae7c608738078d8d83e1c2ab23c8" }, "downloads": -1, "filename": "esy-1.2.0.tar.gz", "has_sig": false, "md5_digest": "7cbd30afc74cdd5978366e3811584885", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 18029, "upload_time": "2018-09-18T18:49:18", "url": "https://files.pythonhosted.org/packages/35/43/2f1eb1680bf206e038bde701139bc756b10b62410be5c0ce03c1f030cc84/esy-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1d8bb531c2ea57a886436818cca9e5b8", "sha256": "00d3e079e6c21b282ffa6e83632d804ceefe8649beee96f0b02de3d45b276a40" }, "downloads": -1, "filename": "esy-1.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1d8bb531c2ea57a886436818cca9e5b8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=3.6.0", "size": 15348, "upload_time": "2018-09-18T18:49:17", "url": "https://files.pythonhosted.org/packages/5f/54/3435b25c836394b83b458128699689d62f5b505fc128998b0f1e695cc165/esy-1.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7cbd30afc74cdd5978366e3811584885", "sha256": "5f0d992ca1f042d80074d084eb6d6f68aec1ae7c608738078d8d83e1c2ab23c8" }, "downloads": -1, "filename": "esy-1.2.0.tar.gz", "has_sig": false, "md5_digest": "7cbd30afc74cdd5978366e3811584885", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6.0", "size": 18029, "upload_time": "2018-09-18T18:49:18", "url": "https://files.pythonhosted.org/packages/35/43/2f1eb1680bf206e038bde701139bc756b10b62410be5c0ce03c1f030cc84/esy-1.2.0.tar.gz" } ] }