These forums have been archived and are now read-only.
The new forums are live and can be found at https://forums.eveonline.com/
PyCrest - Python CREST Client
ReflexiveLotteries
@CCP_FoxFour // Technical Designer // Team Tech Co
Third-party developer? Check out the official developers site for dev blogs, resources, and more.
import pycresteve = pycrest.EVE()eve()
import requestsparams = Noneres = requests.get('https://public-crest.eveonline.com/', headers={'Accept': 'application/json', 'User-Agent': 'PyCrest - v 0.0.1 testing'}, params=params if params else {})
Woo! CSM XI!
Fuzzwork Enterprises
Twitter: @fuzzysteve on Twitter
pip install https://github.com/paxswill/PyCrest/archive/weak-ciphers.zip
import multiprocessingimport urlparseimport uuidimport webbrowserimport pycrestimport server#----------------------------------------------------------------------def main(): # Launch the server in a separate process, pass back the code and state in a queue queue = multiprocessing.Queue() eve_auth = pycrest.EVE(client_id="client id goes here", api_key="api key goes here", redirect_uri="http://localhost:12345/callback/") state_str = uuid.uuid4().get_hex() webbrowser.open(eve_auth.auth_uri(state=state_str)) p = multiprocessing.Process(target=server.start_server, args=(queue,)) p.start() code_raw = queue.get() queue.close() queue.join_thread() p.join() query_str = dict(urlparse.parse_qsl(code_raw)) eve_auth() auth_conn = eve_auth.authorize(query_str['code']) region = getByAttrVal(eve_auth.regions().items, 'name', 'Catch') item = getByAttrVal(getAllItems(eve_auth.itemTypes), 'name', 'Tritanium').href print getAllItems(region().marketSellOrders(type=item)) # Below lifted from http://pycrest.readthedocs.org/en/latest/def getByAttrVal(objlist, attr, val): ''' Searches list of dicts for a dict with dict[attr] == val ''' matches = [getattr(obj, attr) == val for obj in objlist] index = matches.index(True) # find first match, raise ValueError if not found return objlist[index]def getAllItems(page): ''' Fetch data from all pages ''' ret = page().items while hasattr(page(), 'next'): page = page().next() ret.extend(page().items) return retif __name__ == '__main__': main()
region = getByAttrVal(eve_auth.regions().items, 'name', 'Catch')
region = getByAttrVal(auth_conn().regions().items, 'name', 'Catch')
region = getByAttrVal(auth_conn().regions().items, 'name', 'Catch')item = getByAttrVal(getAllItems(eve_auth.itemTypes), 'name', 'Tritanium').hrefprint getAllItems(region().marketSellOrders(type=item))
print getAllItems(region().marketSellOrders(type=item))
def get(self, resource, params=None): logger.debug('Getting resource %s', resource) if params is None: # <-- breakpoint here, condition is 'orders/sell/' in resource params = {}
# check cachekey = (resource, frozenset(self._session.headers.items()), frozenset(prms.items()))cached = self.cache.get(key) # cached == None
(u'https://crest-tq.eveonline.com/market/10000014/orders/sell/', frozenset([('Accept', 'application/json'), ('Connection', 'keep-alive'), ('Accept-Encoding', 'gzip, deflate'), ('Authorization', u'Bearer 9t long string A2'), ('User-Agent', 'PyCrest/0.0.1')]), frozenset([('type', u'https://public-crest.eveonline.com/types/34/')]))
res = self._session.get(resource, params=prms)if res.status_code != 200: # <-- status_code == 401 raise APIException("Got unexpected status code from server: %i" % res.status_code)
webbrowser.open(eve_auth.auth_uri(state=state_str, scopes=['publicData']))
>>> import pycrest>>> eve = pycrest.EVE()>>> history = eve.get('https://public-crest.eveonline.com/market/10000002/types/34/history/')>>> print history['items'][-1]{u'volume': 16016039000, u'orderCount': 2760, u'lowPrice': 5.92, u'highPrice': 6.05,u'avgPrice': 5.99, u'volume_str': u'16016039000', u'orderCount_str': u'2760',u'date': u'2015-03-01T00:00:00'}