preston


Namepreston JSON
Version 4.7.0 PyPI version JSON
download
home_pagehttps://github.com/Celeo/Preston
SummaryEVE ESI API access tool
upload_time2024-12-20 21:02:09
maintainerNone
docs_urlNone
authorCeleo
requires_python<4.0,>=3.8
licenseMIT
keywords eve online eve esi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Preston

[![CI](https://github.com/Celeo/preston/workflows/CI/badge.svg?branch=master)](https://github.com/Celeo/preston/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/Celeo/preston/branch/master/graph/badge.svg?token=2R9RY3P229)](https://codecov.io/gh/Celeo/preston)
[![Python version](https://img.shields.io/badge/Python-3.8+-blue)](https://www.python.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)

Preston is a Python library for accessing EVE Online's ESI API.

## Quick links

* EVE ESI: <https://esi.evetech.net>
* EVE developers: <https://developers.eveonline.com>

## Installation

From [pip](https://pip.pypa.io/en/stable/):

```sh
pip install preston
```

## Initialization

```python
from preston import Preston

preston = Preston()
```

There are values that you can pass to `__init__` as kwargs; those are detailed in the docstring for the class.

## Usage

There are 3 main things that Preston does:

1. Unauthenticated calls to ESI
2. User authentication
3. Authenticated calls to ESI for that user

For #1, all you need to do is initialize a Preston object and make the call:

```python
preston = Preston(
    user_agent='some_user_agent'
)

data = preston.get_op('get_characters_character_id', character_id=91316135)
# ...
```

You should always include a good `user_agent`.

Additionally, a `post_op` method exists, that takes a dictionary (instead of **kwargs) and another parameter; the former is used like above, to satisfy the URL parameters, and the latter is sent to the ESI endpoint as the payloadd.

For #2, there are 2 methods that you'll need, `get_authorize_url` and `authenticate`, and several `__init__` kwargs.

```python
preston = Preston(
    user_agent='some_user_agent',
    client_id='something',
    client_secret='something',
    callback_url='something',
    scope='maybe_something',
)
```

You can find the last 4 values in your application on the [EVE Dev site](https://developers.eveonline.com/).

When you have a Preston instance constructed like this, you can make the call to `get_authorize_url`:

```python
preston.get_authorize_url()
# https://login.eveonline.com/oauth/...
```

This is the URL that your user needs to visit and complete the flow. They'll be redirected to your app's callback URL, so you have to be monitoring that.

When you get their callback, take the code paramter from the URL and pass it to `authenticate`:

```python
auth = preston.authenticate('their_code_here')
```

Note the return variable and it's reassignment: this method returns a *new* instance, with the corresponding variables and headers setup for authenticated ESI calls.

Finally for #3, having followed the steps above, you just make calls like previously, but you can do so to the authenticated-only endpoints. Make sure that if you're calling
an endpoint that requires a specific scope, your app on EVE Devs has that scoped added and you've supplied it to the Preston initialization.

### Resuming authentication

If your app uses scopes, it'll receive a `refresh_token` alongside the `access_token`. The access token, per usual, only lasts 20 minutes before it expires. In this situation,
the refresh token can be used to get a *new* access token. If your Preston instance has a refresh token, this will be done automatically when the access token expires.

You can also get this refresh token from the Preston instance with `token = preston.refresh_token`. This can be then stored somewhere (securely) and used again later by
passing the token to Preston's constructor:

```python
preston = Preston(
    user_agent='some_user_agent',
    client_id='something',
    client_secret='something',
    callback_url='something',
    scope='maybe_something',
    refresh_token='your_token_here'
)
```

Preston will take the refresh token and attempt to get a new access token from it.

On that note, you can also pass the `access_token` to a new Preston instance, but there's less of a use case for that, as either you have an app with scopes, yielding a refresh token,
or an authentication-only app where you only use the access token to verify identity and some basic information before moving on.

## Developing

### Building

### Requirements

* Git
* Poetry
* Python 3.8+

### Steps

```sh
git clone https://github.com/Celeo/preston
cd preston
poetry install
```

### Running tests

| | |
| --- | --- |
| No coverage | `poetry run pytest`
| Coverage printout | `poetry run pytest --cov=preston` |
| Coverage report | `poetry run pytest --cov=preston --cov-report=html` |

## License

Licensed under MIT ([LICENSE](LICENSE)).

## Contributing

PRs are welcome. Please follow PEP8 (I'm lenient on E501) and use [Google-style docstrings](https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html#example-google).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Celeo/Preston",
    "name": "preston",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "eve online, eve, esi",
    "author": "Celeo",
    "author_email": "mattboulanger@fastmail.com",
    "download_url": "https://files.pythonhosted.org/packages/36/7d/1aeae91993af5a3df0540fd41667cc1468d2703cffe2769d4632293feb73/preston-4.7.0.tar.gz",
    "platform": null,
    "description": "# Preston\n\n[![CI](https://github.com/Celeo/preston/workflows/CI/badge.svg?branch=master)](https://github.com/Celeo/preston/actions?query=workflow%3ACI)\n[![codecov](https://codecov.io/gh/Celeo/preston/branch/master/graph/badge.svg?token=2R9RY3P229)](https://codecov.io/gh/Celeo/preston)\n[![Python version](https://img.shields.io/badge/Python-3.8+-blue)](https://www.python.org/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)\n\nPreston is a Python library for accessing EVE Online's ESI API.\n\n## Quick links\n\n* EVE ESI: <https://esi.evetech.net>\n* EVE developers: <https://developers.eveonline.com>\n\n## Installation\n\nFrom [pip](https://pip.pypa.io/en/stable/):\n\n```sh\npip install preston\n```\n\n## Initialization\n\n```python\nfrom preston import Preston\n\npreston = Preston()\n```\n\nThere are values that you can pass to `__init__` as kwargs; those are detailed in the docstring for the class.\n\n## Usage\n\nThere are 3 main things that Preston does:\n\n1. Unauthenticated calls to ESI\n2. User authentication\n3. Authenticated calls to ESI for that user\n\nFor #1, all you need to do is initialize a Preston object and make the call:\n\n```python\npreston = Preston(\n    user_agent='some_user_agent'\n)\n\ndata = preston.get_op('get_characters_character_id', character_id=91316135)\n# ...\n```\n\nYou should always include a good `user_agent`.\n\nAdditionally, a `post_op` method exists, that takes a dictionary (instead of **kwargs) and another parameter; the former is used like above, to satisfy the URL parameters, and the latter is sent to the ESI endpoint as the payloadd.\n\nFor #2, there are 2 methods that you'll need, `get_authorize_url` and `authenticate`, and several `__init__` kwargs.\n\n```python\npreston = Preston(\n    user_agent='some_user_agent',\n    client_id='something',\n    client_secret='something',\n    callback_url='something',\n    scope='maybe_something',\n)\n```\n\nYou can find the last 4 values in your application on the [EVE Dev site](https://developers.eveonline.com/).\n\nWhen you have a Preston instance constructed like this, you can make the call to `get_authorize_url`:\n\n```python\npreston.get_authorize_url()\n# https://login.eveonline.com/oauth/...\n```\n\nThis is the URL that your user needs to visit and complete the flow. They'll be redirected to your app's callback URL, so you have to be monitoring that.\n\nWhen you get their callback, take the code paramter from the URL and pass it to `authenticate`:\n\n```python\nauth = preston.authenticate('their_code_here')\n```\n\nNote the return variable and it's reassignment: this method returns a *new* instance, with the corresponding variables and headers setup for authenticated ESI calls.\n\nFinally for #3, having followed the steps above, you just make calls like previously, but you can do so to the authenticated-only endpoints. Make sure that if you're calling\nan endpoint that requires a specific scope, your app on EVE Devs has that scoped added and you've supplied it to the Preston initialization.\n\n### Resuming authentication\n\nIf your app uses scopes, it'll receive a `refresh_token` alongside the `access_token`. The access token, per usual, only lasts 20 minutes before it expires. In this situation,\nthe refresh token can be used to get a *new* access token. If your Preston instance has a refresh token, this will be done automatically when the access token expires.\n\nYou can also get this refresh token from the Preston instance with `token = preston.refresh_token`. This can be then stored somewhere (securely) and used again later by\npassing the token to Preston's constructor:\n\n```python\npreston = Preston(\n    user_agent='some_user_agent',\n    client_id='something',\n    client_secret='something',\n    callback_url='something',\n    scope='maybe_something',\n    refresh_token='your_token_here'\n)\n```\n\nPreston will take the refresh token and attempt to get a new access token from it.\n\nOn that note, you can also pass the `access_token` to a new Preston instance, but there's less of a use case for that, as either you have an app with scopes, yielding a refresh token,\nor an authentication-only app where you only use the access token to verify identity and some basic information before moving on.\n\n## Developing\n\n### Building\n\n### Requirements\n\n* Git\n* Poetry\n* Python 3.8+\n\n### Steps\n\n```sh\ngit clone https://github.com/Celeo/preston\ncd preston\npoetry install\n```\n\n### Running tests\n\n| | |\n| --- | --- |\n| No coverage | `poetry run pytest`\n| Coverage printout | `poetry run pytest --cov=preston` |\n| Coverage report | `poetry run pytest --cov=preston --cov-report=html` |\n\n## License\n\nLicensed under MIT ([LICENSE](LICENSE)).\n\n## Contributing\n\nPRs are welcome. Please follow PEP8 (I'm lenient on E501) and use [Google-style docstrings](https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html#example-google).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "EVE ESI API access tool",
    "version": "4.7.0",
    "project_urls": {
        "Homepage": "https://github.com/Celeo/Preston",
        "Repository": "https://github.com/Celeo/Preston"
    },
    "split_keywords": [
        "eve online",
        " eve",
        " esi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "30f53ceaffe5f9e182750bbf0f39b26243932cec1c3a29a0b2ee1e121c3321dc",
                "md5": "084887987b625d697b793844f47dba1a",
                "sha256": "a9de6e18059aaed5bbcd4ea2ce03ab8bdcfd6cde334e9d7c3b03b5777dfa0ee7"
            },
            "downloads": -1,
            "filename": "preston-4.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "084887987b625d697b793844f47dba1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 8906,
            "upload_time": "2024-12-20T21:02:08",
            "upload_time_iso_8601": "2024-12-20T21:02:08.352034Z",
            "url": "https://files.pythonhosted.org/packages/30/f5/3ceaffe5f9e182750bbf0f39b26243932cec1c3a29a0b2ee1e121c3321dc/preston-4.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "367d1aeae91993af5a3df0540fd41667cc1468d2703cffe2769d4632293feb73",
                "md5": "5ddb003c7a9ce4475905d6855f808180",
                "sha256": "6ff86d5a4826349b8247b4e872af8c0d1f4ee33e1e24e334818faf15dfa2b13a"
            },
            "downloads": -1,
            "filename": "preston-4.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5ddb003c7a9ce4475905d6855f808180",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 7950,
            "upload_time": "2024-12-20T21:02:09",
            "upload_time_iso_8601": "2024-12-20T21:02:09.453390Z",
            "url": "https://files.pythonhosted.org/packages/36/7d/1aeae91993af5a3df0540fd41667cc1468d2703cffe2769d4632293feb73/preston-4.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-20 21:02:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Celeo",
    "github_project": "Preston",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "preston"
}
        
Elapsed time: 0.45310s