Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 56 lines (34 sloc) 1.689 kB
a491e3b @mattdeboard Added README.
authored
1 ==============
2 Python-USDOL
3 ==============
4
5 Python wrapper for the US Dept. of Labor's `developer API <http://developer.dol.gov/>`_.
c5236b7 @mattdeboard Some PEP8 housekeeping, updated README and added LICENSE.
authored
6
7 -----
8 Usage
9 -----
10
badb820 @mattdeboard Update & clean up README.
authored
11 Usage is straightforward::
c5236b7 @mattdeboard Some PEP8 housekeeping, updated README and added LICENSE.
authored
12
13 import python_usdol
14
3d6fae0 @mattdeboard updated readme
authored
15 conn = python_usdol.Connection(token='mytoken', secret='mysharedsecret')
239ffff @mattdeboard Fixed typo in README
authored
16
c5236b7 @mattdeboard Some PEP8 housekeeping, updated README and added LICENSE.
authored
17 data = conn.fetch_data('FAQ', 'Topic')
18
19
20 Where 'FAQ' and 'Topic' are the names of the targeted dataset and table within the dataset, respectively. For a full list of datasets and tables, please consult the Dept. of Labor's developer website, linked above.
21
badb820 @mattdeboard Update & clean up README.
authored
22 ``fetch_data`` returns a dictionary, with a key for each column on the database you've specified, with an additional ``__metadata`` key.
c5236b7 @mattdeboard Some PEP8 housekeeping, updated README and added LICENSE.
authored
23
24
0abc7e7 @mattdeboard Mop up some crummy rst formatting.
authored
25 Some datasets have "multipart" names, e.g. the `Consumer Expenditure Survey Dataset <http://developer.dol.gov/ConsumerExpenditure-DATASET.htm>`_. In this case, since the base url is ``http://api.dol.gov/V1/Statistics/ConsumerExpenditure``, vice e.g. ``.../V1/FORMS``, for the first argument to fetch data, you would pass the "multipart" Agency name::
c196178 @mattdeboard Updated README to provide better explanation of multi-part agency names.
authored
26
27 data = conn.fetch_data('Statistics/ConsumerExpenditure', '<desired table name>')
0f12a77 @mattdeboard Updated README and fetch_data docstring to explain query params better.
authored
28
29 -----------
30 Parameters
31 -----------
32
badb820 @mattdeboard Update & clean up README.
authored
33 Python-USDOL has support for the following methods outlined in the DOL's `API Access Guide <http://developer.dol.gov/html-req.htm>`_:
73fd0b6 @mattdeboard Updated readme to reflect latest revision.
authored
34
badb820 @mattdeboard Update & clean up README.
authored
35 - ``$metadata``
36 - ``$top``
37 - ``$skip``
38 - ``$orderby``
39 - ``$filter``
73fd0b6 @mattdeboard Updated readme to reflect latest revision.
authored
40
41 ------
42 Filter
43 ------
44
badb820 @mattdeboard Update & clean up README.
authored
45 Using the filter method goes thusly::
73fd0b6 @mattdeboard Updated readme to reflect latest revision.
authored
46
47 data = conn.fetch_data("FAQ", "Topic", filter_="TopicID eq 5")
48
badb820 @mattdeboard Update & clean up README.
authored
49 Since ``filter`` is a keyword in Python, Python-USDOL uses ``filter_`` in its place.
0f12a77 @mattdeboard Updated README and fetch_data docstring to explain query params better.
authored
50
c5236b7 @mattdeboard Some PEP8 housekeeping, updated README and added LICENSE.
authored
51 ------
52 Future
53 ------
54
55 Please help make this API better for everyone by reporting bugs, forking and submitting patches.
Something went wrong with that request. Please try again.