Skip to main content

A client for ESI, the API for Eve Online

Project description

EsiPysi

EsiPysi (pronounced like "Easy Peasy") is a utility for accessing the Eve api called Esi. The goal of this project is to create a lightweight and fast tool which makes devloping with Esi easier.

Features

  • Auth storage and auto refreshing
    • If your access token expires, EsiPysi will acquire a new one
  • Fast API calling and JSON parsing using aiohttp
    • Uses asyncio and event loops so that the API calls are non-blocking
  • Light input validation
    • Only validates that the parameters are in the Esi Swagger Spec, does not validate types/values
  • Caching using Redis
  • Automatic retries for certain error codes
    • Typically those pesky 501s

Install

Install with pip:

pip install EsiPysi

Requires python 3.5+

How to use

Get familliar with the ESI reference and Eve SSO

start with an EsiPysi object, this will keep track of global settings like which Esi version to use (_latest is reccomended) and start a session

from esipysi import EsiPysi

esi = EsiPysi("https://esi.evetech.net/_latest/swagger.json?datasource=tranquility", user_agent="Your User Agent Here").session()
await esi.start()

It also support the with syntax which will start and stop the sessions for you:

async with EsiPysi("https://esi.evetech.net/_latest/swagger.json?datasource=tranquility", user_agent="Your User Agent Here").session() as esi:
    #Do stuff here

Now from that object you can create operations, pass the operation ID to the get_operation function

op = esi.get_operation("get_search")

If it requires authorization you can use EsiAuth

You can either get one from your client info, access token, refresh token, and expire datetime (in UTC)

from esipysi import EsiAuth

auth = EsiAuth(CLIENT_ID, CLIENT_SECRET, ACCESS_TOKEN, REFRESH_TOKEN, EXPIRES_AT)
op.set_auth(auth)

Or you can get it from less data such as an authorization code you got back from the callback or just a refresh token:

from esipysi import EsiAuth

auth = await EsiAuth.from_authorization_code(CLIENT_ID, CLIENT_SECRET, AUTHORIZATION_CODE)
auth = await EsiAuth.from_refresh_token(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)
op.set_auth(auth)

And then you can execute that operation with parameters

result = await op.execute(categories="character", search="Flying Kiwi Sertan")

When you are finished with a session, it is reccomended to stop it:

await esi.stop_session()

Response Object

EsiPysi returns a response object called EsiResponse, it contains the following:

  • response.text - The plain text of the body of the response
  • resonse.json() - The text decoded as json into a python Dict
  • response.status - The HTTP status code
  • response.headers - a CIMultiDict which is a special dict cabable of holding multiple of the same key because headers are funky. They act just like a Dict with some extras.

Caching

EsiPysi has caching provided by redis. First create a redis client.

Example from redis-py

import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)

Now create a RedisCache object and pass it to the EsiPysi object

from esipysy import EsiPysi
from esipysy.cache import RedisCache
cache = RedisCache(r)
esi = EsiPysi("https://esi.evetech.net/_latest/swagger.json?datasource=tranquility", user_agent="Your User Agent Here", cache=cache)

Note: By default a DictCache is used, if you want to disable all caching, you can manually set cache=None

Contact / Links

In game: Flying Kiwi Sertan

GitHub: https://github.com/FlyingKiwiBird/EsiPysi

PyPi: https://pypi.org/project/EsiPysi/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EsiPysi-0.10.2.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file EsiPysi-0.10.2.tar.gz.

File metadata

  • Download URL: EsiPysi-0.10.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.1

File hashes

Hashes for EsiPysi-0.10.2.tar.gz
Algorithm Hash digest
SHA256 153280eeb3b10a78d71a93da1cfe77b8dfe34903685a74b3e1198b6496ecb311
MD5 93f6c15100623316d9736c0d555cf68d
BLAKE2b-256 c4a707ebef46f11cb9938f858c17cec479cc9e7b4a62a7dd9a877239af990039

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page