Skip to main content

ComboCurve client for Python

Authorization

combocurve_api requires the API key and service account provided by ComboCurve, as shown in the example below:

from combocurve_api_v1 import ServiceAccount, ComboCurveAuth

# Use this to create your service account manually
service_account = ServiceAccount(
    client_email='YOUR_CLIENT_EMAIL',
    client_id='YOUR_CLIENT_ID',
    private_key='YOUR_PRIVATE_KEY',
    private_key_id='YOUR_PRIVATE_KEY_id'
)
# Or use this to load it from a JSON file
# service_account = ServiceAccount.from_file("PATH_TO_JSON_FILE")

# Set your API key
api_key = 'YOUR_API_KEY'

combocurve_auth = ComboCurveAuth(service_account, api_key)

# Get auth headers
auth_headers = combocurve_auth.get_auth_headers()

combocurve_auth.get_auth_headers() should be called before every request so that the token can be refreshed if it's about to expire. After getting the authentication headers, they can be used with any HTTP client library. Below is an example using the Requests library:

import requests

data = [{
    'wellName': 'well 1',
    'dataSource': 'internal',
    'chosenID': '1234'
}, {
    'wellName': 'well 2',
    'dataSource': 'internal',
    'chosenID': '4321'
}]
auth_headers = combocurve_auth.get_auth_headers()
url = 'https://api.combocurve.com/v1/wells'

response = requests.put(url, headers=auth_headers, json=data)
print(response.json())

Content-Type

The ComboCurve API only accepts data serialized as JSON and the Content-Type header must be application/json. Luckily, Requests will take care of both things when the data is passed using the json parameter, as you saw in the example above. Using the data parameter would be less convenient but it works too:

import json

response = requests.put(url,
                        headers={
                            **auth_headers, 'Content-Type': 'application/json'
                        },
                        data=json.dumps(data))

More information here: https://docs.python-requests.org/en/latest/user/quickstart/#more-complicated-post-requests

Pagination

When the number of records to be returned for a request is larger than the maximum number of records that can be retrieved in a single response, the requester will need to "paginate", i.e., make multiple requests while there are more records to be returned.

This package provides a helper to assist with that. It parses the response headers and returns a new URL for the next request, if another request is needed. See this example using the Requests library:

from combocurve_api_v1.pagination import get_next_page_url

# See Authorization section
auth_headers = combocurve_auth.get_auth_headers()

# Additional filters are allowed, it is preferred not specify skip if its value is 0
url = 'https://api.combocurve.com/v1/wells?take=200'

# First request
has_more = True

# Keep fetching while there are more records to be returned
while has_more:
    response = requests.get(url, headers=headers)

    # Process response

    url = get_next_page_url(response.headers)
    has_more = url is not None

Metadata

Release files for combocurve-api-v1 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for combocurve-api-v1 0.2.7
File Size Uploaded Provenance
combocurve_api_v1-0.2.7.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for combocurve-api-v1 0.2.7
File Interpreter ABI Platform
combocurve_api_v1-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / combocurve_api_v1-0.2.7.tar.gz

Download URL combocurve_api_v1-0.2.7.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
564eb4b74ff5617d4c31f09ce3317fd79d6feb24f43980ab52436880b2cc6137
BLAKE2b-256 checksum
How to use checksums
9b49a620525b64674ae0714f579a6de5d0cd280e7cb04ce524ed4509c21cf04e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / combocurve_api_v1-0.2.7-py3-none-any.whl

Download URL combocurve_api_v1-0.2.7-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99c6fd880837d00ca492bd4dc43c86f917796e3bf8c38904960c3edf478ddada
BLAKE2b-256 checksum
How to use checksums
6b12080f2198276f37241641b339a9906b27efa338c612d004467fdbe286144d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for combocurve-api-v1 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page