-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
536 lines (512 loc) · 41.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
<!DOCTYPE html>
<html>
<head>
<title>Treasury IO: A daily data feed for the U.S. Treasury</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/png" href="web/favicon.png">
<!-- <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'> -->
<script src="web/js/thirdparty/jquery-1.10.1.min.js"></script>
<script src="web/js/thirdparty/dsv.min.js"></script>
<script src="web/js/thirdparty/jquery.formalize.min.js"></script>
<script src="web/js/thirdparty/bootstrap-scrollspy.js"></script>
<script src="web/js/thirdparty/jquery.scrollTo-min.js"></script>
<!-- CHART BUILDER -->
<link href="web/css/thirdparty/jquery.dynamic-highchart.css" rel='stylesheet' type='text/css'/>
<script src="web/js/thirdparty/miso.ds.deps.ie.0.4.1.js"></script>
<script src="web/js/thirdparty/highcharts.js"></script>
<script src="web/js/thirdparty/jquery.dynamic-highchart.js"></script>
<!-- end chart builder -->
<!-- SYNTAX HIGHLIGHTING -->
<link href="web/css/thirdparty/rainbow.github.css" rel="stylesheet" type="text/css">
<script src="web/js/thirdparty/rainbow-custom.min.js"></script>
<!-- end syntax highlighting -->
<!-- BACKBONE -->
<script src="web/js/thirdparty/backbone-min.js"></script>
<!-- end backbone -->
<!-- JQUERY UI DATEPICKER -->
<link rel="stylesheet" type="text/css" href="web/css/thirdparty/jquery-ui-1.10.3.custom.min.css">
<script src="web/js/thirdparty/jquery-ui-1.10.3.custom.min.js"></script>
<!-- end datepicker -->
<!-- STYLES -->
<link href="web/css/reset.css" rel='stylesheet' type='text/css'/>
<link href="web/css/styles.css" rel='stylesheet' type='text/css'/>
<!-- end styles -->
<!-- Facebook
https://developers.facebook.com/docs/opengraph/creating-object-types/
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Ftreasury.io%2F
-->
<meta property="og:url" content="http://treasury.io" />
<meta property="og:site_name" content="treasury.io" />
<meta property="og:description" content="What did your government spend today?" />
<meta property="og:title" content="treasury.io" />
<meta property="og:image" content="http://treasury.io/web/images/flag.png" />
<meta name="Description" content="Treasury.io is the first-ever electronically-searchable database of the Federal government's daily cash spending and borrowing. It updates daily and the data can be exported in a variety of formats.">
</head>
<body class="bluedots">
<a href="https://github.com/csvsoundsystem/federal-treasury-api" target="_blank"><img id="github-ribbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="See it on GitHub"></a>
<!--[if lt IE 9]>
<p class="chromeframe" style="margin: 40px auto 0; width: 600px; font-size: 24px; line-height: 1.4em;">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<div id="container-fluid">
<div id="hero">
<div id="beta-marker">Beta</div>
<h1 id="title" class="sticky">Treasury.io</h1>
<div id="subhead">A daily data feed for the U.S. Treasury</div>
</div>
<nav id="navmenu">
<ul id="menu">
<li class="nav-item" id="logo"><a class="btn" href="#hero"><img src="web/images/flag.png"></a></li>
<li class="nav-item" style="display: none;"><a class="btn" href="#query">Query</a></li>
<li class="nav-item active"><a class="btn" href="#about">About</a></li>
<li class="nav-item"><a class="btn" href="#documentation">The Docs</a></li>
<li class="nav-item"><a class="btn" href="#usage">Usage</a></li>
<li class="nav-item"><a class="btn" href="#libraries">Libraries</a></li>
<li class="nav-item"><a class="btn" href="#the-robot">The Robot</a></li>
<li class="nav-item"><a class="btn" href="#contact">Contact</a></li>
<li class="nav-item"><a class="btn" href="#testimonials">Testimonials</a></li>
<ul>
</nav>
</div>
<div id="container-solid">
<div id="section-wrapper">
<div id="query" class="section" style="display: none;">
<h2><a href="#query"><span class="bullet">$</span> <span class="internal-link">Query builder</span></a></h2>
<div id="builder">
<select id="builder-table-select" class="builder-item">
<option >What do you want to know?</option>
<option value="t1" >How much cash does the federal government have on hand? (Table 1)</option>
<option value="t2" >What programs are making deposits and withdrawals? (Table 2)</option>
<option value="t3a">How is the government selling and buying back its debt? (Table 3a)</option>
<!-- <option value="t3b">What types of debt is the government selling? (Table 3b)</option> -->
<option value="t3c">How close is the government to its credit limit (the debt ceiling)? (Table 3c)</option>
<option value="t4" >Where is the government getting its tax revenue from and where is it deposited? (Table 4)</option>
<!-- <option value="t5" >Where did the government invest cash it didn't immediately need? (Table 5)</option> -->
<option value="t6" >How much money did the government refund to businesses and individuals? (Table 6)</option>
</select>
<div id="qb-table-builders" class="builder-item">
<!-- t1 -->
<div class="qb-table-builder" id="t1-builder">
<div class="qb-table-name">t1: Operating Cash Balance</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much cash does the federal government have on hand <span class='sentence-option t1-date-select'></span> <span class='sentence-option t1-date-value'></span> ?</p>
</div>
</div>
<!-- t2 -->
<div class="qb-table-builder" id="t2-builder">
<div class="qb-table-name">t2: Deposits & Withdrawals</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much cash in <span class='sentence-option t2-transaction_type'></span> did <span class='sentence-option t2-item'></span> make <span class='sentence-option t2-date-select'></span> <span class='sentence-option t2-date-value'></span> ?</p>
</div>
</div>
<!-- t3a -->
<div class="qb-table-builder" id="t3a-builder">
<div class="qb-table-name">t3a: Public Debt Transactions</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much debt did the government <span class='sentence-option t3a-transaction_type'></span> <span class='sentence-option t3a-date-select'></span> <span class='sentence-option t3a-date-value'></span> ?</p>
</div>
</div>
<!-- t3b -->
<!-- <div class="qb-table-builder" id="t3a-builder">
<div class="qb-table-name">t3b: Public Debt Transactions</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much debt did the government <span class='sentence-option t3a-transaction_type'></span> <span class='sentence-option t3a-date-select'></span> <span class='sentence-option t3a-date-value'></span> ?</p>
</div>
</div> -->
<!-- t3c -->
<div class="qb-table-builder" id="t3c-builder">
<div class="qb-table-name">t3c: Debt Subject to Limit</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much debt that's subject to the debt ceiling does the government have <span class='sentence-option t3c-date-select'></span> <span class='sentence-option t3c-date-value'></span> ?</p>
</div>
</div>
<!-- t4 -->
<div class="qb-table-builder" id="t4-builder">
<div class="qb-table-name">t4: Federal Tax Deposits</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much in <span class='sentence-option t4-classification'></span> revenue did the governent collect <span class='sentence-option t4-date-select'></span> <span class='sentence-option t4-date-value'></span> ?</p>
</div>
</div>
<!-- t5 -->
<!-- <div class="qb-table-builder" id="t5-builder">
<div class="qb-table-name">t4: Federal Tax Deposits</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much in <span class='sentence-option t5-classification'></span> revenue did the governent collect <span class='sentence-option t5-date-select'></span> <span class='sentence-option t5-date-value'></span> ?</p>
</div>
</div> -->
<!-- t6 -->
<div class="qb-table-builder" id="t6-builder">
<div class="qb-table-name">t4: Income Tax Refunds Issued</div>
<div class="qb-table-available-columns"></div>
<div class="qb-table-sentence">
<p>How much tax revenue did the government return to <span class='sentence-option t6-refund_type'></span> <span class='sentence-option t6-date-select'></span> <span class='sentence-option t6-date-value'></span> ?</p>
</div>
</div>
</div>
<div id="query-string-wrapper" class="builder-item">
<fieldset>
<!-- <span>SQL Query, view as:* </span>
<span id="query-encoding-options">
<input type="radio" name="encoding" value="false" checked> Plain-text
<input type="radio" name="encoding" value="true"> URL-Encoded
</span>
--> <div id="query-string">
<textarea id="sql" class="placeholder-textfield" placeholder="Select from the query builder options above or type your own query..."></textarea>
</div>
</fieldset>
</div>
<div id="query-viewers-wrapper" class="builder-item" style="display: block;">
<div id="query-viewers-buttons">
<!-- BUTTON -->
<button type="button" class="buttn disabled piwik_ignore query-preview-button qp-btn" id="download-browser">Query preview</button>
<div class="query-preview-button-wrapper query-preview-button">
<div id="toggle-chart-options" class="disabled toggle-chart-opts">Show options</div>
<div id="chart-builder-options" style="display: none;">
<div class="chart-builder-option-box">
<p class="chart-builder-close-btn toggle-chart-opts">Hide options</p>
<label for="cb-series-col" >Series name: <input id="cb-series-col" type="text" class="placeholder-textfield chart-builder-input-text" placeholder="i.e. item"></label>
<label for="cb-x-col" >X-value <input id="cb-x-col" type="text" class="placeholder-textfield chart-builder-input-text" placeholder="i.e. date"></label>
<label for="cb-y-col" >Y-value <input id="cb-y-col" type="text" class="placeholder-textfield chart-builder-input-text" placeholder="i.e. close_today"></label>
<span class="clearfix"></span>
</div>
<div class="chart-builder-option-box">
<p class="chart-builder-option-box-title">The x-axis holds:</p>
<label for="chart-type-datetime"><input id="chart-type-datetime" type="radio" name="chart-type" value="datetime" checked> Dates (line graph)</label>
<label for="chart-type-categorical"><input id="chart-type-categorical" type="radio" name="chart-type" value="categorical"> Categories (bar graph)</label>
</div>
<div class="chart-builder-option-box" style="margin-top: 10px;">
<label for="cb-chart-title" >Title <input id="cb-chart-title" type="text" class="placeholder-textfield chart-builder-input-text" placeholder="i.e. Daily cash"></label>
<label for="cb-y-axis-label" >Y-axis <input id="cb-y-axis-label" type="text" class="placeholder-textfield chart-builder-input-text" placeholder="i.e. $ (millions)"></label>
</div>
</div>
<button id="view-chart" type="button" class="buttn disabled qp-btn">Draw chart*</button>
</div>
</div>
<div id="query-preview-wrapper" class="query-viewer">
<div class="query-preview-button-wrapper">
<!-- CANVAS -->
<div id="results-container" style="display: none;">
<div class="show-hide-table show-hide-button" data-state="hide" data-target="#results-table-container" data-text="preview table">Hide preview table</div>
<div id="results-table-container">
<div id="results-table-holder">
<table id="results" cellspacing="5"></table>
</div>
</div>
</div>
</div>
</div>
<div id="query-chart-wrapper" class="query-viewer">
<!-- CANVAS -->
<div id="chart-container" style="display: none;">
<div class="show-hide-chart show-hide-button" data-state="hide" data-target="#chart-canvas" data-text="chart">Hide chart</div>
<div id="chart-canvas"></div>
<div id="hover-templ"></div>
</div>
</div>
</div>
<div id="builder-btns" class="btn-group builder-item">
<div id="builder-btns-overlay"></div>
<!-- <span class="btn disabled piwik_ignore" id="download-browser">Preview query**</span> -->
<a class="btn disabled piwik_ignore" id="download-json" target="_blank" href="#">View JSON</a>
<span class="btn disabled piwik_ignore download-as-csv-btn" id="download-csv" data-query-link="">Download CSV†</span>
<div class="clearfix"></div>
<!-- <div id="chart-builder-options" class="disabled">
<div class="chart-builder-title">Chart options</div>
<div class="chart-builder-option-box">
<p class="chart-builder-option-box-title">Which fields hold the...</p>
<input id="cb-series-col" type="text" class="placeholder-textfield chart-builder-input-text" title="Series names ">
<input id="cb-x-col" type="text" class="placeholder-textfield chart-builder-input-text" title="X-axis data ">
<input id="cb-y-col" type="text" class="placeholder-textfield chart-builder-input-text" title="Y-axis data ">
<span class="clearfix"></span>
</div>
<div class="chart-builder-option-box">
<p class="chart-builder-option-box-title">The chart's x-axis holds...</p>
<input type="radio" name="chart-type" value="datetime" checked> <span class="radio-btn-text"><span class="radio-btn-fixewidth">Dates</span> (line graph)</span><br/>
<input type="radio" name="chart-type" value="categorical"> <span class="radio-btn-text"><span class="radio-btn-fixed-wid">Categories</span> (bar graph)</span>
</div>
<div class="chart-builder-submit">
<div class="btn disabled">View chart</div>
</div>
</div> -->
</div>
</div>
<!-- <div id="query-asterisk-field">
<p>Note: If using "is before" or "is after" for "Date" field, make sure your dates is in YYYY-MM-DD format (<a href="https://en.wikipedia.org/wiki/ISO_8601" target="_blank">ISO-8601</a>/<a href="https://tools.ietf.org/html/rfc3339">RFC3339</a>).</p>
<p>* Use these radio buttons as a shortcut when accessing the API programatically or for testing. All queries are URL-encoded when you select "View JSON" or "Download CSV."</p>
<p>** This will put <code class="inline-code">LIMIT 10</code> on the end of your query, so best not to add your own <code class="inline-code">LIMIT</code>.</p>
</div>
-->
</div>
<!-- <div id="chart-container" class="section" style="display: none;">
<div class="show-hide-chart" data-state="hide">Hide chart</div>
<div id="chart-canvas"></div>
<div id="hover-templ"></div>
</div>
--><!-- <div id="results-container" class="section" style="display: none;">
<div class="show-hide-table" data-state="hide">Hide preview table</div>
<div id="results-table-container">
<div id="results-table-holder">
<table id="results" cellspacing="5"></table>
</div>
</div>
</div> -->
<div class="section" id="about">
<div class="note" style="display: none;">*Note: All dollar values are in millions e.g. 1000 equals $1 billion.</div>
<div class="note" style="display: none;">†Different browsers have limits to how much data they can crunch into a csv. If you're querying a lot of data, selecting "View JSON" or using one of <a href="#libraries">our libraries</a> might be better.</div>
<h2><a href="#about"><span class="bullet">$</span> <span class="internal-link">About</span></a></h2>
<!-- Copied from http://www.bdatafest.computationalreporting.com/projects/fms-symphony -->
<h3>⚠️ Under renovation ⚠️</h3>
<p>Hey there! We're in the process of porting this website over to Engima's instance of this database and revamping our query builder, if possible. In the meantime, you can access the data directly via their query interface here: <a href="https://public.enigma.com/browse/1ee6ce88-f5f8-4a2c-8190-445739beea31" target="_blank" rel="noopener">https://public.enigma.com/browse/1ee6ce88-f5f8-4a2c-8190-445739beea31</a></p>
<h3>The data</h3>
<p>Every day at 4pm, the United States Treasury <a href="http://www.fms.treas.gov/dts/index.html" target="_blank">publishes data tables</a> summarizing the cash spending, deposits, and borrowing of the Federal government. These files catalog all the money taken in that day from taxes, the programs, and how much debt the government took out to make it happen. It comes from a section of the U.S. Treasury called the <a href="https://www.fiscal.treasury.gov/" target="_blank">Bureau of the Fiscal Service</a></p>
<p>At a time of record fiscal deficits and continual debates over spending, taxation, and the debt, this daily accounting of our government's main checking account is an essential data point that the public should have ready access to.</p>
<h3>Original data format</h3>
<p>The Treasury told us in response to a Freedom of Information Act Request that it does not store this data in any format other than inconsistently structured text files that don't lend themselves to programmatic analysis.</p>
<h3>New data format</h3>
<p>We have created the first-ever electronically-searchable database of the Federal government's daily cash spending and borrowing. It updates daily and the data can be exported in various formats and loaded into a variety of systems. It is also <a href="https://github.com/csvsoundsystem/federal-treasury-api" target="_blank">100% open</a> <a href="https://github.com/csvsoundsystem/treasury.io" target="_blank">source</a> and free to use. We started the project at the <a href="http://www.bdatafest.computationalreporting.com/" target="_blank">Columbia and Stanford Bi-Coastal Datafest Hackathon</a> and continued the it with support from a <a href="http://dansinker.com/post/49856260511/opennews-code-sprints-do-some-spring-cleaning-on-data" target="_blank">Knight-Mozilla OpenNews Code Sprint Grant</a>.</p>
<p>We want to make it easy for people to search, explore, and visualize how the government spends their tax dollars.</p>
</div>
<div class="section" id="documentation">
<h2><a href="#documentation"><span class="bullet">$</span> <span class="internal-link">Documentation</span></a></h2>
<p>We created a <a href="https://github.com/csvsoundsystem/federal-treasury-api/wiki/Treasury.io-Data-Dictionary" target="_blank">fully-documented data dictionary</a> that details the structure of these tables as well as descriptions of many programs and classifications. If you're the kind to prefer your data dictionaries in hard-copies, <a href="https://github.com/csvsoundsystem/federal-treasury-api/blob/master/documentation/treasuryio_data_dictionary.pdf?raw=true" target="_blank">here's the full documentation as a PDF</a>. We also have an <a href="https://github.com/csvsoundsystem/federal-treasury-api/wiki/Frequently-Asked-Questions-(FAQ)" target="_blank">FAQ or any other questions you might have</a>.</p>
<p>The data is complicated, however, and we recommend that you reach out to the <a href="http://www.fms.treas.gov/dts/contacts.html" target="_blank">Bureau of the Fiscal Service at the U.S. Treasury</a> directly via that page or at <a href="mailto:[email protected]">[email protected]</a>. Note that the units of the data are in millions e.g. 1000 equals $1 billion.
<p><strong>Always query responsibly.</strong></p>
<p>This API provides eight tables. You can access them with the short names in parentheses.
Click "preview" to download the first ten rows of the table as CSV, and click "full" to
download the full table as CSV.</p>
<ul class="tables">
<li>I. Operating Cash Balance <code class="inline-code">t1</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t1%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_i.csv" target="_blank">full</a>)</li>
<li>II. Deposits and Withdrawals <code class="inline-code">t2</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t2%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_ii.csv" target="_blank">full</a>)</li>
<li>IIIa. Public Debt Transactions <code class="inline-code">t3a</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t3a%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_iii_a.csv" target="_blank">full</a>)</li>
<li>IIIb. Adjustment of Public Dept Transactions to Cash Basis <code class="inline-code">t3b</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t3b%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_iii_b.csv" target="_blank">full</a>)</li>
<li>IIIc. Debt Subject to Limit <code class="inline-code">t3c</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t3c%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_iii_c.csv" target="_blank">full</a>)</li>
<li>IV. Federal Tax Deposits <code class="inline-code">t4</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t4%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_iv.csv" target="_blank">full</a>)</li>
<li>V. Short-term Cash Investments <code class="inline-code">t5</code> (<a class="piwik_download download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t5%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_v.csv" target="_blank">full</a>)</li>
<li>VI. Income Tax Refunds Issued <code class="inline-code">t6</code> (<a class="download-as-csv-btn" href="#" data-query-link="http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20*%20FROM%20t6%20LIMIT%2010;" target="_blank">preview</a>, <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/lifetime_csv/table_vi.csv" target="_blank">full</a>)</li>
</ul>
<p>You can also download the <a class="piwik_download" href="http://api.treasury.io/cc7znvq/47d80ae900e04f2/http/treasury_data.db" target="_blank">full SQLite3 database</a>, with all of the tables. It's about 50mb in total.</p>
<p>To see the table schema and column types, you can use this query:</p>
<pre><a target="_blank" href='http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT%20"name","sql"%20FROM%20sqlite_master'><code>http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT "name","sql" FROM sqlite_master</code></a></pre>
</div>
<div class="section" id="usage">
<h2><a href="#usage"><span class="bullet">$</span> <span class="internal-link">Usage</span></a></h2>
<p>The eight tables are stored in one SQLite database and the API. To get the data back as JSON, query it from a URL like this:</p>
<pre><code>http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=YOUR_QUERY</code></pre>
<p>where <code class="inline-code">YOUR_QUERY</code> is a URL-encoded SQL command. This query will show the ten most recent withdrawals.</p>
<pre><a target="_blank" href="http:////api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT * FROM t2 WHERE transaction_type = 'withdrawal' ORDER BY date DESC LIMIT 10"><code>http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=SELECT * FROM t2 WHERE transaction_type = 'withdrawal' ORDER BY date DESC LIMIT 10</code></a></pre>
<p>Note: We're submitting a plain-text query string because the browser is doing the <a href="http://www.w3schools.com/tags/ref_urlencode.asp" target="_blank">URL-encoding</a> here. The <a href="#libraries" class="smooth-scroll">libraries</a> we've written either do that for you or expect it a URL-encoded query, as shown in the examples.</p>
<h3>Host it yourself</h3>
<p>If you want to install the database locally, follow the instructions on <a href="http://github.com/csvsoundsystem/federal-treasury-api" target="_blank">the GitHub page</a></p>
<h3>Citation</h3>
<p>You can cite this data as "U.S. Treasury data via Treasury.io." Or, with links:</p>
<div class="code-container">
<pre><code data-language="html"><a href="http://www.fms.treas.gov/index.html" target="_blank">U.S. Treasury data</a> via <a href="http://treasury.io/" target="_blank">Treasury.io</a>.</code></pre>
</div>
</div>
<div class="section" id="libraries">
<h2><a href="#libraries"><span class="bullet">$</span> <span class="internal-link">Libraries</span></a></h2>
<ul>
<li>
<h3>Python</h3>
<p>Install with pip.</p>
<div class="code-container">
<pre><code data-language="shell">pip install treasuryio</code></pre>
</div>
<p>Alternatively, copy the <code class="inline-code">query</code> function from <a href="https://github.com/csvsoundsystem/pytreasuryio/blob/master/treasuryio/query.py" target="_blank">here</a>.</p>
<p>Send SQL, and get a pandas DataFrame.</p>
<div class="code-container">
<pre><code data-language="python">import treasuryio
treasuryio.query('SELECT * FROM sqlite_master')</code></pre>
</div>
<p>This package lives <a href="https://github.com/csvsoundsystem/pytreasuryio" target="_blank">here</a>.</p>
</li>
<li>
<h3>R</h3>
<div class="code-container">
<pre><code data-language="r">library('devtools')
install_github('Rtreasuryio', 'csvsoundsystem')
library('Rtreasuryio')</code></pre>
</div>
<p>Alternatively, copy the <code class="inline-code">treasuryio</code> function from <a href="https://github.com/csvsoundsystem/Rtreasuryio/blob/master/R/treasuryio.R" target="_blank">here</a>.</p>
<p>Send SQL, and get a data.frame.</p>
<div class="code-container">
<pre><code data-language="r">treasuryio('SELECT * FROM sqlite_master')</code></pre>
</div>
<p>This package lives <a href="https://github.com/csvsoundsystem/Rtreasuryio" target="_blank">here</a>.</p>
</li>
<li>
<h3>JavaScript</h3>
<p>There isn't a separate library for JavaScript (if you want one, <a href="http://www.twitter.com/treasuryio" target="_blank">let us know</a>), you can just call it through jQuery's <code class="inline-code">$.ajax()</code>.</p>
<p>Include jQuery :</p>
<div class="code-container">
<pre><code data-language="html"><script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script></code></pre>
</div>
<p>Create a function <code class="inline-code">treasuryIo()</code> that holds the API endpoint and accepts a query string. Pass it a query and get the JSON response.</p>
<div class="code-container">
<pre><code data-language="javascript">function treasuryIo(query){
return $.ajax({
url: 'http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q='+query
})
}
treasuryIo('SELECT * FROM t1 LIMIT 10')
.done(function(response){
console.log(response);
}).fail(function(err){
console.log(err)
});</code></pre>
</div>
<p>If you want a CSV response instead of JSON, you can include the <code class="inline-code"><a href="https://github.com/mbostock/dsv" target="_blank">dsv.js</a></code> library, which is the CSV parser and formatter from <code class="inline-code"><a href="http://d3js.org/" target="_blank">d3.js</a></code>.</p>
<div class="code-container">
<pre><code data-language="html"><script src="js/thirdparty/dsv.min.js"></script></code></pre>
</div>
<p>Then, when you call <code class="inline-code">treasuryIo()</code>, convert into a CSV like so :</p>
<div class="code-container">
<pre><code data-language="javascript">treasuryIo('SELECT * FROM t1 LIMIT 10')
.done(function(response){
var csv_response = dsv.csv.format(response);
console.log(csv_response);
}).fail(function(err){
console.log(err)
});</code></pre>
</div>
</li>
<li>
<h3>Node.js</h3>
<p>Install with npm</p>
<div class="code-container">
<pre><code data-language="shell">npm install treasuryio</code></pre>
</div>
<p>Send SQL, and get a csv or json representation of the data, depending on what string you pass as the second argument.</p>
<div class="code-container">
<pre><code data-language="javascript">var treasuryio = require('treasuryio')
treasuryio('SELECT * FROM t1 LIMIT 10', 'csv', function(err, response){
if (err) console.log(err)
console.log(response);
});</code></pre>
<p>This module lives <a href="https://github.com/csvsoundsystem/treasuryiojs" target="_blank">here</a>.</p>
</div>
</li>
<li>
<h3>Ruby</h3>
<p>Install the gem</p>
<div class="code-container">
<pre><code data-language="shell">gem install treasuryio</code></pre>
</div>
<p>Send SQL, and get a list of hashes.</p>
<div class="code-container">
<pre><code data-language="javascript">require 'treasuryio'
puts (treasuryio 'SELECT * FROM t1 LIMIT 10')</code></pre>
<p>This module lives <a href="https://github.com/csv/treasuryiorb" target="_blank">here</a>.</p>
</div>
</li>
<li>
<h3>Google Docs</h3>
<div class="code-container">
<p>Paste this function into the script editor. (Or wait a bit; we've submitted it to the script gallery.)</p>
<pre><code data-language="javascript">function treasuryio(sql) {
var response = UrlFetchApp.fetch("http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=" + encodeURIComponent(sql));
var data = JSON.parse(response.getContentText());
if (data.length == 0){
return [];
} else {
// Unfortunately, this is ordered arbitrarily and is not guaranteed to be consistant.
var keys = Object.keys(data[0]);
return [keys].concat(data.map(function(row){return keys.map(function(key){return row[key]})}))
}
}</code></pre>
</div>
<p>Then use it like so</p>
<div class="code-container">
<pre><code data-language="javascript">=treasuryio("SELECT * FROM t1 limit 10")</code></pre>
</div>
<p><a href="https://docs.google.com/spreadsheet/ccc?key=0Avjq7klTEotEdFpIeUR1alE0ai1WdGc0azU5MGNLVXc&usp=sharing" target="_blank">Here's</a> an example.</p>
</li>
</ul>
</div>
<div class="section" id="the-robot">
<h2><a href="#the-robot"><span class="bullet">$</span> <span class="internal-link">The Robot</span></a></h2>
<p>The twitter account <a href="http://www.twitter.com/treasuryio" target="_blank">@TreasuryIO</a> is a python Twitter bot we made that tweets out daily analyses of the data.</p>
<p>It runs SQL queries on the database and then turns the results into tweetable messages. You can make your own bot by using <a href="https://github.com/csvsoundsystem/pytreasuryio" target="_blank">our PyTreasuryIO package on GitHub</a>, which includes instructions on how to make your own bot based on a SQL query of your choosing. The example bot calculates the total outstanding federal debt.</p>
<p>Some sample tweets the bot makes:</p>
<ul>
<li>The distance to the debt ceiling.</li>
<li>Notifications of income from taxes.</li>
<li>How much the money spent on different programs like:</li>
<ul>
<li>Food Stamps</li>
<li>Veterans Affairs Benefits Programs</li>
<li>Medicare</li>
</ul>
</ul>
</div>
<div class="section" id="contact">
<h2><a href="#contact"><span class="bullet">$</span> <span class="internal-link">Contact</span></a></h2>
<p>For help with accessing the API or running it yourself, contact us via any of these means.</p>
<ul>
<li>Subscribe and post to the <a href="http://groups.google.com/forum/#!forum/federal-treasury-api" target="_blank">Google Group</a></li>
<li>Submit an issue <a href="http://github.com/csvsoundsystem/federal-treasury-api/issues/" target="_blank">on GitHub</a></li>
<li>Tweet at us, we're <a href="http://twitter.com/treasuryio" target="_blank">@Treasuryio</a>.</li>
</ul>
<p>You should also <a href="mailto:[email protected]">contact us</a> if you've done something cool with the API because we'd love to hear about it.</p>
</div>
<div class="section" id="testimonials">
<h2><a href="#testimonials"><span class="bullet">$</span> <span class="internal-link">Testimonials</span></a></h2>
<blockquote>
<p>.<a href="https://twitter.com/TreasuryIO"><s>@</s><b>TreasuryIO</b></a> is just awesome. Simple to use, clear docs, data dictionary, client libraries and code on <a href="https://twitter.com/github"><s>@</s><b>GitHub</b></a>. <a href="https://twitter.com/search?q=%23opendata&src=hash"><s>#</s><b>opendata</b></a> done right.</p>
<div style="text-align: right;">—<a href="https://twitter.com/mheadd/status/359381930489294848">Mark Headd</a></div>
</blockquote>
<blockquote>
<p>Well [this] is literally bad ass as fuck. I didn't even know that data was publicly available!</p>
<p style="text-align: right;">—<a href="http://en.reddit.com/r/technology/comments/1unj34/treasuryio_is_the_firstever/cejwneu">TanyIshsar</a></p>
</blockquote>
</div>
</div>
</div>
<footer>
<p>Made lovingly by <a href="http://csvsoundsystem.com" target="_blank" class="highlight-link">csv soundsystem</a> with help from <a href="http://www.mozillaopennews.org/" target="_blank" class="highlight-link">knight-mozilla OpenNews</a>. <a href="http://dansinker.com/post/49856260511/opennews-code-sprints-do-some-spring-cleaning-on-data" target="_blank">Huh?</a></p>
<p>By <a href="http://www.twitter.com/brianabelson" target="_blank">Brian Abelson</a>, <a href="http://www.twitter.com/jbialer" target="_blank">Jake Bialer</a>, <a href="http://www.twitter.com/bjdewilde" target="_blank">Burton DeWilde</a>, <a href="http://www.twitter.com/mhkeller" target="_blank">Michael Keller</a>, <a href="http://www.twitter.com/thomaslevine" target="_blank">Thomas Levine</a> & <a href="http://www.twitter.com/cezary" target="_blank">Cezary Podkul</a>. With an assist from <a href="http://www.twitter.com/ag_dubs" target="_blank">Ashley Williams</a>.</p>
<p></p>
</footer>
<div id="qb-help-text-hover"></div>
<script type="text/template" id="sentence-col-templ">
<ul class="sentence-group">
</ul>
</script>
<script type="text/template" id="Checkbox-view-templ">
<label for="<%= makeKeyFromName(table_name, value) %>"><input type="checkbox" id="<%= makeKeyFromName(table_name, value) %>" checked/> <%= value %> <span style="display:<% ((description != '') ? print('inline-block') : print('none')) %>;" class="help-text-flag" data-help-text="<%= description %>">?</span></label>
</script>
<script type="text/template" id="OutputNumber-view-templ">
<label class="qc-textfield-option" for="<%= makeKeyFromName(column_name, table_name) %>-<%= comparinatorToText(comparinator) %>">
<span class="textbox-label-text"><input type="text" value="<%= value %>" placeholder="<%= comparinatorToText(comparinator) %>" id="<%= makeKeyFromName(column_name, table_name) %>-<%= comparinatorToText(comparinator) %>"/>
</label>
</script>
<script type="text/template" id="TextfieldSelector-view-templ">
<label for="<%= makeKeyFromName(table_name, column_name) %>-<%= comparinatorToText(comparinator) %>-select">
<input type="checkbox" value="<%= comparinator %>" id="<%= makeKeyFromName(table_name, column_name) %>-<%= comparinatorToText(comparinator) %>-select" checked /> <%= comparinatorToText(comparinator) %></label>
</script>
<script src="web/js/main.js"></script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.treasury.io"]);
_paq.push(["setDomains", ["*.treasury.io"]]);
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.thomaslevine.com/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "21"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
</body>
</html>