Skip to main content

A python wrapper library for the ODS Automation API

Project description

ods-utils-py

With ods-utils-py, the Automation API from Opendatasoft can be accessed directly from Python. A valid API key is required (Create an API key). The source code is publicly available on GitHub.

Table of Contents


Installation

Installation via pip:

pip install ods-utils-py

Requirements

  • Python Version: 3.11 or higher
  • API Key: A valid API key from Opendatasoft

Getting Started

Set up API Key

To use ods-utils-py, a valid API key from Opendatasoft is required.

For OGD Basel, the API key can be created here.

For key creation on other platforms, click on the username button in the top right corner to open account settings. Under API Keys, custom keys with the appropriate permissions can be created.

The name should describe its purpose, for example, "ods_utils_py - <Initial Key Name>"

The API key requires the following 4 permissions:

  • Browse all datasets
  • Create new datasets
  • Edit all datasets
  • Publish own datasets

The API key is then required as an environment variable.

Set up Environment Variables

Next, the environment variables must be defined. For this, a .ods_utils_py.env file should be created in the root directory of the project with the following content.

ODS_API_KEY=your_ods_api_key

USE_PROXY=true

PROXY_USER=your_proxy_user
PROXY_PASSWORD=your_proxy_password
PROXY_ADDRESS=your_proxy_address
PROXY_PORT=your_proxy_port

ODS_DOMAIN=data.bs.ch
ODS_API_TYPE=automation/v1.0

Important: Make sure to add **/*.env to your .gitignore to not upload the credentials to the internet!

Usage

Here's a simple example to retrieve the number of datasets:

import ods_utils_py as ods_utils

num_datasets = ods_utils.get_number_of_datasets()
print(f"We currently have {num_datasets} datasets.")

A list of all currently implemented functions can be found on GitHub.

If a desired function does not exist, it can be implemented via _requests_utils:

import ods_utils_py as ods_utils

response = ods_utils._requests_get("https://www.example.com")
print(response.text)

Note: Most of these functions should eventually be integrated into ods_utils_py if they use the Automation API.


Further Links

The complete documentation of the Automation API 1.0 can be found here.


License

This project is licensed under the MIT License. See the LICENSE file in the repository for the full license text.


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

ods_utils_py-0.1.12.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ods_utils_py-0.1.12-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file ods_utils_py-0.1.12.tar.gz.

File metadata

  • Download URL: ods_utils_py-0.1.12.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for ods_utils_py-0.1.12.tar.gz
Algorithm Hash digest
SHA256 df69ccb31378648edbaae6c5a398433a26b2311e01bfb80a09b29824b51e87ef
MD5 a03d0f9358548a805a20abe1ef3842c4
BLAKE2b-256 aa16bc8410a11c67eb6e8da1e8d42728b402bb4b59bce1fef32d1667f6e19f60

See more details on using hashes here.

File details

Details for the file ods_utils_py-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: ods_utils_py-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for ods_utils_py-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 ed2caed2ab564acdf7ea4b38d105a76202f1412aff9c365bfffc806b5aa68c0e
MD5 efecf1a79c6e9d6fcd397c843cc343c4
BLAKE2b-256 83257a783084e825b84bfe7dcef5a6c05dc82b3f6e5e1b826f971c8a417c20e8

See more details on using hashes here.

Supported by

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