Skip to content

Commit fb8b33c

Browse files
committed
Updated README with more detailed usage examples and more explanation about installing the package and running tests.
1 parent 2a4e6e7 commit fb8b33c

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

README.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,33 @@ A Python client library for the [Dynata Demand API](https://developers.dynata.co
66

77
## Setup
88

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

1115
## Example Usage
1216

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

1737
## Supported API Functions
1838

@@ -64,12 +84,22 @@ Information on [contributing](CONTRIBUTING.md).
6484

6585
## Testing
6686

67-
To run the tests,
87+
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.
6888

89+
You can check out the code by running:
90+
91+
git clone https://github.com/dynata/python-demandapi-client.git
92+
cd python-demandapi-client
93+
94+
And you can create an environment by running:
95+
96+
# If you're using Python 2.7
6997
virtualenv venv
70-
. venv/bin/activate
98+
99+
# Or if you're using Python 3:
100+
python3 -m venv venv
101+
102+
source venv/bin/activate
71103
pip install -r requirements.txt
72-
pytest tests
73-
deactivate
74104

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

0 commit comments

Comments
 (0)