Client wrapper for Wikimedia UMAPI.
Project description
umapi_client
============
Client wrapper for Wikipedia User Metrics API.
See https://github.com/wikimedia/user_metrics for UMAPI implementation.
Usage
-----
Set the ``UMAPI_USER`` and ``UMAPI_PASS`` in ``umapi_client/config.py``
(copied from ``umapi_client/config.py.settings``). Ensure that
``call_client`` is executable and requests are invoked by simply
calling this script followed by the URL path and parameters of a request. Only
cached responses will return a response with JSON, otherwise the request will
be queued by the service.
RFaulkner-WMF:umapi_client rfaulkner$ cd umapi_client/
RFaulkner-WMF:umapi_client rfaulkner$ ./scripts/call_client "cohorts/\
ryan_test_2/bytes_added"
{
"cohort": "ryan_test_2",
"group": "default",
"cohort_last_generated": "2013-03-19 07:43:26",
"aggregator": "None",
"metric": "bytes_added",
"namespace": [
0
],
"project": "enwiki",
"time_of_response": "2013-03-19 07:43:32",
"datetime_start": "2010-10-25 08:00:00",
"datetime_end": "2011-01-01 00:00:00",
"header": [
"user_id",
"bytes_added_net",
"bytes_added_absolute",
"bytes_added_pos",
"bytes_added_neg",
"edit_count"
],
"type": "raw",
"data": {
"15972203": [
683,
1133,
908,
-225,
5
],
"13234584": [
0,
0,
0,
0,
0
],
"15972135": [
0,
0,
0,
0,
0
]
},
"interval_hours": 24,
"t": 24
}
To save the contents to a file [-s] and timestamp the file [-t]:
RFaulkner-WMF:umapi_client rfaulkner$ ./scripts/call_client "cohorts/\
ryan_test_2/bytes_added" -s -t
Mar-29 12:47:33 DEBUG __main__ :: Attempting to create cookie jar,
logging in ..
Mar-29 12:47:34 DEBUG __main__ :: Login successful. Making request:
http://metrics.wikimedia.org/cohorts/ryan_test_2/bytes_added
Mar-29 12:47:35 DEBUG __main__ :: Writing response to file:
umapi_client_ryan_test_2_bytes_added_20130329.json
RFaulkner-WMF:umapi_client rfaulkner$ cat umapi_client_ryan_test_2_bytes_\
added_20130329.json
{
"cohort": "ryan_test_2",
"group": "default",
"cohort_last_generated": "2013-03-29 19:40:19",
"aggregator": "None",
"metric": "bytes_added",
"namespace": [
0
],
"project": "enwiki",
"time_of_response": "2013-03-29 19:40:26",
"datetime_start": "2010-10-25 08:00:00",
"datetime_end": "2011-01-01 00:00:00",
"header": [
"user_id",
"bytes_added_net",
"bytes_added_absolute",
"bytes_added_pos",
"bytes_added_neg",
"edit_count"
],
"type": "raw",
"data": {
"15972203": [
683,
1133,
908,
-225,
5
],
"13234584": [
0,
0,
0,
0,
0
],
"15972135": [
0,
0,
0,
0,
0
]
},
"interval_hours": 24,
"t": 24
}
To convert the output to csv:
RFaulkner-WMF:scripts rfaulkner$ ./json2csv umapi_client_ryan_test_2_bytes_added_20130331.json
Mar-31 23:57:20 DEBUG __main__ :: Attempting to read file...
Mar-31 23:57:20 DEBUG __main__ :: Writing to file...
RFaulkner-WMF:scripts rfaulkner$ cat ../../csv/umapi_client_ryan_test_2_bytes_added_20130331.json.csv
user_id,bytes_added_net,bytes_added_absolute,bytes_added_pos,bytes_added_neg,edit_count
13234584,0,0,0,0,0
15972203,683,1133,908,-225,5
15972135,0,0,0,0,0
============
Client wrapper for Wikipedia User Metrics API.
See https://github.com/wikimedia/user_metrics for UMAPI implementation.
Usage
-----
Set the ``UMAPI_USER`` and ``UMAPI_PASS`` in ``umapi_client/config.py``
(copied from ``umapi_client/config.py.settings``). Ensure that
``call_client`` is executable and requests are invoked by simply
calling this script followed by the URL path and parameters of a request. Only
cached responses will return a response with JSON, otherwise the request will
be queued by the service.
RFaulkner-WMF:umapi_client rfaulkner$ cd umapi_client/
RFaulkner-WMF:umapi_client rfaulkner$ ./scripts/call_client "cohorts/\
ryan_test_2/bytes_added"
{
"cohort": "ryan_test_2",
"group": "default",
"cohort_last_generated": "2013-03-19 07:43:26",
"aggregator": "None",
"metric": "bytes_added",
"namespace": [
0
],
"project": "enwiki",
"time_of_response": "2013-03-19 07:43:32",
"datetime_start": "2010-10-25 08:00:00",
"datetime_end": "2011-01-01 00:00:00",
"header": [
"user_id",
"bytes_added_net",
"bytes_added_absolute",
"bytes_added_pos",
"bytes_added_neg",
"edit_count"
],
"type": "raw",
"data": {
"15972203": [
683,
1133,
908,
-225,
5
],
"13234584": [
0,
0,
0,
0,
0
],
"15972135": [
0,
0,
0,
0,
0
]
},
"interval_hours": 24,
"t": 24
}
To save the contents to a file [-s] and timestamp the file [-t]:
RFaulkner-WMF:umapi_client rfaulkner$ ./scripts/call_client "cohorts/\
ryan_test_2/bytes_added" -s -t
Mar-29 12:47:33 DEBUG __main__ :: Attempting to create cookie jar,
logging in ..
Mar-29 12:47:34 DEBUG __main__ :: Login successful. Making request:
http://metrics.wikimedia.org/cohorts/ryan_test_2/bytes_added
Mar-29 12:47:35 DEBUG __main__ :: Writing response to file:
umapi_client_ryan_test_2_bytes_added_20130329.json
RFaulkner-WMF:umapi_client rfaulkner$ cat umapi_client_ryan_test_2_bytes_\
added_20130329.json
{
"cohort": "ryan_test_2",
"group": "default",
"cohort_last_generated": "2013-03-29 19:40:19",
"aggregator": "None",
"metric": "bytes_added",
"namespace": [
0
],
"project": "enwiki",
"time_of_response": "2013-03-29 19:40:26",
"datetime_start": "2010-10-25 08:00:00",
"datetime_end": "2011-01-01 00:00:00",
"header": [
"user_id",
"bytes_added_net",
"bytes_added_absolute",
"bytes_added_pos",
"bytes_added_neg",
"edit_count"
],
"type": "raw",
"data": {
"15972203": [
683,
1133,
908,
-225,
5
],
"13234584": [
0,
0,
0,
0,
0
],
"15972135": [
0,
0,
0,
0,
0
]
},
"interval_hours": 24,
"t": 24
}
To convert the output to csv:
RFaulkner-WMF:scripts rfaulkner$ ./json2csv umapi_client_ryan_test_2_bytes_added_20130331.json
Mar-31 23:57:20 DEBUG __main__ :: Attempting to read file...
Mar-31 23:57:20 DEBUG __main__ :: Writing to file...
RFaulkner-WMF:scripts rfaulkner$ cat ../../csv/umapi_client_ryan_test_2_bytes_added_20130331.json.csv
user_id,bytes_added_net,bytes_added_absolute,bytes_added_pos,bytes_added_neg,edit_count
13234584,0,0,0,0,0
15972203,683,1133,908,-225,5
15972135,0,0,0,0,0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for wmf_umapi_client-0.1.1-dev.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50dba42ce88396f2718d05376fe5c7a47f42101dc0ec4fc497c38ede6b50c0a7 |
|
MD5 | e84006cdff74d62a0cf9cff61908031c |
|
BLAKE2b-256 | 5978558429e0a4ad41923f98a29e3fd68852069c20e013c0896b8df34e307127 |
Close
Hashes for wmf_umapi_client-0.1.1-dev.macosx-10.7-intel.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 823cf17f9719a0948915a0c819c0e46664ae86af5cd7908a045bb5dc3e61ea47 |
|
MD5 | 168da9c8ac2806502c56c2e4179ba643 |
|
BLAKE2b-256 | 01a20e3929c31abf9ffe2e6aad363f5013704ce1d2983bb66e77747e4e32dfc7 |