eve-val / evelink

Python bindings for the EVE API.
Other
91 stars 30 forks source link

Corporate API Key usage #219

Closed markhamilton1 closed 9 years ago

markhamilton1 commented 9 years ago

I did not know how else to ask this question. Can someone send me an example of using a corporate api_key to get corporate info? Thanks! If there is a better way for me to ask questions like this please let me know.

metatoaster commented 9 years ago

There really isn't any real distinction between user API key and corporate API key from the end-user side of things, it's only a matter whether the given key has access to the data being requested. If you looked at the code first, you can find that there is a whole module dealing with corporation stuff, which you can use. Actual usage is no different:

from evelink import api
from evelink import corp

api = api.API(api_key=(id_, vcode))
corp = corp.Corp(api)
starbases = corp.starbases()
ayust commented 9 years ago

Yep, as already mentioned - just create an API object with a corp api key; then create a Corp object passing that API object in, and then call a method on it.

ayust commented 9 years ago

Here's an example that checks to make sure all of a corp's owned stations have the "Use Alliance Standings" option set:

import evelink
api_obj = evelink.api.API(api_key=(12345678, "vcodegoeshere"))
corp = evelink.corp.Corp(api=api_obj)
corp_info = corp.corporation_sheet().result
for station in corp.stations().result.values():
    if station["standing_owner_id"] != corp_info["alliance"]["id"]:
        print(station["name"], "isn't using alliance standings!")