|
1 | 1 | ## Dataverse API Client |
2 | 2 |
|
3 | 3 | This is a library for writing Python applications that make use of Dataverse |
4 | | -APIs v4.0. The code started as a "proof of concept" in the |
5 | | -[dvn/swordpoc](https://github.com/dvn/swordpoc) repo and the intent is to |
6 | | -publish the python client on https://pypi.python.org. |
| 4 | +APIs v4.0. The intent is to publish the python client on https://pypi.python.org. |
7 | 5 |
|
8 | 6 | ## Installation |
9 | 7 |
|
10 | | -This client requires python 2.6+. |
11 | | -It has not been tested in python 3. |
| 8 | + $ pip install -e git+https://github.com/IQSS/dataverse-client-python.git#egg=dataverse |
| 9 | + |
| 10 | +Requires Python >= 2.6. |
12 | 11 |
|
13 | | -To install dataverse as a package: |
14 | 12 |
|
15 | | - $ pip install -e git+https://github.com/rliebz/dvn-client-python.git#egg=dataverse |
| 13 | +## Usage |
16 | 14 |
|
17 | | -## Configuration |
| 15 | +To use the python client, you will need a dataverse account and an API token. |
| 16 | +```python |
| 17 | +from dataverse import Connection |
| 18 | + |
| 19 | +host = 'apitest.dataverse.org' # All clients >4.0 are supported |
| 20 | +token = '4d0634d3-74d5-4770-8088-1971847ac75e' # Generated at /account/apitoken |
| 21 | + |
| 22 | +connection = Connection(host, token) |
| 23 | +``` |
| 24 | + |
| 25 | +Dataverse Objects can be retrieved from their respective containers |
| 26 | +```python |
| 27 | +dataverse = connection.get_dataverse('ALIAS') |
| 28 | +dataset = dataverse.get_dataset_by_doi('DOI:10.5072/FK2/ABC123') |
| 29 | +files = dataset.get_files('latest') |
| 30 | +``` |
| 31 | + |
| 32 | +## Testing |
| 33 | + |
| 34 | +### Configuration |
18 | 35 |
|
19 | 36 | Create a file at `settings/local.py`. The file should contain the following |
20 | 37 | information: |
21 | 38 |
|
22 | 39 | ```python |
23 | | -DEFAULT_HOST = "dataverse-demo.iq.harvard.edu" |
| 40 | +DEFAULT_HOST = "apitest.dataverse.org" |
24 | 41 | DEFAULT_TOKEN = "" # Token can be generated at {host}/account/apitoken |
25 | 42 | ``` |
26 | 43 |
|
27 | 44 | Do not commit this file. |
28 | 45 |
|
29 | | -## Testing |
| 46 | +### Running Tests |
30 | 47 |
|
31 | 48 | In order to run any tests, you must first create a Dataverse on the |
32 | 49 | host you wish to test. Do not run tests on the production server. |
33 | 50 |
|
34 | | -To run tests |
| 51 | +To run tests: |
35 | 52 |
|
36 | 53 | $ cd dataverse/test |
37 | 54 | $ python -m unittest test_dataverse |
0 commit comments