Skip to main content

Python API for PetroVisor platform.

Project description

PetroVisor API

PyPI Latest Release

Python interface to PetroVisor REST API. This lib is currently in development and is subject to change.

Install

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

Uninstall petrovisor package

python -m pip uninstall petrovisor

Dependencies

REST API interface is implemented using requests

Other dependencies include

Documentation

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.

PetroVisor REST API

How to use

Authorization

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)

Examples: Get, Post, Put, Delete requests

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.

Put request

name = 'Well'
pv_api.put(f'Entities/{name}', data = {
  'Name': name,
  'EntityTypeName': 'Well',
  'Alias': 'Well Alias',
  'IsOpportunity': False,
})

Post request

old_name = 'Well'
new_name = 'New Well'
pv_api.post(f'Entities/Rename', query = {
    'OldName': old_name,
    'NewName': new_name,
})

Get request

name = 'New Well'
pv_api.get(f'Entities/{name}')

Delete request

name = 'New Well'
pv_api.delete(f'Entities/{name}')

More examples can be found in the examples directory of the repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

petrovisor-0.1.7.tar.gz (67.4 kB view hashes)

Uploaded Source

Built Distribution

petrovisor-0.1.7-py3-none-any.whl (77.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page