enverus-ea / enverus-developer-api

Enverus Developer API Python Client
MIT License
19 stars 16 forks source link

Getting 403 errors using the python package #14

Open adrian5040 opened 2 years ago

adrian5040 commented 2 years ago

Code:

from enverus_developer_api import DirectAccessV2
from datetime import datetime as dt
from datetime import timedelta as td

PAGE_SIZE = 10000

# (I have these populated with my own keys)
DICT_ACCESS = {
    "api_key": "",
    "client_id": "",
    "client_secret": ""
}

d2 = DirectAccessV2(**DICT_ACCESS)

from_dt = dt(2022,5,9)
to_dt = dt(2022,5,10)

resp = d2.query(
    "well-production-details",
    updateddate=(f"btw({dt.strftime(from_dt, '%Y-%m-%dT%H:%M:%S.%fZ')},"
                 f"{dt.strftime(to_dt, '%Y-%m-%dT%H:%M:%S.%fZ')})"),
    deleteddate='null'
)

with open("C:\\Users\\adurham\\well_prod_dtls.txt", "w") as fh:
    doc = next(resp)
    fh.write("|".join([str(x) for x in doc.keys()]) + "\n")
    start_tm = dt.now()
    list_recs = []
    bool_done = False
    while not bool_done:
        for idx in range(PAGE_SIZE):
            try:
                doc = next(resp)
            except StopIteration:
                bool_done = True
            list_recs.append("|".join([str(x) if isinstance(x, int) or isinstance(x, float) else '"' + str(x) + '"' for x in doc.values()]))
        fh.write("\n".join(list_recs))
        msg = "%s document retrieved from drilling info in %sms" % (
            len(list_recs),
            str(int(round((dt.now() - start_tm) / td(milliseconds=1), 0)))
        )
        print(msg)
        start_tm = dt.now()
        list_recs = []

    fh.close()

Output:

10000 document retrieved from drilling info in 25342ms
10000 document retrieved from drilling info in 26004ms
10000 document retrieved from drilling info in 25905ms
10000 document retrieved from drilling info in 26988ms
10000 document retrieved from drilling info in 27054ms
10000 document retrieved from drilling info in 27088ms
10000 document retrieved from drilling info in 27924ms
10000 document retrieved from drilling info in 30367ms
10000 document retrieved from drilling info in 28880ms
10000 document retrieved from drilling info in 26423ms
10000 document retrieved from drilling info in 28886ms
10000 document retrieved from drilling info in 28436ms
10000 document retrieved from drilling info in 30926ms
10000 document retrieved from drilling info in 30813ms
10000 document retrieved from drilling info in 33318ms
10000 document retrieved from drilling info in 28026ms
10000 document retrieved from drilling info in 32832ms
10000 document retrieved from drilling info in 35197ms
10000 document retrieved from drilling info in 35707ms
10000 document retrieved from drilling info in 29467ms
10000 document retrieved from drilling info in 30878ms
10000 document retrieved from drilling info in 30602ms
10000 document retrieved from drilling info in 31785ms
10000 document retrieved from drilling info in 29022ms
10000 document retrieved from drilling info in 28694ms
10000 document retrieved from drilling info in 33191ms
10000 document retrieved from drilling info in 36550ms
10000 document retrieved from drilling info in 37471ms
10000 document retrieved from drilling info in 28277ms
10000 document retrieved from drilling info in 32088ms
10000 document retrieved from drilling info in 34088ms
10000 document retrieved from drilling info in 38507ms
10000 document retrieved from drilling info in 30465ms
10000 document retrieved from drilling info in 30349ms
10000 document retrieved from drilling info in 35122ms
10000 document retrieved from drilling info in 32635ms
10000 document retrieved from drilling info in 32294ms
10000 document retrieved from drilling info in 27856ms
10000 document retrieved from drilling info in 35429ms
10000 document retrieved from drilling info in 30406ms
10000 document retrieved from drilling info in 26665ms
10000 document retrieved from drilling info in 25171ms
10000 document retrieved from drilling info in 28793ms
10000 document retrieved from drilling info in 27207ms
10000 document retrieved from drilling info in 28947ms
10000 document retrieved from drilling info in 24744ms
10000 document retrieved from drilling info in 27245ms
10000 document retrieved from drilling info in 29953ms
10000 document retrieved from drilling info in 32786ms
10000 document retrieved from drilling info in 25630ms
10000 document retrieved from drilling info in 25818ms
10000 document retrieved from drilling info in 30052ms
10000 document retrieved from drilling info in 27121ms
10000 document retrieved from drilling info in 25602ms
10000 document retrieved from drilling info in 30040ms
10000 document retrieved from drilling info in 25641ms
10000 document retrieved from drilling info in 28284ms
10000 document retrieved from drilling info in 30515ms
10000 document retrieved from drilling info in 34678ms
10000 document retrieved from drilling info in 32630ms
10000 document retrieved from drilling info in 29638ms
10000 document retrieved from drilling info in 27129ms
10000 document retrieved from drilling info in 26782ms
10000 document retrieved from drilling info in 31314ms
10000 document retrieved from drilling info in 32871ms
10000 document retrieved from drilling info in 27243ms
10000 document retrieved from drilling info in 31853ms
10000 document retrieved from drilling info in 37422ms
10000 document retrieved from drilling info in 28165ms
10000 document retrieved from drilling info in 29978ms
10000 document retrieved from drilling info in 31734ms
10000 document retrieved from drilling info in 30698ms
10000 document retrieved from drilling info in 27338ms
10000 document retrieved from drilling info in 30147ms
10000 document retrieved from drilling info in 33597ms
10000 document retrieved from drilling info in 36821ms
10000 document retrieved from drilling info in 27019ms
10000 document retrieved from drilling info in 37760ms
10000 document retrieved from drilling info in 32540ms
10000 document retrieved from drilling info in 28593ms
10000 document retrieved from drilling info in 29547ms
10000 document retrieved from drilling info in 32191ms
10000 document retrieved from drilling info in 32314ms
10000 document retrieved from drilling info in 27048ms
10000 document retrieved from drilling info in 28354ms
10000 document retrieved from drilling info in 33104ms
10000 document retrieved from drilling info in 33863ms
10000 document retrieved from drilling info in 26686ms
10000 document retrieved from drilling info in 30513ms
10000 document retrieved from drilling info in 30011ms
10000 document retrieved from drilling info in 35158ms
10000 document retrieved from drilling info in 25969ms
10000 document retrieved from drilling info in 27191ms
10000 document retrieved from drilling info in 34971ms
10000 document retrieved from drilling info in 28036ms
10000 document retrieved from drilling info in 29117ms
10000 document retrieved from drilling info in 31314ms
10000 document retrieved from drilling info in 29801ms
10000 document retrieved from drilling info in 25761ms
10000 document retrieved from drilling info in 29950ms
10000 document retrieved from drilling info in 30300ms
10000 document retrieved from drilling info in 30407ms
10000 document retrieved from drilling info in 25450ms
10000 document retrieved from drilling info in 30030ms
10000 document retrieved from drilling info in 30709ms
10000 document retrieved from drilling info in 24395ms
10000 document retrieved from drilling info in 29691ms
10000 document retrieved from drilling info in 33751ms
10000 document retrieved from drilling info in 29977ms
10000 document retrieved from drilling info in 28368ms
10000 document retrieved from drilling info in 28081ms
10000 document retrieved from drilling info in 32449ms
10000 document retrieved from drilling info in 30586ms
10000 document retrieved from drilling info in 25598ms
10000 document retrieved from drilling info in 28502ms
10000 document retrieved from drilling info in 29984ms
10000 document retrieved from drilling info in 24176ms
10000 document retrieved from drilling info in 32357ms
10000 document retrieved from drilling info in 29768ms
10000 document retrieved from drilling info in 32052ms
10000 document retrieved from drilling info in 26005ms
10000 document retrieved from drilling info in 29492ms
10000 document retrieved from drilling info in 32782ms
10000 document retrieved from drilling info in 25353ms
10000 document retrieved from drilling info in 29176ms
10000 document retrieved from drilling info in 29086ms
10000 document retrieved from drilling info in 29952ms
10000 document retrieved from drilling info in 32386ms
10000 document retrieved from drilling info in 31206ms
10000 document retrieved from drilling info in 30075ms
10000 document retrieved from drilling info in 26455ms
10000 document retrieved from drilling info in 34515ms
10000 document retrieved from drilling info in 30277ms
10000 document retrieved from drilling info in 35836ms
10000 document retrieved from drilling info in 27002ms
10000 document retrieved from drilling info in 34344ms
10000 document retrieved from drilling info in 28230ms
10000 document retrieved from drilling info in 29425ms
10000 document retrieved from drilling info in 33264ms
10000 document retrieved from drilling info in 34997ms
10000 document retrieved from drilling info in 32799ms
10000 document retrieved from drilling info in 24797ms
10000 document retrieved from drilling info in 32262ms
10000 document retrieved from drilling info in 28410ms
10000 document retrieved from drilling info in 28500ms
10000 document retrieved from drilling info in 24254ms
10000 document retrieved from drilling info in 31128ms
10000 document retrieved from drilling info in 32171ms
10000 document retrieved from drilling info in 32604ms
10000 document retrieved from drilling info in 33532ms
10000 document retrieved from drilling info in 25517ms
10000 document retrieved from drilling info in 33503ms
10000 document retrieved from drilling info in 32652ms
10000 document retrieved from drilling info in 32914ms
10000 document retrieved from drilling info in 26028ms
10000 document retrieved from drilling info in 32662ms
10000 document retrieved from drilling info in 35286ms
10000 document retrieved from drilling info in 31512ms
10000 document retrieved from drilling info in 33661ms
10000 document retrieved from drilling info in 25647ms
10000 document retrieved from drilling info in 32012ms
10000 document retrieved from drilling info in 31567ms
10000 document retrieved from drilling info in 32601ms
10000 document retrieved from drilling info in 31269ms
10000 document retrieved from drilling info in 28435ms
10000 document retrieved from drilling info in 27912ms
10000 document retrieved from drilling info in 32802ms
10000 document retrieved from drilling info in 29895ms
10000 document retrieved from drilling info in 31702ms
10000 document retrieved from drilling info in 30563ms
10000 document retrieved from drilling info in 31971ms
10000 document retrieved from drilling info in 26456ms
10000 document retrieved from drilling info in 34196ms
10000 document retrieved from drilling info in 29115ms
10000 document retrieved from drilling info in 29755ms
10000 document retrieved from drilling info in 28510ms
10000 document retrieved from drilling info in 38366ms
10000 document retrieved from drilling info in 33634ms
10000 document retrieved from drilling info in 26618ms
10000 document retrieved from drilling info in 27638ms
10000 document retrieved from drilling info in 29860ms
10000 document retrieved from drilling info in 33048ms
10000 document retrieved from drilling info in 30219ms
10000 document retrieved from drilling info in 32529ms
10000 document retrieved from drilling info in 29583ms
10000 document retrieved from drilling info in 31410ms
10000 document retrieved from drilling info in 25120ms
10000 document retrieved from drilling info in 33301ms
10000 document retrieved from drilling info in 32387ms
10000 document retrieved from drilling info in 31854ms
10000 document retrieved from drilling info in 27820ms
10000 document retrieved from drilling info in 28071ms
10000 document retrieved from drilling info in 31173ms
10000 document retrieved from drilling info in 28083ms
10000 document retrieved from drilling info in 24913ms
10000 document retrieved from drilling info in 31850ms
10000 document retrieved from drilling info in 35492ms
10000 document retrieved from drilling info in 37923ms
10000 document retrieved from drilling info in 29633ms
10000 document retrieved from drilling info in 33641ms
10000 document retrieved from drilling info in 32789ms
10000 document retrieved from drilling info in 33457ms
10000 document retrieved from drilling info in 29325ms
10000 document retrieved from drilling info in 26629ms
10000 document retrieved from drilling info in 28830ms
10000 document retrieved from drilling info in 35754ms
10000 document retrieved from drilling info in 33245ms
10000 document retrieved from drilling info in 30762ms
10000 document retrieved from drilling info in 30582ms
10000 document retrieved from drilling info in 32698ms
10000 document retrieved from drilling info in 34759ms
10000 document retrieved from drilling info in 30460ms
10000 document retrieved from drilling info in 31425ms
10000 document retrieved from drilling info in 27308ms
10000 document retrieved from drilling info in 39467ms
10000 document retrieved from drilling info in 33245ms
10000 document retrieved from drilling info in 32799ms
10000 document retrieved from drilling info in 32051ms
10000 document retrieved from drilling info in 30109ms
10000 document retrieved from drilling info in 28315ms
10000 document retrieved from drilling info in 28869ms
10000 document retrieved from drilling info in 30472ms
10000 document retrieved from drilling info in 30993ms
10000 document retrieved from drilling info in 26829ms
10000 document retrieved from drilling info in 32028ms
10000 document retrieved from drilling info in 27401ms
10000 document retrieved from drilling info in 32514ms
10000 document retrieved from drilling info in 29963ms
10000 document retrieved from drilling info in 29217ms
10000 document retrieved from drilling info in 29864ms
10000 document retrieved from drilling info in 29581ms
10000 document retrieved from drilling info in 33924ms
10000 document retrieved from drilling info in 28370ms
10000 document retrieved from drilling info in 29459ms
10000 document retrieved from drilling info in 34737ms
10000 document retrieved from drilling info in 33039ms
10000 document retrieved from drilling info in 35782ms
10000 document retrieved from drilling info in 28856ms
10000 document retrieved from drilling info in 28481ms
10000 document retrieved from drilling info in 30035ms
10000 document retrieved from drilling info in 33868ms
10000 document retrieved from drilling info in 34353ms
10000 document retrieved from drilling info in 30140ms
10000 document retrieved from drilling info in 34348ms
10000 document retrieved from drilling info in 30579ms
10000 document retrieved from drilling info in 30669ms
10000 document retrieved from drilling info in 30840ms
10000 document retrieved from drilling info in 32407ms
10000 document retrieved from drilling info in 37983ms
10000 document retrieved from drilling info in 37255ms
10000 document retrieved from drilling info in 37017ms
10000 document retrieved from drilling info in 33145ms
10000 document retrieved from drilling info in 34565ms
10000 document retrieved from drilling info in 29257ms
10000 document retrieved from drilling info in 31529ms
10000 document retrieved from drilling info in 29333ms
10000 document retrieved from drilling info in 27850ms
10000 document retrieved from drilling info in 26887ms
10000 document retrieved from drilling info in 34258ms
10000 document retrieved from drilling info in 30732ms
10000 document retrieved from drilling info in 31214ms
10000 document retrieved from drilling info in 33744ms
10000 document retrieved from drilling info in 36096ms
10000 document retrieved from drilling info in 36698ms
10000 document retrieved from drilling info in 41142ms
10000 document retrieved from drilling info in 34408ms
10000 document retrieved from drilling info in 36137ms
10000 document retrieved from drilling info in 34376ms
10000 document retrieved from drilling info in 29543ms
10000 document retrieved from drilling info in 27836ms
10000 document retrieved from drilling info in 35384ms
10000 document retrieved from drilling info in 30637ms
10000 document retrieved from drilling info in 33167ms
10000 document retrieved from drilling info in 30771ms
10000 document retrieved from drilling info in 31883ms
10000 document retrieved from drilling info in 29560ms
10000 document retrieved from drilling info in 32485ms
10000 document retrieved from drilling info in 29737ms
10000 document retrieved from drilling info in 32287ms
10000 document retrieved from drilling info in 33086ms
10000 document retrieved from drilling info in 34381ms
10000 document retrieved from drilling info in 30143ms
10000 document retrieved from drilling info in 28900ms
10000 document retrieved from drilling info in 28814ms
10000 document retrieved from drilling info in 29585ms
10000 document retrieved from drilling info in 31472ms
10000 document retrieved from drilling info in 28400ms
10000 document retrieved from drilling info in 27130ms
10000 document retrieved from drilling info in 29285ms
10000 document retrieved from drilling info in 27855ms
10000 document retrieved from drilling info in 33570ms
10000 document retrieved from drilling info in 32690ms
10000 document retrieved from drilling info in 34647ms
10000 document retrieved from drilling info in 35590ms
10000 document retrieved from drilling info in 31191ms
10000 document retrieved from drilling info in 31289ms
10000 document retrieved from drilling info in 35092ms
10000 document retrieved from drilling info in 33669ms
10000 document retrieved from drilling info in 34618ms
10000 document retrieved from drilling info in 31459ms
10000 document retrieved from drilling info in 33280ms
10000 document retrieved from drilling info in 35181ms
10000 document retrieved from drilling info in 28495ms
10000 document retrieved from drilling info in 32159ms
10000 document retrieved from drilling info in 26400ms
10000 document retrieved from drilling info in 31027ms
10000 document retrieved from drilling info in 32057ms
10000 document retrieved from drilling info in 35479ms
10000 document retrieved from drilling info in 35370ms
10000 document retrieved from drilling info in 35749ms
10000 document retrieved from drilling info in 38962ms
10000 document retrieved from drilling info in 34345ms
10000 document retrieved from drilling info in 38730ms
10000 document retrieved from drilling info in 35426ms
10000 document retrieved from drilling info in 31972ms
10000 document retrieved from drilling info in 28594ms
10000 document retrieved from drilling info in 34918ms
10000 document retrieved from drilling info in 34829ms
10000 document retrieved from drilling info in 30132ms
10000 document retrieved from drilling info in 29871ms
10000 document retrieved from drilling info in 31701ms
10000 document retrieved from drilling info in 29714ms
10000 document retrieved from drilling info in 41869ms
10000 document retrieved from drilling info in 31332ms
10000 document retrieved from drilling info in 30881ms
10000 document retrieved from drilling info in 27646ms
10000 document retrieved from drilling info in 35824ms
10000 document retrieved from drilling info in 33981ms
10000 document retrieved from drilling info in 30621ms
10000 document retrieved from drilling info in 33030ms
10000 document retrieved from drilling info in 32101ms
10000 document retrieved from drilling info in 30283ms
10000 document retrieved from drilling info in 32008ms
10000 document retrieved from drilling info in 33291ms
10000 document retrieved from drilling info in 29765ms
10000 document retrieved from drilling info in 32957ms
10000 document retrieved from drilling info in 28654ms
10000 document retrieved from drilling info in 32967ms
10000 document retrieved from drilling info in 35484ms
10000 document retrieved from drilling info in 29035ms
10000 document retrieved from drilling info in 28076ms
10000 document retrieved from drilling info in 30828ms
10000 document retrieved from drilling info in 28681ms
10000 document retrieved from drilling info in 31614ms
10000 document retrieved from drilling info in 31139ms
10000 document retrieved from drilling info in 32478ms
10000 document retrieved from drilling info in 32249ms
10000 document retrieved from drilling info in 32583ms
10000 document retrieved from drilling info in 26855ms
10000 document retrieved from drilling info in 32618ms
10000 document retrieved from drilling info in 31530ms
10000 document retrieved from drilling info in 33505ms
10000 document retrieved from drilling info in 28491ms
10000 document retrieved from drilling info in 32219ms
10000 document retrieved from drilling info in 31921ms
10000 document retrieved from drilling info in 36182ms
10000 document retrieved from drilling info in 27819ms
10000 document retrieved from drilling info in 33552ms
10000 document retrieved from drilling info in 32864ms
10000 document retrieved from drilling info in 32881ms
10000 document retrieved from drilling info in 34619ms
10000 document retrieved from drilling info in 35399ms
10000 document retrieved from drilling info in 33331ms
10000 document retrieved from drilling info in 33018ms
10000 document retrieved from drilling info in 32367ms
10000 document retrieved from drilling info in 29530ms
10000 document retrieved from drilling info in 30737ms
10000 document retrieved from drilling info in 31398ms
10000 document retrieved from drilling info in 28547ms
10000 document retrieved from drilling info in 28697ms
10000 document retrieved from drilling info in 29487ms
10000 document retrieved from drilling info in 29142ms
10000 document retrieved from drilling info in 26086ms
10000 document retrieved from drilling info in 28505ms
10000 document retrieved from drilling info in 29352ms
10000 document retrieved from drilling info in 29361ms
10000 document retrieved from drilling info in 32826ms
10000 document retrieved from drilling info in 36911ms
10000 document retrieved from drilling info in 49231ms
10000 document retrieved from drilling info in 41503ms
10000 document retrieved from drilling info in 51916ms
10000 document retrieved from drilling info in 46215ms
10000 document retrieved from drilling info in 49872ms
10000 document retrieved from drilling info in 36547ms
10000 document retrieved from drilling info in 46456ms
10000 document retrieved from drilling info in 39350ms
10000 document retrieved from drilling info in 34103ms
10000 document retrieved from drilling info in 29846ms
10000 document retrieved from drilling info in 40695ms
10000 document retrieved from drilling info in 38140ms
10000 document retrieved from drilling info in 30917ms
10000 document retrieved from drilling info in 30413ms
10000 document retrieved from drilling info in 37188ms
10000 document retrieved from drilling info in 35074ms
10000 document retrieved from drilling info in 25183ms
10000 document retrieved from drilling info in 30300ms
10000 document retrieved from drilling info in 42446ms
10000 document retrieved from drilling info in 41502ms
10000 document retrieved from drilling info in 47613ms
10000 document retrieved from drilling info in 44691ms
10000 document retrieved from drilling info in 42053ms
10000 document retrieved from drilling info in 42599ms
10000 document retrieved from drilling info in 43137ms
10000 document retrieved from drilling info in 45390ms
10000 document retrieved from drilling info in 29042ms
10000 document retrieved from drilling info in 47628ms
10000 document retrieved from drilling info in 42585ms
10000 document retrieved from drilling info in 44695ms
10000 document retrieved from drilling info in 43779ms
10000 document retrieved from drilling info in 66541ms
10000 document retrieved from drilling info in 65961ms
10000 document retrieved from drilling info in 92535ms
10000 document retrieved from drilling info in 110809ms
10000 document retrieved from drilling info in 88297ms
10000 document retrieved from drilling info in 57909ms
10000 document retrieved from drilling info in 51888ms
10000 document retrieved from drilling info in 84034ms

Error:

---------------------------------------------------------------------------
DAQueryException                          Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11504/2259352277.py in <module>
     32         for idx in range(PAGE_SIZE):
     33             try:
---> 34                 doc = next(resp)
     35             except StopIteration:
     36                 bool_done = True

~\source\py\.venv\lib\site-packages\enverus_developer_api\__init__.py in query(self, dataset, **options)
    440 
    441             if not response.ok:
--> 442                 raise DAQueryException(
    443                     "Non-200 response: {} {}".format(response.status_code, response.text)
    444                 )

DAQueryException: Non-200 response: 403 Authentication failed
joseramosenverus commented 1 year ago

@adrian5040 are you still having these issues? If so, can you also provide the following? OS name and version

Python version

full log of program launch in debug mode