The XBRL API is a unified interface to stored XBRL data – facts, taxonomies and assertions – that enables developers with limited XBRL knowledge to learn a single interface and access any data repository structured to the XBRL Specification. Dig into the draft documentation for the XBRL API beta to learn more and consider joining the Beta User Group to quickly build apps using this interface and return data like the example below.

Data below is a sample preview - login to see the latest (processing may take a minute).

Report for company (CIK) plus filing detail & select reported facts Accepted (ET)
10-K for Amerityre Corp (0000945828)Fri, 9/14 9:32 AM
Inline document on EDGAR
Generated by iC(tm) - CompSci Interactive Converter - http://www.compsciresources.com
 Cash And Cash Equivalents At Carrying Value as of July 1, 2018
$
213,854
 Retained Earnings Accumulated Deficit as of July 1, 2018
$
-61,438,919
 Cash And Cash Equivalents At Carrying Value as of July 1, 2018
$
213,854
 Liabilities And Stockholders Equity as of July 1, 2018
$
1,787,446
10-K for INTUIT INC (0000896878)Fri, 8/31 5:05 PM
Inline document on EDGAR
XBRL Document Created with Wdesk from Workiva
 Liabilities And Stockholders Equity as of August 1, 2018
$
5,178,000,000
 Cash And Cash Equivalents At Carrying Value as of August 1, 2018
$
1,464,000,000
 Retained Earnings Accumulated Deficit as of August 1, 2018
$
8,101,000,000
 Cash And Cash Equivalents At Carrying Value as of August 1, 2018
$
1,464,000,000
<?php

// NOTES: Highlighted rows correspond to sample
//        query parameters ( $args ) for the two most recent
//        inline 10-Ks and fact endpoints ( $recent_filings ).
// OAuth logic is omitted from this example. 

// Whitespace/breaks in $concepts variable is for illustrative purposes only.
 
    $limit = 2;
    if (isset($args['limit']) && $args['limit'] !='' ) {
        $limit = $args['limit'];
    }
    $api = new XBRLUSCall ();

    $concepts = '
       CashAndCashEquivalentsAtCarryingValue,
       LiabilitiesAndStockholdersEquity,
       RetainedEarningsAccumulatedDeficit';

    $args = array('fields' => "
     report.accepted-timestamp.sort(DESC),
     concept.local-name.sort(ASC),
     entity.cik,
     fact.value,
     fact.decimals, 
     period.instant,
     report.creation-software,
     report.document-type,
     report.entity-name,
     report.entry-type, 
     report.sec-url,
     report.limit(" . $limit . "),",
           'concept.local-name' => $concepts,
           'fact.has-dimensions' => 'false',
           'period.fiscal-year' => '2018',
           'report.document-type' => '10-K',
           'report.entry-type' => 'inline',
           'report.is-most-current' => 'true'
    );

    $recent_filings = $api->call ( 
    '/api/v1/report/fact/search', 'GET', $args );

    $recent_filings = json_decode ( $recent_filings, true );
            $output = "

<!-- return api results as html -->

			<table class=api-sample>
            <thead><tr><th class=api-row-head>
            Report for company (CIK) plus filing detail & select reported facts</th><th class=api-row-head style=text-align:right;>
            Accepted (ET)</th></tr></thead>";

    if (! isset ( $recent_filings ['error'] ) && count ( $recent_filings['data'] ) > 0) {
        $num = 0;
        foreach ( 
        $recent_filings['data'] as $recent_row ) { 
        $date = strtotime($recent_row ['report.accepted-timestamp']);
            $output .= "

<!-- row 1 - document type, entity, cik, date accepted -->

			<tr class=api-background>";
            $output .= "<td class=api-row-1 style='font-weight:600;'>" .
              $recent_row ['report.document-type'] . " for " .
              $recent_row ['report.entity-name'] . " (" .
              $recent_row ['entity.cik'] . ")</td>";
		            $output .= "<td class=api-row-1 nowrap style=text-align:right>" .
              date('D, n/j g:i A', $date) . "</td>";
            $output .= "</tr>

<!-- row 2 - entry (instance or inline), link to EDGAR, report software used -->

			<tr class=api-background>";
			$output .= "<td class=api-row-2 colspan=2><a href=" .
              $recent_row ['report.sec-url'] . " target=blank>" .
              ucfirst ($recent_row ['report.entry-type']) . " document on EDGAR <i class='fa fa-external-link' aria-hidden='true'></i></a><div style='text-align:right;float:right'>" .
              $recent_row ['report.creation-software'] . "</div></td>";
			$output .= "</tr><tr class=api-background><td colspan=2 class=api-row-data><table class=api-row-detail>

<!-- row 3+ - each queried element, instance date, amount-->

			<tr class=api-background>";
        foreach ( 
        $recent_row['fact']['data'] as $fact ) {
        $period = strtotime($fact['period.instant']);
        $element = preg_replace('/(?<!\ )[A-Z]/', ' $0', $fact['concept.local-name']);
        $value = $fact['fact.value'];
        $decimals = abs($fact['fact.decimals']);
        $amount = str_pad($value , $decimals , '0' , STR_PAD_RIGHT);
            $output .= "<tr><td class=api-cell-element><pre>" .
              $element . " as of " .
              date('F j, Y', $period) . "</pre></td><td class=api-cell-element><pre>$</pre></td><td class=api-cell-value><pre style=text-align:right>" . 
              number_format($amount) . "</pre></td></tr>" ; }
            $output .= "</tr></table></td></tr>";
        }
    } else {
        $output .= "<tr><td colspan=2>You might need to log in again to refresh your view of the data in this report <em>OR</em> no filings have been submitted matching these query parameters.</td></tr>";
    }
		$output .= "</table>

<!-- end api results as html -->

";";

    return $output;
} ?>

Comment