Package: esi-client
esi-clientA Python client for accessing the complete Eve Online ESI API.ContentsOverviewInstallationUsageOverviewThis package is a library that provides a Python client for accessing the public 3rd party API of EVE Online, which is more commonly known as "ESI" (EVE Swagger Interface).The client is automatically generated from ESI's specification with theOpen API generator.This approach offers many benefits in comparison to other ESI libraries:Complete and correct coverage of all endpointsAutomatic serialization and mapping to Python data typesPython classes for all data modelsType annotations, i.e. enabling auto complete for API methodsNo delay at startup for building the clientRobust and proven API clientFast turnaround on API updatesInstallationYou can install the current this library directly from PyPI:pipinstallesi-clientUsageIn this chapter we are showing how to get information from ESI with the open API client.Accessing public endpointsThe esi client from openAPI is easy to use. Here is a minimal example for fetching a character from the public endpoint:fromesi_client.api.character_apiimportCharacterApiapi=CharacterApi()character=api.get_characters_character_id(character_id=93330670)print(character.name)Error handlingCommon errors can be handled by catchingApiException:importesi_clientfromesi_client.api.character_apiimportCharacterApiapi=CharacterApi()try:character=api.get_characters_character_id(character_id=93330670)print(character.name)exceptesi_client.ApiExceptionasex:print(f"Exception occurred when trying to fetch a character:{ex}")Making multiple calls to endpointsWhen making multiple calls to endpoints it is more efficient to use the same API client instance. Here we are first calling the character endpoint to get information about a character and then we are calling the corporation endpoint to get the name of the corporation the character belongs to.importesi_clientfromesi_client.api.character_apiimportCharacterApifromesi_client.api.corporation_apiimportCorporationApiwithesi_client.ApiClient()asapi_client:character_api=CharacterApi(api_client)character=character_api.get_characters_character_id(character_id=93330670)corporation_api=CorporationApi(api_client)corporation=corporation_api.get_corporations_corporation_id(corporation_id=character.corporation_id)print(f"{character.name}if a member of{corporation.name}")Accessing private endpointsFor accessing private endpoint you need a valid access token.Note that to topic of obtaining an access token is not in scope of this library. Please see theSSO documentationfor more information on how to obtain an access token for your web site or app. For testing purposes it is possible to generate an access token on theESI web site.You can provide your access token in two ways:As configuration for the api clientAs parameter when calling an endpointToken as configurationOne way for providing your access token is as configuration for the api client:importesi_clientfromesi_client.api.character_apiimportCharacterApiconfiguration=esi_client.Configuration(access_token="ACCESS-TOKEN")withesi_client.ApiClient(configuration)asapi_client:api_instance=CharacterApi(api_client)api_response=api_instance.get_characters_character_id_medals(character_id=93330670)...Token as parameterAnother way of providing your access token is as parameter when making the call to the endpoint:fromesi_client.api.character_apiimportCharacterApiapi_instance=CharacterApi(api_client)api_response=api_instance.get_characters_character_id_medals(character_id=93330670,token="ACCESS-TOKEN")Getting HTTP information for a responseIn some cases you also need to get the HTTP information for a response. e.g. if a endpoint supports paging the information about how many pages there are is in the HTTP header.To get the HTTP information you need to pass the argument_return_http_data_only=Falsewhen calling the API method. The API method will then return a tuple consisting of:dataHTTP status codeHTTP response headersHere is an example:fromesi_client.api.universe_apiimportUniverseApiapi=UniverseApi()data,status_code,header=api.get_universe_types(_return_http_data_only=False)The source code for these examples can also be found in project'sexamplesfolder.