Skip to main content

python-demandapi-client

PyPI version

GitHub Actions status

A Python client library for the Dynata Demand API. There are also go and .NET clients available.

Setup

You can install the Demand API client with:

pip install dynatademand

You can provide your Demand API credentials in a couple of ways. They can be set in the environment (a sample config is provided in .env-example) or you can provide them while creating the client object.

Example Usage

# You can optionally provide your credentials here instead of environment variables.
demandapi = DemandAPIClient("client_id", "username", "password")
demandapi.authenticate()

# Any function requiring one or more IDs should be provided as positional arguments.
demandapi.get_project(7)

# Provide query parameters as keyword-arguments.
demandapi.get_projects(state="LAUNCHED")

# Functions that send data in a request body accept a python dictionary.
# Your data will be validated against the schemas provided in the Demand API documentation.
project_data = {
  'title': 'My New Survey',
  ...
}
demandapi.create_project(project_data)

Supported API Functions

Links to the Demand API documentation are included for each function.

Authentication Functions

Obtain Access Token: authenticate()
Refresh Access Token: refresh_access_token()
Logout: logout()

Event Functions

Get Event: get_event(event_id)
Get Events: get_events(**kwargs)

Project Functions

Buy Project: buy_project(project_id, buy_data)
Close Project: close_project(project_id)
Create Project: create_project(project_data)
Get Project: get_project(project_id)
Get Projects: get_projects(**kwargs)
Update Project: update_project(project_id, update_data)
Get Project Detailed Report: get_project_detailed_report(project_id)
Get Pricing & Feasibility: get_feasibility(project_id)
Get Invoice PDF: get_invoice(project_id)
Get Invoices Summary PDF: get_invoices_summary(**kwargs)

Line Item Functions

Add Line Item: add_line_item(project_id, lineitem_data)
Close Line Item: close_line_item(project_id, line_item_id)
Get Line Item: get_line_item(project_id, line_item_id)
Get Line Items: get_line_items(project_id, **kwargs)
Launch Line Item: launch_line_item(project_id, line_item_id)
Pause Line Item: pause_line_item(project_id, line_item_id)
Update Line Item: update_line_item(project_id, line_item_id, line_item_data)
Get Line Item Detailed Report: get_line_item_detailed_report(project_id, line_item_id) Launch Quota cell: set_quotacell_status(project_id, line_item_id, quota_cell_id, launch)
Pause Quota cell: set_quotacell_status(project_id, line_item_id, quota_cell_id, pause)

Misc Functions

Get Attributes: get_attributes(country_code, language_code, **kwargs)
Get Countries: get_countries(**kwargs)
Get Sources: get_sources()
Get Survey Topics: get_survey_topics(**kwargs)

Contributing

Information on contributing.

Testing

To run the tests, you will need to install the development requirements to your environment. It's recommended to create a virtual environment for your installation to avoid any package conflicts.

You can check out the code by running:

git clone https://github.com/dynata/python-demandapi-client.git
cd python-demandapi-client

And you can create an environment by running:

# If you're using Python 2.7
virtualenv venv

# Or if you're using Python 3:
python3 -m venv venv

source venv/bin/activate
pip install -r requirements.txt

While your virtual environment is activated, you can run pytest tests to run the tests.

Release files for dynatademand 1.0.5

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

Source distribution (sdist)

Source distribution for dynatademand 1.0.5
File Size Uploaded
dynatademand-1.0.5.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dynatademand 1.0.5
File Interpreter ABI Platform
dynatademand-1.0.5-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 46.4 kB

Release files / dynatademand-1.0.5.tar.gz

Download URL dynatademand-1.0.5.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b631e011d0d140952ea06d88031de5ed4aacd1316962d08b4a108ae224b13572
BLAKE2b-256 checksum
How to use checksums
96b9c9cf333ce63ffbd5efcedd128fa57d47b2a620eafae1267aaf9b861d9e45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/2.7.10 Darwin/18.6.0

Release files / dynatademand-1.0.5-py2.py3-none-any.whl

Download URL dynatademand-1.0.5-py2.py3-none-any.whl
Size 30.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2c4003798bd3be78df111520e777f365831322d7bbf399224ae0a2918f103fad
BLAKE2b-256 checksum
How to use checksums
b2d8ad167bb474eeb22f3b7674c0ad037abfb8ce222e25faa30af0b632e85c47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.0 CPython/2.7.10 Darwin/18.6.0

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

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