Department of Labor Logo United States Department of Labor
Dot gov

The .gov means it's official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you're on a federal government site.


The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Accessing the Public Data API with PHP Code


Multiple Series and Multiple Years

Use this code to retrieve data for more than one timeseries and more than one year.

Sample PHP Code:

$url = '';
$method = 'POST';
$query = array(
'seriesid'  => array('LEU0254555900', 'APU0000701111'),
'startyear' => '2002',
'endyear'   => '2012'
$pd = json_encode($query);
$contentType = 'Content-Type: application/json';
$contentLength = 'Content-Length: ' . strlen($pd);
$result = file_get_contents(
$url, null, stream_context_create(
'http' => array(
'method' => $method,
'header' => $contentType . "\r\n" . $contentLength . "\r\n",
'content' => $pd



Last Modified Date: October 16, 2014