Skip to Content

An official website of the United States government 	  	Here is how you know 

  United States Department of Labor

**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.		

U.S. Bureau of Labor Statistics

Follow UsRelease CalendarBlog

                - Search buttonSearch:  Follow Us | Release Calendar | Blog 
                - Home   - About BLS
- History
- Our Leadership
- Budget and Performance
- Questions and Answers
- A-Z Index
- Glossary
- Careers at BLS 
- BLS Speakers Available
- Errata
- Contact BLS
- Overview of BLS Statistics
- Guide to Programs & Services
- Demographics
- Industries
- Business Costs
- Occupations
- Geography
- Resources For
- Business Leaders
- Consumers
- Developers
- Economists
- Investors
- Jobseekers
- Media
- Public Policymakers
- Researcher
- Students & Teachers
- Survey Respondents
 
                - Subjects   - Inflation & Prices
- Consumer Price Index
- Producer Price Indexes
- Import/Export Price Indexes
- Contract Escalation
- Price Index Research
- Pay & Benefits
- Employment Cost Index
- Employer Costs for Employee Compensation
- Wage Data by Occupation
- Earnings by Demographics
- Earnings by Industry
- County Wages
- Benefits
- Modeled Wage Estimates
- Compensation Research
- Strikes & Lockouts 
- Wage Records from Unemployment Insurance
- Occupational Requirements
- Unemployment
- National Unemployment Rate 
- State & Local Unemployment Rates 
- Unemployment Research
- Employment
- National Employment 
- State & Local Employment 
- County Employment 
- Worker Characteristics 
- American Indian Report
- Employment Projections 
- Job Openings & Labor Turnover Survey 
- Business Response Survey
- Employment by Occupation 
- Work Experience Over Time 
- Business Employment Dynamics 
- Foreign Direct Investment 
- Employment Research
- Workplace Injuries
- Productivity
- Labor and Total Factor Productivity
- Productivity Research
- Spending & Time Use
- Consumer Expenditures 
- How Americans Spend Time
- International
- International Technical Cooperation
- Import/Export Price Indexes
- Geographic Information
- Northeast (Boston-New York)
- Mid-Atlantic (Philadelphia)
- Southeast (Atlanta)
- Midwest (Chicago)
- Southwest (Dallas)
- Mountain-Plains (Kansas City)
- West (San Francisco)
 
                - Data Tools   - Data Retrieval Tools
- BLS Popular Series
- Series Report
- Top Picks, One Screen, Multi-Screen, and Maps
- Data Finder
- Public Data API
- Charts and Applications
- Charts for Economic News Releases
- CPI Inflation Calculator
- Injury and Illness Calculator
- Pay Measure Comparison
- Demographic Data Sources
- COVID-19 Economic Trends
- Industry Productivity Viewer
- Employment and Wages Data Viewer
- Industry Finder from the Quarterly Census of Employment and Wages
- Customized Tables
- U.S. Economy at a Glance
- Regions, States & Areas at a Glance
- Industry at a Glance
- Text Files
- News Release Tables
- More Sources of Data
- Restricted Data Access
- Discontinued Databases 
- Questions & Answers
- Special Notices 
 
                - Publications   - Latest Publications
- The Economics Daily
- Monthly Labor Review
- Beyond the Numbers
- Spotlight on Statistics
- Reports
- Commissioner's Corner
- Videos
- Career Outlook
- Occupational Outlook Handbook
- Geographic Profile
- Handbook of Methods
- Research Papers
- Copyright Information
- Contact & Help 
- Weekly Update
 
                - Economic Releases   - Latest Releases
- Major Economic Indicators
- Schedules for news Releases
- By Month
- By News Release
- Current Year
- Prior Years
- Archived News Releases
- Employment & Unemployment
- Monthly
- Quarterly, annual, and other
-  Inflation & Prices
- Pay & Benefits & Workplace Injuries
- Productivity & Technology
- Employment Projections
- Regional News Releases
 
                - Classroom   - K-12 Student & Teacher Resources
- Games & Quizzes
- Student's Desk
- Teacher's Desk
- Questions & Answers
 
                - Beta   - Redesigned News Releases
 

| - BROWSE       DEVELOPER'S SITE  API Signatures v2-  Single Series
- Multiple Series
- One or More Series with Optional Parameters 
- Latest Series 
- Popular Series
- All Surveys
- Single Survey
  API Signatures v1-  Single Series
- Multiple Series
- One or More Series, Specifying Years
  Sample Code- C#
- Java
- PHP
- Python
- R Script
- Ruby/Ruby on Rails
- SAS
- Unix Command Line
- Matlab
- Julia
  Terms Of Service  FAQs  Release Notes  Contact Us 

SEARCH DEVELOPER'S SITE | Accessing the Public Data API with C#On This Page- API Version 2.0 C# Sample Code
Single Series
Multiple Series
One or More Series with Optional Parameters

- API Version 1.0 C# Sample Code
Single Series
Multiple Series
Multiple Series, Multiple Years

