Skip to content

Commit 7e97e6b

Browse files
authored
Merge pull request #38 from dynata/feature/more-docs
Updated README with more detailed usage examples and more explanation…
2 parents 2a4e6e7 + d2c01ea commit 7e97e6b

File tree

1 file changed

+69
-36
lines changed

1 file changed

+69
-36
lines changed

README.md

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,108 @@
11
# python-demandapi-client
22

3+
[![PyPI version](https://badge.fury.io/py/dynatademand.svg)](https://pypi.org/project/dynatademand/)
4+
35
<a href="https://github.com/dynata/python-demandapi-client/actions?query=branch%3Adev"><img alt="GitHub Actions status" src="https://github.com/dynata/python-demandapi-client/workflows/python-tests/badge.svg"></a>
46

57
A Python client library for the [Dynata Demand API](https://developers.dynata.com/). There are also [go](https://github.com/researchnow/go-samplifyapi-client) and [.NET](https://github.com/researchnow/dotnet-samplifyapi-client) clients available.
68

79
## Setup
810

9-
The client requires environment variables to be set for the Dynata Demand API credentials. These can be found in `.env-example`.
11+
You can install the Demand API client with:
12+
13+
pip install dynatademand
14+
15+
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.
1016

1117
## Example Usage
1218

13-
demandapi = DemandAPIClient()
14-
demandapi.authenticate()
15-
demandapi.logout()
19+
```python
20+
# You can optionally provide your credentials here instead of environment variables.
21+
demandapi = DemandAPIClient("client_id", "username", "password")
22+
demandapi.authenticate()
23+
24+
# Any function requiring one or more IDs should be provided as positional arguments.
25+
demandapi.get_project(7)
26+
27+
# Provide query parameters as keyword-arguments.
28+
demandapi.get_projects(state="LAUNCHED")
29+
30+
# Functions that send data in a request body accept a python dictionary.
31+
# Your data will be validated against the schemas provided in the Demand API documentation.
32+
project_data = {
33+
'title': 'My New Survey',
34+
...
35+
}
36+
demandapi.create_project(project_data)
37+
```
1638

1739
## Supported API Functions
1840

41+
Links to the Demand API documentation are included for each function.
42+
1943
### Authentication Functions
2044

21-
authenticate()
22-
refresh_access_token()
23-
logout()
45+
[Obtain Access Token](https://developers.dynata.com/demand-api-reference/authentication/authentication/post-token): authenticate()
46+
[Refresh Access Token](https://developers.dynata.com/demand-api-reference/authentication/authentication/post-token-refresh): refresh_access_token()
47+
[Logout](https://developers.dynata.com/demand-api-reference/authentication/authentication/post-logout): logout()
2448

2549
### Event Functions
2650

27-
get_event(event_id)
28-
get_events(\*\*kwargs)
51+
[Get Event](https://developers.dynata.com/demand-api-reference/notifications/events/get-event): get_event(event_id)
52+
[Get Events](https://developers.dynata.com/demand-api-reference/notifications/events/get-events): get_events(\*\*kwargs)
2953

3054
### Project Functions
3155

32-
buy_project(project_id, buy_data)
33-
close_project(project_id)
34-
create_project(project_data)
35-
get_project(project_id)
36-
get_projects(\*\*kwargs)
37-
reconcile_project(project_id, reconcile_data)
38-
update_project(project_id, update_data)
39-
get_project_detailed_report(project_id)
40-
get_feasibility(project_id)
41-
get_invoice(project_id)
56+
[Buy Project](https://developers.dynata.com/demand-api-reference/core-resources/projects/post-project-buy): buy_project(project_id, buy_data)
57+
[Close Project](https://developers.dynata.com/demand-api-reference/core-resources/projects/post-close-project): close_project(project_id)
58+
[Create Project](https://developers.dynata.com/demand-api-reference/core-resources/projects/post-projects): create_project(project_data)
59+
[Get Project](https://developers.dynata.com/demand-api-reference/core-resources/projects/get-project): get_project(project_id)
60+
[Get Projects](https://developers.dynata.com/demand-api-reference/core-resources/projects/get-projects): get_projects(\*\*kwargs)
61+
[Update Project](https://developers.dynata.com/demand-api-reference/core-resources/projects/post-project): update_project(project_id, update_data)
62+
[Get Project Detailed Report](https://developers.dynata.com/demand-api-reference/core-resources/projects/get-project-detailed-report): get_project_detailed_report(project_id)
63+
[Get Pricing & Feasibility](https://developers.dynata.com/demand-api-reference/core-resources/pricing-feasibility/get-pricing-feasibility): get_feasibility(project_id)
64+
[Get Invoice PDF](https://developers.dynata.com/demand-api-reference/billing_invoicing/invoicing/get-invoices): get_invoice(project_id)
4265

4366
### Line Item Functions
4467

45-
add_line_item(project_id, lineitem_data)
46-
close_line_item(project_id, line_item_id)
47-
get_line_item(project_id, line_item_id)
48-
get_line_items(project_id, \*\*kwargs)
49-
launch_line_item(project_id, line_item_id)
50-
pause_line_item(project_id, line_item_id)
51-
update_line_item(project_id, line_item_id, line_item_data)
52-
get_line_item_detailed_report(project_id, line_item_id)
68+
[Add Line Item](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/post-lineitems): add_line_item(project_id, lineitem_data)
69+
[Close Line Item](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/post-lineitem-close): close_line_item(project_id, line_item_id)
70+
[Get Line Item](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/get-lineitem): get_line_item(project_id, line_item_id)
71+
[Get Line Items](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/get-lineitems): get_line_items(project_id, \*\*kwargs)
72+
[Launch Line Item](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/post-lineitem-launch): launch_line_item(project_id, line_item_id)
73+
[Pause Line Item](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/post-lineitem-pause): pause_line_item(project_id, line_item_id)
74+
[Update Line Item](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/post-lineitem): update_line_item(project_id, line_item_id, line_item_data)
75+
[Get Line Item Detailed Report](https://developers.dynata.com/demand-api-reference/core-resources/lineitems/get-detailed-line-item): get_line_item_detailed_report(project_id, line_item_id)
5376

5477
### Misc Functions
5578

56-
get_attributes(country_code, language_code, \*\*kwargs)
57-
get_countries(\*\*kwargs)
58-
get_sources()
59-
get_survey_topics(\*\*kwargs)
79+
[Get Attributes](https://developers.dynata.com/demand-api-reference/data_endpoints/attributes/get-attributes): get_attributes(country_code, language_code, \*\*kwargs)
80+
[Get Countries](https://developers.dynata.com/demand-api-reference/data_endpoints/countries-languages/get-countries): get_countries(\*\*kwargs)
81+
[Get Sources](https://developers.dynata.com/demand-api-reference/data_endpoints/supplier-sources/get-sources): get_sources()
82+
[Get Survey Topics](https://developers.dynata.com/demand-api-reference/data_endpoints/categories/get-survey-topic): get_survey_topics(\*\*kwargs)
6083

6184
## Contributing
6285

6386
Information on [contributing](CONTRIBUTING.md).
6487

6588
## Testing
6689

67-
To run the tests,
90+
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.
91+
92+
You can check out the code by running:
93+
94+
git clone https://github.com/dynata/python-demandapi-client.git
95+
cd python-demandapi-client
6896

97+
And you can create an environment by running:
98+
99+
# If you're using Python 2.7
69100
virtualenv venv
70-
. venv/bin/activate
101+
102+
# Or if you're using Python 3:
103+
python3 -m venv venv
104+
105+
source venv/bin/activate
71106
pip install -r requirements.txt
72-
pytest tests
73-
deactivate
74107

75-
to run the tests for this project.
108+
While your virtual environment is activated, you can run `pytest tests` to run the tests.

0 commit comments

Comments
 (0)