Skip to content

Datagration/petrovisor-python-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PetroVisor API

PyPI Latest Release

Python interface to PetroVisor REST API.

Documentation

Python API Documentation

For comprehensive guides, tutorials, and API reference, please visit our official documentation site.

REST API Reference

The complete PetroVisor REST API specification, including all available endpoints and data models, is accessible through our Swagger documentation:

Installing petrovisor

petrovisor can be installed using pip or uv from PyPI, GitHub, or directly from the source.

Prerequisites

  • Python 3.7 or higher, Python 3.12 (Recommended)
  • pip (Python package installer) or uv (extremely fast Python package and project manager, written in Rust)

Installation Options

From PyPI (Recommended)

pip install petrovisor

or

uv pip install petrovisor

From GitHub

pip install git+https://github.com/Datagration/petrovisor-python-api.git

or

uv pip install git+https://github.com/Datagration/petrovisor-python-api.git

From Source

  1. Clone the repository
git clone https://github.com/Datagration/petrovisor-python-api.git
cd petrovisor-python-api
  1. Install the package
pip install .

or

uv pip install .

Verify Installation

You can verify that petrovisor is installed correctly by importing it in Python:

import petrovisor as pv
print(pv.__version__)

Development Setup

For contributors, you can install development dependencies with:

pip install -e "[.dev]"

or

uv pip install -e "[.dev]"

Note that package installation dependencies are defined in pyproject.toml, while the requirements.txt file includes additional packages needed for development, testing and documentation.

Package Build System

This package uses Hatchling as its build system. Hatchling is a modern, extensible Python build backend that follows the latest packaging standards (PEP 517/518).

Uninstalling petrovisor

Uninstall petrovisor package

pip uninstall petrovisor

or

uv pip uninstall petrovisor

Dependencies

REST API interface is implemented using requests

Other dependencies include

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 Name'
# url for authentification (US or EU)
discovery_url = r'https://identity.us1.petrovisor.com' # US
discovery_url = r'https://identity.eu1.petrovisor.com' # EU

username and password credentials can be entered either by using the login dialog

api = pv.PetroVisor(workspace = workspace,
                    discovery_url = discovery_url)

or by specifying username and password arguments directly

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'
api.put(f'Entities/{name}', data = {
  'Name': name,
  'EntityTypeName': 'Well',
  'Alias': 'Well Alias',
  'IsOpportunity': False,
})

Post request

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

Get request

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

Delete request

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

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

About

Python interface to PetroVisor REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •