Whitson Python SDK for developers, data scientists, and engineers working with
Project description
Whitson Python SDK
This is the Whitson Python SDK for developers, data scientists, and engineers working with Whitson+.
The API documentation is accessible with the client name: https://<CLIENT_NAME>.whitson.com/api-external/swagger/
The source code is located in the whitson/client
directory.
Example usage:
import json
from decouple import config
from dacite import from_dict
from whitson.client import Token, ClientConfig, WhitsonClient
# Define connection details as environment variables
CLIENT_NAME = config("WHITSON_CLIENT_NAME")
CLIENT_ID = config("WHITSON_CLIENT_ID")
CLIENT_SECRET = config("WHITSON_CLIENT_SECRET")
# Check for access token
with open("token.json") as f:
token = from_dict(data=json.load(f), data_class=Token)
# Define configuration parameters to retrieve access token
# If no token is specified, a new one will be requested and the output printed.
# If certain certificates are required for data to be requested, this can be specified in a PEM file
config = ClientConfig(
token=token,
client_name=CLIENT_NAME,
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
pem_path="custom_cacerts.pem"
)
# Instantiate client and retrieve data
client = WhitsonClient(config)
# Example
project_id = 161
well_id = 228368
result = client.get(suffix=f"wells/{well_id}/bhp_calculation", params={"project_id": project_id})
The access token can be stored in a JSON
file as shown below:
{
'access_token': '<access-token-value>',
'scope': 'get:api post:api delete:api',
'expires_in': 86400,
'token_type': 'Bearer',
'issued_at': 1692136969.7024412
}
Acknowledgements
I learned a great deal from the amazing and talented people at Cognite and this repository is heavily based off of the structure of the publicly available Cognite Python SDK. Thank you for the incredible experience and the continued learning your resources have provided me.
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
Built Distribution
Hashes for whitson_sdk_python-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2e52815b74b5c8eb0bb9650b3da81173d161dcccee211139ef4c745745a5a4e |
|
MD5 | b8ccf4ddc5cd0e95e7bef4e1e2ed0d1d |
|
BLAKE2b-256 | e63385801b010983111dbfc2e101fbda54c7c801f4dc57ccb739c13699ad0014 |