Python interface to PetroVisor REST API. This lib is currently in development and is subject to change.
Install petrovisor
package from pip
pip install petrovisor
or from the source
python -m pip install .
Make sure that pip
, setuptools
and build
are up to date
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
python -m pip install --upgrade build
Uninstall petrovisor
package
python -m pip uninstall petrovisor
REST API interface is implemented using requests
Other dependencies include
Details of the API endpoints and data models can be found in the Swagger links below, which are always up-to-date.
PetroVisor Web API (US1)
PetroVisor Web API (EU1)
Other documentation can be found by the following link.
If one uses Jupyter notebook or running Python script from console for authorization the user required to specify the workspace
and discovery_url
.
# workspace
workspace = 'Workspace Name'
# url
discovery_url = r'https://identity.us1.petrovisor.com' # US
# discovery_url = r'https://identity.eu1.petrovisor.com' # EU (alternative)
username
and password
credentials can be entered either by using the login dialog
pv_api = pv.PetroVisor(workspace = workspace,
discovery_url = discovery_url)
or by specifying username
and password
arguments directly
pv_api = pv.PetroVisor(workspace = workspace,
discovery_url = discovery_url,
username = username,
password = password)
Basic API requests such as get
, post
, put
, delete
consist of main URL/route part,
as well as an optional data
and query
string arguments.
data
and query
arguments can presented by the built-in Python dictionary.
name = 'Well'
pv_api.put(f'Entities/{name}', data = {
'Name': name,
'EntityTypeName': 'Well',
'Alias': 'Well Alias',
'IsOpportunity': False,
})
old_name = 'Well'
new_name = 'New Well'
pv_api.post(f'Entities/Rename', query = {
'OldName': old_name,
'NewName': new_name,
})
name = 'New Well'
pv_api.get(f'Entities/{name}')
name = 'New Well'
pv_api.delete(f'Entities/{name}')
More examples can be found in the examples
directory of the repository.