API Version 2.0 C# Sample CodeSingle Series
Here is an example of how to use POST method in c# (Version 2.0, single series):
//Post request example version 2.0var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.bls.gov/publicAPI/v2/timeseries/data/");httpWebRequest.ContentType = "application/json";httpWebRequest.Method = "POST";//Using Javascript Serializerusing (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())){  var jS = new JavaScriptSerializer();  var newJson = jS.Serialize(new SeriesPost()  {      seriesid = (new List() { "CUUR0000SA0" }).ToArray(),      startyear = "",      endyear = "",      catalog = true,      calculations = true,      annualaverage = true,      registrationKey = "EnterRegistrationKeyHere"  });  //View the JSON output  System.Diagnostics.Debug.WriteLine(newJson);  streamWriter.Write(newJson);  streamWriter.Flush();  streamWriter.Close();}
 
TopMultiple Series
Here is an example of how to use POST method in c# (Version 2.0, multiple series):
//Post request example version 2.0var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.bls.gov/publicAPI/v2/timeseries/data/");httpWebRequest.ContentType = "application/json";httpWebRequest.Method = "POST";//Using Javascript Serializerusing (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())){  var jS = new JavaScriptSerializer();  var newJson = jS.Serialize(new SeriesPost()  {      seriesid = (new List() { "CUUR0000SA0", "WPUSOP3000" }).ToArray(),      startyear = "",      endyear = "",      catalog = true,      calculations = true,      annualaverage = true,      registrationKey = "EnterRegistrationKeyHere"  });  //So you can see the JSON thats output  System.Diagnostics.Debug.WriteLine(newJson);  streamWriter.Write(newJson);  streamWriter.Flush();  streamWriter.Close();}
 
One or More Series with Optional Parameters
Here is an example of how to use POST method in c# (Version 2.0, one or more series with optional parameters):
//Post request example version 2.0var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.bls.gov/publicAPI/v2/timeseries/data/");httpWebRequest.ContentType = "application/json";httpWebRequest.Method = "POST";//Using Javascript Serializerusing (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())){  var jS = new JavaScriptSerializer();  var newJson = jS.Serialize(new SeriesPost()  {      seriesid = (new List() { " CUUR0000SA0" }).ToArray(),      startyear = "2010",      endyear = "2015",      catalog = true,      calculations = true,      annualaverage = true,      registrationKey = "EnterRegistrationKeyHere"  });  //View the JSON output  System.Diagnostics.Debug.WriteLine(newJson);  streamWriter.Write(newJson);  streamWriter.Flush();  streamWriter.Close();}
 
API Version 1.0 C# Sample CodeSingle Series
Here is an example of version 1.0 single series:
//Post request example version 1.0var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.bls.gov/publicAPI/v1/timeseries/data/CUUR0000SA0");httpWebRequest.ContentType = "application/json";httpWebRequest.Method = "POST";
 
Multiple Series
Here is an example of version 1.0 multiple series:
//Post request example version 1.0var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.bls.gov/publicAPI/v1/timeseries/data/");httpWebRequest.ContentType = "application/json";httpWebRequest.Method = "POST";//Using Javascript Serializerusing (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())){  var jS = new JavaScriptSerializer();  var newJson = jS.Serialize(new SeriesPost()  {      seriesid = (new List() { "CUUR0000SA0", "WPUSOP3000" }).ToArray(),      startyear = "",      endyear = "",      catalog = true,      calculations = true,      annualaverage = true,  });  //So you can see the JSON thats output  System.Diagnostics.Debug.WriteLine(newJson);  streamWriter.Write(newJson);  streamWriter.Flush();  streamWriter.Close();}
 
Multiple Series, Multiple Years
Here is an example of version 1.0 multiple series specifying years:
//Post request example version 1.0var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.bls.gov/publicAPI/v1/timeseries/data/");httpWebRequest.ContentType = "application/json";httpWebRequest.Method = "POST";//Using Javascript Serializerusing (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())){  var jS = new JavaScriptSerializer();  var newJson = jS.Serialize(new SeriesPost()  {      seriesid = (new List() { "CUUR0000SA0", "WPUSOP3000" }).ToArray(),      startyear = "2010",      endyear = "2015",      catalog = true,      calculations = true,      annualaverage = true,  });  //So you can see the JSON thats output  System.Diagnostics.Debug.WriteLine(newJson);  streamWriter.Write(newJson);  streamWriter.Flush();  streamWriter.Close();}
 

 

**Last Modified Date:**June 22, 2016
Recommend this page using:FacebookTwitterLinkedIn- Home
- Subjects
- Data Tools
- Publications
- Economic Releases
- Classroom
- Beta
**U.S. Bureau of Labor Statistics**Postal Square Building2 Massachusetts Avenue NEWashington, DC 20212-0001Telephone: 1-202-691-5200 Telecommunications Relay Service: 7-1-1www.bls.govContact Us**resources**- Inspector General (OIG)
- Budget and Performance
- Department of Labor Grants
- No Fear Act
- USA.gov
- Vote.gov
**about the site**- Sitemap
- Freedom of Information Act
- Privacy and Security Statement
- Disclaimers
- Linking and Copyright Info
- Important Website Notices
- Help and Tutorials
- Babel Notice: accessing language services
Connect With BLSTwitterYoutubeEmail- Developers |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|